glibc/debug
H.J. Lu f33632ccd1 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 04:58:01 -08:00
..
asprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
backtrace-tst.c Add #include <stdint.h> for uint[32|64]_t usage (except installed headers). 2013-05-16 11:32:54 -05:00
backtrace.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
backtracesyms.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
backtracesymsfd.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
catchsegv.sh Update copyright dates not handled by scripts/update-copyrights. 2017-01-01 00:26:24 +00:00
chk_fail.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
confstr_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Depend * stdlib/bits/stdlib.h: New file. 2005-07-13 06:09:58 +00:00
dprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
execinfo.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
explicit_bzero_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fdelt_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fgets_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fgets_u_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fgetws_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fgetws_u_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fortify_fail.c __fortify_fail: Remove internal_function attribute 2017-08-13 21:10:44 +02:00
fprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fread_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fread_u_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
fwprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
getcwd_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
getdomainname_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
getgroups_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
gethostname_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
gets_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
getwd_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
longjmp_chk.c x86: Make a space in jmpbuf for shadow stack pointer 2017-11-30 04:58:01 -08:00
Makefile Enable unwind info in libc-start.c and backtrace.c 2017-09-19 15:07:58 +01:00
mbsnrtowcs_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mbsrtowcs_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mbstowcs_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
memcpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
memmove_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mempcpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
memset_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
noophooks.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
obprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
pcprofile.c Narrowing the visibility of libc-internal.h even further. 2017-03-01 20:33:46 -05:00
pcprofiledump.c Fix pcprofiledump cross-endian condition (bug 22086). 2017-09-05 15:14:09 +00:00
poll_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
ppoll_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
pread64_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
pread_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
printf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
read_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
readlink_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
readlinkat_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
readonly-area.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
realpath_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
recv_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
recvfrom_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
segfault.c Fix struct sigaltstack namespace (bug 21517). 2017-06-05 10:17:46 +00:00
snprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
sprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
stack_chk_fail_local.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
stack_chk_fail.c Avoid backtrace from __stack_chk_fail [BZ #12189] 2017-07-11 07:44:14 -07:00
stpcpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
stpncpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
strcat_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
strcpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
strncat_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
strncpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
swprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
test-stpcpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
test-strcpy_chk.c Update string tests to use the support test driver. 2017-03-23 11:32:29 -03:00
tst-backtrace2.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
tst-backtrace3.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
tst-backtrace4.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
tst-backtrace5.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
tst-backtrace6.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
tst-backtrace.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
tst-chk1.c Clean up conditionals for declaration of gets. 2017-02-25 09:47:51 -05:00
tst-chk2.c 2004-10-15 Jakub Jelinek <jakub@redhat.com> 2004-10-18 04:17:19 +00:00
tst-chk3.c 2004-10-15 Jakub Jelinek <jakub@redhat.com> 2004-10-18 04:17:19 +00:00
tst-chk4.cc * misc/sys/cdefs.h (__va_arg_pack): Define for GCC 4.3+. 2007-09-15 02:38:04 +00:00
tst-chk5.cc * misc/sys/cdefs.h (__va_arg_pack): Define for GCC 4.3+. 2007-09-15 02:38:04 +00:00
tst-chk6.cc * misc/sys/cdefs.h (__va_arg_pack): Define for GCC 4.3+. 2007-09-15 02:38:04 +00:00
tst-lfschk1.c * posix/bits/unistd.h (pread) [__USE_FILE_OFFSET64]: Use __off64_t 2005-03-20 16:51:05 +00:00
tst-lfschk2.c * posix/bits/unistd.h (pread) [__USE_FILE_OFFSET64]: Use __off64_t 2005-03-20 16:51:05 +00:00
tst-lfschk3.c * posix/bits/unistd.h (pread) [__USE_FILE_OFFSET64]: Use __off64_t 2005-03-20 16:51:05 +00:00
tst-lfschk4.cc * misc/sys/cdefs.h (__va_arg_pack): Define for GCC 4.3+. 2007-09-15 02:38:04 +00:00
tst-lfschk5.cc * misc/sys/cdefs.h (__va_arg_pack): Define for GCC 4.3+. 2007-09-15 02:38:04 +00:00
tst-lfschk6.cc * misc/sys/cdefs.h (__va_arg_pack): Define for GCC 4.3+. 2007-09-15 02:38:04 +00:00
tst-longjmp_chk2.c test-skeleton.c: Add write_message function 2016-06-23 11:00:36 +02:00
tst-longjmp_chk3.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
tst-longjmp_chk.c tests: unify fortification handler logic 2014-02-08 06:58:43 -05:00
tst-ssp-1.c Avoid backtrace from __stack_chk_fail [BZ #12189] 2017-07-11 07:44:14 -07:00
ttyname_r_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
vasprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
vdprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Versions New string function explicit_bzero (from OpenBSD). 2016-12-16 16:21:54 -05:00
vfprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
vfwprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
vprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
vsnprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
vsprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
vswprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
vwprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
warning-nop.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcpcpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcpncpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcrtomb_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcscat_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcscpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcsncat_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcsncpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcsnrtombs_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcsrtombs_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wcstombs_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wctomb_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wmemcpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wmemmove_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wmempcpy_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wmemset_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
wprintf_chk.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
xtrace.sh Update copyright dates not handled by scripts/update-copyrights. 2017-01-01 00:26:24 +00:00