2012-05-26 17:46:59 +00:00
|
|
|
# We don't need any header files.
|
|
|
|
abi-includes :=
|
|
|
|
|
|
|
|
abi-variants := 32 64 x32
|
|
|
|
|
|
|
|
abi-32-condition := !defined __x86_64__
|
|
|
|
abi-64-condition := defined __x86_64__ && defined __LP64__
|
|
|
|
abi-x32-condition := defined __x86_64__ && defined __ILP32__
|
2012-06-01 20:22:46 +00:00
|
|
|
|
|
|
|
ifeq ($(subdir),misc)
|
|
|
|
sysdep_headers += sys/elf.h sys/perm.h sys/reg.h sys/vm86.h sys/debugreg.h sys/io.h
|
|
|
|
endif
|
2014-05-14 22:32:18 +00:00
|
|
|
|
|
|
|
ifeq ($(subdir),nptl)
|
2018-10-02 14:51:48 +00:00
|
|
|
CFLAGS-elision-lock.c += -mrtm
|
|
|
|
CFLAGS-elision-unlock.c += -mrtm
|
|
|
|
CFLAGS-elision-timed.c += -mrtm
|
|
|
|
CFLAGS-elision-trylock.c += -mrtm
|
2014-05-14 22:32:18 +00:00
|
|
|
endif
|
2014-06-27 21:00:18 +00:00
|
|
|
|
x86: Make a space in jmpbuf for shadow stack pointer
To support Shadow Stack (SHSTK) in Intel Control-flow Enforcement
Technology (CET) in setjmp/longjmp, we need to save shadow stack
pointer in jmp_buf. The __saved_mask field in jmp_buf has type
of __sigset_t. On Linux, __sigset_t is defined as
#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
typedef struct
{
unsigned long int __val[_SIGSET_NWORDS];
} __sigset_t;
which is much bigger than expected by the __sigprocmask system call,
which has
typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;
For Linux/x86, we can shrink __sigset_t used by __saved_mask in jmp_buf
to add paddings for shadow stack pointer. As long as the new __sigset_t
is not smaller than sigset_t expected by the __sigprocmask system call,
it should work correctly.
This patch adds an internal header file, <setjmpP.h>, to define
__jmp_buf_sigset_t for __saved_mask in jmp_buf for Linux/x86 with a
space to store shadow stack pointer. It verifies __jmp_buf_sigset_t has
the suitable size for the __sigprocmask system call. A run-time test,
tst-saved_mask-1.c, is added to verify that size of __jmp_buf_sigset_t
is sufficient. If its size is too small, the test fails with
rt_sigprocmask(SIG_SETMASK, strace: umoven: short read (4 < 8) @0x7fa8aa28effc
0x7fa8aa28effc, NULL, 8) = -1 EFAULT (Bad address)
rt_sigprocmask(SIG_SETMASK, strace: umoven: short read (4 < 8) @0x7fa8aa28effc
0x7fa8aa28effc, NULL, 8) = -1 EFAULT (Bad address)
rt_sigprocmask(SIG_SETMASK, NULL, 0x7fa8aa28effc, 8) = -1 EFAULT (Bad address)
exit_group(1) = ?
Tested with build-many-glibcs.py.
* debug/longjmp_chk.c: Include <setjmpP.h> instead of
<setjmp.h>.
* setjmp/longjmp.c: Include <setjmpP.h> instead of <setjmp.h>.
(__libc_siglongjmp): Cast &env[0].__saved_mask to "sigset_t *".
* setjmp/sigjmp.c: Include <setjmpP.h> instead of <setjmp.h>.
(__sigjmp_save): Cast &env[0].__saved_mask to "sigset_t *".
* sysdeps/generic/setjmpP.h: New file.
* sysdeps/unix/sysv/linux/x86/jmp_buf-ssp.sym: Likewise.
* sysdeps/unix/sysv/linux/x86/setjmpP.h: Likewise.
* sysdeps/unix/sysv/linux/x86/tst-saved_mask-1.c: Likewise.
* sysdeps/unix/sysv/linux/x86/Makefile (gen-as-const-headers):
Add jmp_buf-ssp.sym.
(tests): Add tst-saved_mask-1.
2017-11-30 12:49:25 +00:00
|
|
|
ifeq ($(subdir),setjmp)
|
|
|
|
tests += tst-saved_mask-1
|
|
|
|
endif
|
2018-07-25 15:40:39 +00:00
|
|
|
|
2020-04-27 22:44:07 +00:00
|
|
|
ifneq ($(enable-cet),no)
|
2018-07-30 23:14:46 +00:00
|
|
|
ifeq ($(subdir),elf)
|
|
|
|
tests += tst-cet-property-1 tst-cet-property-2
|
|
|
|
|
|
|
|
CFLAGS-tst-cet-property-1.o += -fcf-protection
|
|
|
|
ASFLAGS-tst-cet-property-dep-2.o += -fcf-protection
|
|
|
|
|
|
|
|
$(objpfx)tst-cet-property-2: $(objpfx)tst-cet-property-dep-2.o
|
|
|
|
$(objpfx)tst-cet-property-2.out: $(objpfx)tst-cet-property-2 \
|
|
|
|
$(objpfx)tst-cet-property-1.out
|
|
|
|
env $(run-program-env) $(test-via-rtld-prefix) \
|
|
|
|
$(objpfx)tst-cet-property-2 \
|
|
|
|
< $(objpfx)tst-cet-property-1.out > $@; \
|
|
|
|
$(evaluate-test)
|
|
|
|
endif
|
|
|
|
|
2020-09-16 23:00:14 +00:00
|
|
|
ifeq ($(subdir),posix)
|
|
|
|
tests += tst-cet-vfork-1
|
|
|
|
CFLAGS-tst-cet-vfork-1.c += -mshstk
|
|
|
|
endif
|
|
|
|
|
2018-07-25 15:40:39 +00:00
|
|
|
ifeq ($(subdir),stdlib)
|
|
|
|
tests += tst-cet-setcontext-1
|
|
|
|
CFLAGS-tst-cet-setcontext-1.c += -mshstk
|
|
|
|
endif
|
|
|
|
endif
|