An integer overflow triggered when processing inputs to the C++ new operator in libstdc+-v3/libsupc+/newopa.cc where sz + align could overflow with large sz or align, potentially resulting in an undersized allocation instead of throwing badalloc. Note that this only affects older gcc versions since 12.4 onwards (see pr113258) prefer posixmemalign over alignedalloc so on the RHEL front this should only affect RHEL9 and RHEL8 system gcc. The older libstdc++ (8.5.0) has a slightly different variant of that expression but has the same overflow problem.
libiberty/rust-demangle.c in GNU GCC 11.2 allows stack consumption in demangleconst, as demonstrated by nm-new.
DISPUTEDA failure in the -fstack-protector feature in GCC-based toolchains that target AArch64 allows an attacker to exploit an existing buffer overflow in dynamically-sized local variables in your application without this being detected. This stack-protector failure only applies to C99-style dynamically-sized local variables or those created using alloca(). The stack-protector operates as intended for statically-sized local variables.
The default behavior when the stack-protector detects an overflow is to terminate your application, resulting in controlled loss of availability. An attacker who can exploit a buffer overflow without triggering the stack-protector might be able to change program flow control to cause an uncontrolled loss of availability or to go further and affect confidentiality or integrity. NOTE: The GCC project argues that this is a missed hardening bug and not a vulnerability by itself.
GCC v12.0 was discovered to contain an uncontrolled recursion via the component libiberty/rust-demangle.c. This vulnerability allows attackers to cause a Denial of Service (DoS) by consuming excessive CPU and memory resources.
Under certain circumstances, the ix86expandbuiltin function in i386.c in GNU Compiler Collection (GCC) version 4.6, 4.7, 4.8, 4.9, 5 before 5.5, and 6 before 6.4 will generate instruction sequences that clobber the status flag of the RDRAND and RDSEED intrinsics before it can be read, potentially causing failures of these instructions to go unreported.
Upstream bug:
https://gcc.gnu.org/bugzilla/showbug.cgi?id=80180
Upstream patch:
https://gcc.gnu.org/ml/gcc-patches/2017-03/msg01349.html
References:
http://seclists.org/oss-sec/2017/q3/218
It was reported that targets that use libssp for SSP (e.g. newlib, Cygwin, RTEMS, MinGW, but not e.g. Glibc, Bionic, NetBSD which provide SSP in libc) are mistakenly missing out on -DFORTIFYSOURCE functionality even when explicitly specified. The problem is in gcc libssp/Makefile.am:
libsubincludedir = $(libdir)/gcc/$(targetnoncanonical)/$(gccversion)/include nobaselibsubincludeHEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h
Headers are structured so that they should be in $(libsubincludedir), instead of $(libsubincludedir)/ssp where they are currently placed.
Demonstration:
$ cat fortifytest.c / example from https://gcc.gnu.org/bugzilla/showbug.cgi?id=50460 [Open URL] / #include <stdio.h> #include <string.h>
const char str1 = "JIHGFEDCBA";
int main () { struct A { char buf1[9]; char buf2[1]; } a; strcpy (a.buf1 + (0 + 4), str1 + 5); printf("%s %s\n", a.buf1, a.buf2); return 0; }
$ gcc -DFORTIFYSOURCE=2 -fstack-protector-strong -o fortifytest -O2 fortifytest.c $ nm -C fortifytest | grep strcpy U strcpychk@@GLIBC2.3.4
$ i686-w64-mingw32-gcc -DFORTIFYSOURCE=2 -fstack-protector-strong -o fortifytest.exe -O2 fortifytest.c $ i686-w64-mingw32-nm -C fortifytest.exe | grep strcpy 004061e8 I impstrcpy 00402624 T strcpy
If headers are moved, we can see:
$ i686-w64-mingw32-gcc -DFORTIFYSOURCE=2 -fstack-protector-strong -o fortifytest.exe -O2 fortifytest.c $ i686-w64-mingw32-nm -C fortifytest.exe | grep strcpy 00406200 I impstrcpychk 00401590 T strcpychk