gcc/libgcc/config/i386
H.J. Lu bf6465d046 i386: Properly pop restore token in signal frame
Linux CET kernel places a restore token on shadow stack for signal
handler to enhance security.  The restore token is 8 byte and aligned
to 8 bytes.  It is usually transparent to user programs since kernel
will pop the restore token when signal handler returns.  But when an
exception is thrown from a signal handler, now we need to pop the
restore token from shadow stack.  For x86-64, we just need to treat
the signal frame as normal frame.  For i386, we need to search for
the restore token to check if the original shadow stack is 8 byte
aligned.  If the original shadow stack is 8 byte aligned, we just
need to pop 2 slots, one restore token, from shadow stack.  Otherwise,
we need to pop 3 slots, one restore token + 4 byte padding, from
shadow stack.

This patch also includes 2 tests, one has a restore token with 4 byte
padding and one without.

Tested on Linux/x86-64 CET machine with and without -m32.

libgcc/

	PR libgcc/85334
	* config/i386/shadow-stack-unwind.h (_Unwind_Frames_Increment):
	New.

gcc/testsuite/

	PR libgcc/85334
	* g++.target/i386/pr85334-1.C: New test.
	* g++.target/i386/pr85334-2.C: Likewise.
2020-02-10 07:59:10 -08:00
..
32 Update copyright years. 2020-01-01 12:51:42 +01:00
64
avx_resms64.S
avx_resms64f.S
avx_resms64fx.S
avx_resms64x.S
avx_savms64.S
avx_savms64f.S
cpuinfo.c Update copyright years. 2020-01-01 12:51:42 +01:00
cpuinfo.h Update copyright years. 2020-01-01 12:51:42 +01:00
crtfastmath.c Update copyright years. 2020-01-01 12:51:42 +01:00
crti.S Update copyright years. 2020-01-01 12:51:42 +01:00
crtn.S Update copyright years. 2020-01-01 12:51:42 +01:00
crtprec.c Update copyright years. 2020-01-01 12:51:42 +01:00
cygming-crtbegin.c Update copyright years. 2020-01-01 12:51:42 +01:00
cygming-crtend.c Update copyright years. 2020-01-01 12:51:42 +01:00
cygwin.S Update copyright years. 2020-01-01 12:51:42 +01:00
darwin-lib.h Update copyright years. 2020-01-01 12:51:42 +01:00
dragonfly-unwind.h Update copyright years. 2020-01-01 12:51:42 +01:00
elf-lib.h Update copyright years. 2020-01-01 12:51:42 +01:00
enable-execute-stack-mingw32.c Update copyright years. 2020-01-01 12:51:42 +01:00
freebsd-unwind.h Update copyright years. 2020-01-01 12:51:42 +01:00
gthr-win32.c Update copyright years. 2020-01-01 12:51:42 +01:00
gthr-win32.h Update copyright years. 2020-01-01 12:51:42 +01:00
i386-asm.h Update copyright years. 2020-01-01 12:51:42 +01:00
libgcc-bsd.ver Update copyright years. 2020-01-01 12:51:42 +01:00
libgcc-cygming.ver Update copyright years. 2020-01-01 12:51:42 +01:00
libgcc-darwin.10.4.ver Update copyright years. 2020-01-01 12:51:42 +01:00
libgcc-darwin.10.5.ver Update copyright years. 2020-01-01 12:51:42 +01:00
libgcc-glibc.ver Update copyright years. 2020-01-01 12:51:42 +01:00
libgcc-sol2.ver Update copyright years. 2020-01-01 12:51:42 +01:00
linux-unwind.h Update copyright years. 2020-01-01 12:51:42 +01:00
morestack.S Update copyright years. 2020-01-01 12:51:42 +01:00
resms64.h Update copyright years. 2020-01-01 12:51:42 +01:00
resms64f.h Update copyright years. 2020-01-01 12:51:42 +01:00
resms64fx.h Update copyright years. 2020-01-01 12:51:42 +01:00
resms64x.h Update copyright years. 2020-01-01 12:51:42 +01:00
savms64.h Update copyright years. 2020-01-01 12:51:42 +01:00
savms64f.h Update copyright years. 2020-01-01 12:51:42 +01:00
sfp-exceptions.c Update copyright years. 2020-01-01 12:51:42 +01:00
sfp-machine.h
shadow-stack-unwind.h i386: Properly pop restore token in signal frame 2020-02-10 07:59:10 -08:00
sol2-c1.S Update copyright years. 2020-01-01 12:51:42 +01:00
sol2-unwind.h Update copyright years. 2020-01-01 12:51:42 +01:00
sse_resms64.S
sse_resms64f.S
sse_resms64fx.S
sse_resms64x.S
sse_savms64.S
sse_savms64f.S
t-chkstk
t-cpuinfo
t-cpuinfo-static
t-crtpc
t-crtstuff
t-cygming
t-cygwin
t-darwin
t-dlldir
t-dlldir-x
t-dragonfly
t-dw2-eh
t-freebsd
t-gthr-win32
t-linux
t-mingw32
t-mingw-pthread
t-msabi
t-nto
t-seh-eh
t-sjlj-eh
t-slibgcc-cygming
t-softfp
t-sol2
t-stack-i386
value-unwind.h Update copyright years. 2020-01-01 12:51:42 +01:00
w32-unwind.h Update copyright years. 2020-01-01 12:51:42 +01:00