public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/105084] New: ASAN false positive on global-buffer-overflow
@ 2022-03-28 15:35 shaohua.li at inf dot ethz.ch
  2022-03-28 15:40 ` [Bug sanitizer/105084] " shaohua.li at inf dot ethz.ch
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2022-03-28 15:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105084

            Bug ID: 105084
           Summary: ASAN false positive on global-buffer-overflow
           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: ---

Hi,

ASAN seems to falsely report global-buffer-overflow with "-O1" and above. I
tested with gcc trunk, 11.0, 10.0, and 9.0. They all reported the same issue. I
wonder if this behaviour is intended or not. For clang's ASAN, it does not
report anything on the program.

$
$cat a.c
int a[] = {3};
int b = 7;

main() {
    unsigned int *c = &b;
    *c = a[1];
}
$
$gcc -fsanitize=address -w -O0; ./a.out
$
$gcc -fsanitize=address -w -O1; ./a.out
==292501==ERROR: AddressSanitizer: global-buffer-overflow on address
0x55aff123e040 at pc 0x55aff123b218 bp 0x7ffd41151fd0 sp 0x7ffd41151fc0
READ of size 4 at 0x55aff123e040 thread T0
    #0 0x55aff123b217 in main (/shared/oob/debug_wrong3/a.out+0x2217)
    #1 0x7f3933a360b2 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x240b2)
    #2 0x55aff123b10d in _start (/shared/oob/debug_wrong3/a.out+0x210d)

0x55aff123e040 is located 32 bytes to the left of global variable 'ak' defined
in 'simple.c:26:16' (0x55aff123e060) of size 4
0x55aff123e040 is located 28 bytes to the right of global variable 'al' defined
in 'simple.c:27:16' (0x55aff123e020) of size 4
SUMMARY: AddressSanitizer: global-buffer-overflow
(/shared/oob/debug_wrong3/a.out+0x2217) in main
Shadow bytes around the buggy address:
  0x0ab67e23fbb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab67e23fbc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab67e23fbd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab67e23fbe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab67e23fbf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ab67e23fc00: 00 00 00 00 04 f9 f9 f9[f9]f9 f9 f9 04 f9 f9 f9
  0x0ab67e23fc10: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab67e23fc20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab67e23fc30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ab67e23fc40: 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9
  0x0ab67e23fc50: 04 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-29  7:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 15:35 [Bug sanitizer/105084] New: ASAN false positive on global-buffer-overflow shaohua.li at inf dot ethz.ch
2022-03-28 15:40 ` [Bug sanitizer/105084] " shaohua.li at inf dot ethz.ch
2022-03-28 16:03 ` jakub at gcc dot gnu.org
2022-03-28 20:19 ` shaohua.li at inf dot ethz.ch
2022-03-29  7:17 ` rguenth at gcc dot gnu.org

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).