public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "shaohua.li at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/105396] New: missed stack-buffer-overflow by -O0 Date: Tue, 26 Apr 2022 12:43:09 +0000 [thread overview] Message-ID: <bug-105396-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105396 Bug ID: 105396 Summary: missed stack-buffer-overflow by -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, marxin at gcc dot gnu.org Target Milestone: --- For the following code, `gcc -fsanitize=address -O0` misses the buffer-overflow, while `gcc -fsanitize=address -O3` catches it. $cat a.c int main() { int a; int *b[1]; int c[10]; int d[1][1]; for (a = 0; a < 1; a++) d[1][a] = 0; } $ $gcc -fsanitize=address -O0;./a.out $ $gcc -fsanitize=address -O3;./a.out ==1==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffda35c0d4 at pc 0x000000401104 bp 0x7fffda35c0a0 sp 0x7fffda35c098 WRITE of size 4 at 0x7fffda35c0d4 thread T0 #0 0x401103 in main /app/example.c:8 #1 0x7fc3351380b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b2) #2 0x40118d in _start (/app/output.s+0x40118d) Address 0x7fffda35c0d4 is located in stack of thread T0 at offset 36 in frame #0 0x40107f in main /app/example.c:2 This frame has 1 object(s): [32, 36) 'd' (line 6) <== Memory access at offset 36 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 /app/example.c:8 in main Shadow bytes around the buggy address: 0x10007b4637c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007b4637d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007b4637e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007b4637f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007b463800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x10007b463810: 00 00 00 00 00 00 f1 f1 f1 f1[04]f3 f3 f3 00 00 0x10007b463820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007b463830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007b463840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007b463850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10007b463860: 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 ==1==ABORTING
next reply other threads:[~2022-04-26 12:43 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-26 12:43 shaohua.li at inf dot ethz.ch [this message] 2022-04-26 13:40 ` [Bug sanitizer/105396] " marxin at gcc dot gnu.org 2022-04-26 13:47 ` jakub at gcc dot gnu.org 2022-04-26 14:39 ` jakub at gcc dot gnu.org 2022-04-26 14:41 ` jakub at gcc dot gnu.org 2022-04-26 15:05 ` jakub at gcc dot gnu.org 2022-04-27 6:35 ` cvs-commit at gcc dot gnu.org 2022-04-27 6:36 ` [Bug sanitizer/105396] [9/10/11 Regression] " jakub at gcc dot gnu.org 2022-05-06 23:44 ` cvs-commit at gcc dot gnu.org 2022-05-09 11:26 ` [Bug sanitizer/105396] [9/10 " jakub at gcc dot gnu.org 2022-05-10 8:26 ` cvs-commit at gcc dot gnu.org 2022-05-11 6:26 ` cvs-commit at gcc dot gnu.org 2022-05-11 6:36 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-105396-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).