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/108817] New: ASAN at -O3 failed to detect a global-buffer-overflow Date: Thu, 16 Feb 2023 08:16:43 +0000 [thread overview] Message-ID: <bug-108817-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108817 Bug ID: 108817 Summary: ASAN at -O3 failed to detect a global-buffer-overflow Product: gcc Version: 13.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, ASAN at -O3 (GCC>=12) missed the global buffer-overflow, while other opt levels detected it. GCC-11 can detect it at all opt levels. Although I was using -O3, I indeed observed the overflow read and the ASAN check in the assembly code. Compiler explorer: https://godbolt.org/z/9Yenz8roT % cat a.c long a; int b[3]; char c; int main() { int d; a = 2; for (; a >= 0; a--) { d = 0; for (; d <= 3; d++) c = b[a+1]; } return c; } % % gcc-tk -O3 -fsanitize=address a.c && ./a.out % % gcc-tk -O2 -fsanitize=address a.c && ./a.out ================================================================= ==1==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000004041cc at pc 0x00000040112b bp 0x7ffd88ccd090 sp 0x7ffd88ccd088 READ of size 4 at 0x0000004041cc thread T0 #0 0x40112a in main /a.c:10 #1 0x7f8b3fad2082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee) #2 0x40119d in _start (/a.s+0x40119d) (BuildId: 8f8919b865053b4da8e28daf8de45ed9390d0057) 0x0000004041cc is located 52 bytes before global variable 'a' defined in '/a.c' (0x404200) of size 8 0x0000004041cc is located 0 bytes after global variable 'b' defined in '/a.c' (0x4041c0) of size 12 SUMMARY: AddressSanitizer: global-buffer-overflow /a.c:10 in main Shadow bytes around the buggy address: 0x000000403f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000000403f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000000404000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000000404080: 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 0x000000404100: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 =>0x000000404180: 01 f9 f9 f9 f9 f9 f9 f9 00[04]f9 f9 f9 f9 f9 f9 0x000000404200: 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00 0x000000404280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000000404300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000000404380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x000000404400: 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 ... %
next reply other threads:[~2023-02-16 8:16 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-16 8:16 shaohua.li at inf dot ethz.ch [this message] 2023-02-17 14:31 ` [Bug sanitizer/108817] " marxin 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-108817-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).