public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/107747] New: gcc trunk at -Os misses a global-buffer-overflow
@ 2022-11-18 9:29 shaohua.li at inf dot ethz.ch
2022-11-21 9:39 ` [Bug sanitizer/107747] " marxin at gcc dot gnu.org
2022-12-02 12:48 ` marxin at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2022-11-18 9:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107747
Bug ID: 107747
Summary: gcc trunk at -Os misses 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, `gcc-trunk -Os -fsanitize=address` misses the
global-buffer-overflow, while `gcc-trunk -Ox -fsanitize=address` (x=0,1, 2, 3)
can detect it.
gcc-12 can detect the global-buffer-overflow at all optimization levels.
clang-tk can also detect it at all optimization levels.
Compiler explorer: https://godbolt.org/z/j6vh4hhaq
% cat a.c
int a, e = 2;
long b;
int *c = &a;
char *d;
void main() {
*c = 0;
c = c + 1;
if (*c = e || (*d = 0))
for (; b;)
;
}
%
% gcc-tk -Os -fsanitize=address a.c && ./a.out
%
% gcc-tk -O3 -fsanitize=address a.c && ./a.out
=================================================================
==1==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000000404344
at pc 0x000000401159 bp 0x7fff230c86c0 sp 0x7fff230c86b8
WRITE of size 4 at 0x000000404344 thread T0
#0 0x401158 in main /app/example.c:8
#1 0x7fe78f129082 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId:
1878e6b475720c7c51969e69ab2d276fae6d1dee)
#2 0x4011cd in _start (/app/output.s+0x4011cd) (BuildId:
864a1d27e04c540136a2c693324ee073ba4b3fa0)
0x000000404344 is located 0 bytes after global variable 'a' defined in
'/app/example.c' (0x404340) of size 4
SUMMARY: AddressSanitizer: global-buffer-overflow /app/example.c:8 in main
Shadow bytes around the buggy address:
0x000000404080: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
0x000000404100: 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9
0x000000404180: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
0x000000404200: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
0x000000404280: f9 f9 f9 f9 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9
=>0x000000404300: 00 f9 f9 f9 f9 f9 f9 f9[04]f9 f9 f9 f9 f9 f9 f9
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
0x000000404480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000000404500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x000000404580: 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
%
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug sanitizer/107747] gcc trunk at -Os misses a global-buffer-overflow
2022-11-18 9:29 [Bug sanitizer/107747] New: gcc trunk at -Os misses a global-buffer-overflow shaohua.li at inf dot ethz.ch
@ 2022-11-21 9:39 ` marxin at gcc dot gnu.org
2022-12-02 12:48 ` marxin at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-11-21 9:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107747
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |marxin at gcc dot gnu.org
Last reconfirmed| |2022-11-21
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
I will take a look.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug sanitizer/107747] gcc trunk at -Os misses a global-buffer-overflow
2022-11-18 9:29 [Bug sanitizer/107747] New: gcc trunk at -Os misses a global-buffer-overflow shaohua.li at inf dot ethz.ch
2022-11-21 9:39 ` [Bug sanitizer/107747] " marxin at gcc dot gnu.org
@ 2022-12-02 12:48 ` marxin at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-12-02 12:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107747
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|ASSIGNED |RESOLVED
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Can't reproduce, also GCC master reports the issue.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-02 12:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18 9:29 [Bug sanitizer/107747] New: gcc trunk at -Os misses a global-buffer-overflow shaohua.li at inf dot ethz.ch
2022-11-21 9:39 ` [Bug sanitizer/107747] " marxin at gcc dot gnu.org
2022-12-02 12:48 ` marxin 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).