From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D4F1B3858C54; Wed, 27 Apr 2022 10:02:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4F1B3858C54 From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/105405] New: missed buffer-overflow in -O0 Date: Wed, 27 Apr 2022 10:02:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shaohua.li at inf dot ethz.ch X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2022 10:02:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105405 Bug ID: 105405 Summary: missed buffer-overflow in -O0 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxi= n at gcc dot gnu.org Target Milestone: --- For the following code, `gcc -fsanitize=3Daddress -O0` would miss the repor= t, while `gcc -fsanitize=3Daddress -O3` would not. $cat a.c main() { int a[1][1]; { int *b[1]; } a[1][3]++; } $ $gcc -fsanitize=3Daddress -w -O0 a.c ; ./a.out $ $gcc -fsanitize=3Daddress -w -O3 a.c ; ./a.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D6342=3D=3DERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f8843a00030 at pc 0x0000004010f9 bp 0x7fff0b7f6a40 sp 0x7fff0b7f6a38 READ of size 4 at 0x7f8843a00030 thread T0 #0 0x4010f8 in main (/shared/mutate/array/trial_new/work0/debug40/a.out+0x4010f8) #1 0x7f8845c570b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2) #2 0x40117d in _start (/shared/mutate/array/trial_new/work0/debug40/a.out+0x40117d) Address 0x7f8843a00030 is located in stack of thread T0 at offset 48 in fra= me #0 0x40107f in main (/shared/mutate/array/trial_new/work0/debug40/a.out+0x40107f) This frame has 1 object(s): [32, 36) 'a' (line 2) <=3D=3D Memory access at offset 48 overflows this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-overflow (/shared/mutate/array/trial_new/work0/debug40/a.out+0x4010f8) in main Shadow bytes around the buggy address: 0x0ff188737fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff188737fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff188737fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff188737fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff188737ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =3D>0x0ff188738000: f1 f1 f1 f1 04 f3[f3]f3 00 00 00 00 00 00 00 00 0x0ff188738010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff188738020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff188738030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff188738040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0ff188738050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb =3D=3D6342=3D=3DABORTING=