glibc/sysdeps/unix/sysv/linux/i386
H.J. Lu 5d844e1b72 i386: Enable CET support in ucontext functions
1. getcontext and swapcontext are updated to save the caller's shadow
stack pointer and return address.
2. setcontext and swapcontext are updated to restore shadow stack and
jump to new context directly.
3. makecontext is updated to allocate a new shadow stack and set the
caller's return address to the helper code, L(exitcode).
4. Since we no longer save and restore EAX, ECX and EDX in getcontext,
setcontext and swapcontext, we can use them as scratch register slots
to enable CET in ucontext functions.

Since makecontext allocates a new shadow stack when making a new
context and kernel allocates a new shadow stack for clone/fork/vfork
syscalls, we track the current shadow stack base.  In setcontext and
swapcontext, if the target shadow stack base is the same as the current
shadow stack base, we unwind the shadow stack.  Otherwise it is a stack
switch and we look for a restore token.

We enable shadow stack at run-time only if program and all used shared
objects, including dlopened ones, are shadow stack enabled, which means
that they must be compiled with GCC 8 or above and glibc 2.28 or above.
We need to save and restore shadow stack only if shadow stack is enabled.
When caller of getcontext, setcontext, swapcontext and makecontext is
compiled with smaller ucontext_t, shadow stack won't be enabled at
run-time.  We check if shadow stack is enabled before accessing the
extended field in ucontext_t.

Tested on i386 CET/non-CET machines.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-02-14 15:15:25 -08:00
..
i686 Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
i786
____longjmp_chk.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
arch-syscall.h Linux: Add tables with system call numbers 2020-01-02 10:18:10 +01:00
brk.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
c++-types.data
clone.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
configure
configure.ac
dl-librecon.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
dl-procinfo.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
dl-sysdep.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
fxstat.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
fxstatat.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
getcontext.S i386: Enable CET support in ucontext functions 2020-02-14 15:15:25 -08:00
Implies
jmp_buf-macros.h
kernel-features.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
ld.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
ldconfig.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
libanl.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
libBrokenLocale.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
libc-do-syscall.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
libc.abilist Finish move of clock_* functions to libc. [BZ #24959] 2019-09-04 14:39:38 +02:00
libcrypt.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
libdl.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
libm.abilist Make totalorder and totalordermag functions take pointer arguments. 2019-08-15 15:18:34 +00:00
libnsl.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
libpthread.abilist nptl: Move waitpid implementation to libc 2019-12-19 16:11:09 -03:00
libresolv.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
librt.abilist Finish move of clock_* functions to libc. [BZ #24959] 2019-09-04 14:39:38 +02:00
libthread_db.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
libutil.abilist Ignore absolute symbols in ABI tests. 2018-05-04 15:46:32 +00:00
localplt.data
lxstat.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
makecontext.S i386: Enable CET support in ucontext functions 2020-02-14 15:15:25 -08:00
Makefile i386: Fix i386 sigaction sa_restorer initialization (BZ#21269) 2018-03-05 18:08:27 -03:00
readelflib.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
register-dump.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
setcontext.S i386: Enable CET support in ucontext functions 2020-02-14 15:15:25 -08:00
shlib-versions
sigaction.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
sigcontextinfo.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
smp.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
startup.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
swapcontext.S i386: Enable CET support in ucontext functions 2020-02-14 15:15:25 -08:00
syscall.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
syscalls.list
sysdep.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
sysdep.h i386: Enable CET support in ucontext functions 2020-02-14 15:15:25 -08:00
tst-bz21269.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
ucontext_i.sym i386: Enable CET support in ucontext functions 2020-02-14 15:15:25 -08:00
Versions
vfork.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
xstat.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00