public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/102453] New: buffer overflow by atomic built-ins not diagnosed
@ 2021-09-22 15:17 msebor at gcc dot gnu.org
2021-09-22 15:17 ` [Bug middle-end/102453] " msebor at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-09-22 15:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102453
Bug ID: 102453
Summary: buffer overflow by atomic built-ins not diagnosed
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The buffer overflow by the straight assignment in f() below is diagnosed as
expected but the equivalent overflow by the atomic built-in in g() is not even
though both should be. The problem is simply that due to an oversight, the
access warnings lack support for atomic built-ins.
$ cat y.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout y.c
extern _Atomic char x;
void f (void)
{
long *p = (long*)&x;
*p = 0;
}
void g (void)
{
long *p = (long*)&x;
__atomic_store_n (p, 0, 0);
}
y.c: In function ‘f’:
y.c:7:3: warning: array subscript ‘long int[0]’ is partly outside array bounds
of ‘_Atomic char[1]’ [-Warray-bounds]
7 | *p = 0;
| ^~
y.c:1:21: note: object ‘x’ of size 1
1 | extern _Atomic char x;
| ^
;; Function f (f, funcdef_no=0, decl_uid=1979, cgraph_uid=1, symbol_order=0)
void f ()
{
<bb 2> [local count: 1073741824]:
MEM[(long int *)&x] = 0;
return;
}
;; Function g (g, funcdef_no=1, decl_uid=1983, cgraph_uid=2, symbol_order=1)
void g ()
{
<bb 2> [local count: 1073741824]:
__atomic_store_8 (&x, 0, 0); [tail call]
return;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/102453] buffer overflow by atomic built-ins not diagnosed
2021-09-22 15:17 [Bug middle-end/102453] New: buffer overflow by atomic built-ins not diagnosed msebor at gcc dot gnu.org
@ 2021-09-22 15:17 ` msebor at gcc dot gnu.org
2021-10-11 21:49 ` msebor at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-09-22 15:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102453
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Keywords| |diagnostic
Blocks| |56456
Ever confirmed|0 |1
Last reconfirmed| |2021-09-22
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
[Bug 56456] [meta-bug] bogus/missing -Warray-bounds
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/102453] buffer overflow by atomic built-ins not diagnosed
2021-09-22 15:17 [Bug middle-end/102453] New: buffer overflow by atomic built-ins not diagnosed msebor at gcc dot gnu.org
2021-09-22 15:17 ` [Bug middle-end/102453] " msebor at gcc dot gnu.org
@ 2021-10-11 21:49 ` msebor at gcc dot gnu.org
2021-10-26 22:54 ` cvs-commit at gcc dot gnu.org
2021-10-26 23:02 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-11 21:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102453
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581396.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/102453] buffer overflow by atomic built-ins not diagnosed
2021-09-22 15:17 [Bug middle-end/102453] New: buffer overflow by atomic built-ins not diagnosed msebor at gcc dot gnu.org
2021-09-22 15:17 ` [Bug middle-end/102453] " msebor at gcc dot gnu.org
2021-10-11 21:49 ` msebor at gcc dot gnu.org
@ 2021-10-26 22:54 ` cvs-commit at gcc dot gnu.org
2021-10-26 23:02 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-26 22:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102453
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:
https://gcc.gnu.org/g:88b504b7a8c5affb0ffa97990d22af2b199e36ed
commit r12-4725-g88b504b7a8c5affb0ffa97990d22af2b199e36ed
Author: Martin Sebor <msebor@redhat.com>
Date: Tue Oct 26 14:34:16 2021 -0600
Detect overflow by atomic functions [PR102453].
Resolves:
PR middle-end/102453 - buffer overflow by atomic built-ins not diagnosed
gcc/ChangeLog:
PR middle-end/102453
* gimple-ssa-warn-access.cc (pass_waccess::check_atomic_builtin):
New.
(pass_waccess::check_atomic_builtin): Call it.
gcc/testsuite/ChangeLog:
PR middle-end/102453
* gcc.dg/Warray-bounds-90.c: New test.
* gcc.dg/Wstringop-overflow-77.c: New test.
* gcc.dg/Wstringop-overflow-78.c: New test.
* gcc.dg/Wstringop-overflow-79.c: New test.
* gcc.dg/Wstringop-overflow-80.c: New test.
* c-c++-common/gomp/atomic-4.c: Avoid an out-of-bounds access.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/102453] buffer overflow by atomic built-ins not diagnosed
2021-09-22 15:17 [Bug middle-end/102453] New: buffer overflow by atomic built-ins not diagnosed msebor at gcc dot gnu.org
` (2 preceding siblings ...)
2021-10-26 22:54 ` cvs-commit at gcc dot gnu.org
@ 2021-10-26 23:02 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-26 23:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102453
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|--- |12.0
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Done in r12-4725.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-26 23:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 15:17 [Bug middle-end/102453] New: buffer overflow by atomic built-ins not diagnosed msebor at gcc dot gnu.org
2021-09-22 15:17 ` [Bug middle-end/102453] " msebor at gcc dot gnu.org
2021-10-11 21:49 ` msebor at gcc dot gnu.org
2021-10-26 22:54 ` cvs-commit at gcc dot gnu.org
2021-10-26 23:02 ` msebor 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).