about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/hppa/pthread.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-12-19 02:43:50 -0800
committerH.J. Lu <hjl.tools@gmail.com>2017-12-19 02:44:04 -0800
commitf81ddabffd76ac9dd600b02adbf3e1dac4bb10ec (patch)
tree7f9cac093b8e4d135be6ba830cd2bfe9a004131f /sysdeps/unix/sysv/linux/hppa/pthread.h
parent1a49fc59e42513247eaeac3feac6b099157eea7c (diff)
downloadglibc-f81ddabffd76ac9dd600b02adbf3e1dac4bb10ec.tar.gz
glibc-f81ddabffd76ac9dd600b02adbf3e1dac4bb10ec.tar.xz
glibc-f81ddabffd76ac9dd600b02adbf3e1dac4bb10ec.zip
Linux/x86: Update cancel_jmp_buf to match __jmp_buf_tag [BZ #22563]
On x86, padding in struct __jmp_buf_tag is used for shadow stack pointer
to support shadow stack in Intel Control-flow Enforcemen Technology.
Since the cancel_jmp_buf array is passed to setjmp and longjmp by
casting it to pointer to struct __jmp_buf_tag, it should be as large
as struct __jmp_buf_tag.  Otherwise when shadow stack is enabled,
setjmp and longjmp will write and read beyond cancel_jmp_buf when saving
and restoring shadow stack pointer.

This patch adds bits/types/__cancel_jmp_buf_tag.h to define struct
__cancel_jmp_buf_tag so that Linux/x86 can add saved_mask to
cancel_jmp_buf.

Tested natively on i386, x86_64 and x32.  Tested hppa-linux-gnu with
build-many-glibcs.py.

	[BZ #22563]
	* bits/types/__cancel_jmp_buf_tag.h: New file.
	* sysdeps/unix/sysv/linux/x86/bits/types/__cancel_jmp_buf_tag.h
	* sysdeps/unix/sysv/linux/x86/pthreaddef.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/nptl/pthreadP.h: Likewise.
	* nptl/Makefile (headers): Add
	bits/types/__cancel_jmp_buf_tag.h.
	* nptl/descr.h [NEED_SAVED_MASK_IN_CANCEL_JMP_BUF]
	(pthread_unwind_buf): Add saved_mask to cancel_jmp_buf.
	* sysdeps/nptl/pthread.h: Include
	<bits/types/__cancel_jmp_buf_tag.h>.
	(__pthread_unwind_buf_t): Use struct __cancel_jmp_buf_tag with
	__cancel_jmp_buf.
	* sysdeps/unix/sysv/linux/hppa/pthread.h: Likewise.
Diffstat (limited to 'sysdeps/unix/sysv/linux/hppa/pthread.h')
-rw-r--r--sysdeps/unix/sysv/linux/hppa/pthread.h7
1 files changed, 2 insertions, 5 deletions
diff --git a/sysdeps/unix/sysv/linux/hppa/pthread.h b/sysdeps/unix/sysv/linux/hppa/pthread.h
index d1973741cd..3d69ddcd00 100644
--- a/sysdeps/unix/sysv/linux/hppa/pthread.h
+++ b/sysdeps/unix/sysv/linux/hppa/pthread.h
@@ -27,6 +27,7 @@
 #include <bits/setjmp.h>
 #include <bits/wordsize.h>
 #include <bits/types/struct_timespec.h>
+#include <bits/types/__cancel_jmp_buf_tag.h>
 
 
 /* Detach state.  */
@@ -499,11 +500,7 @@ extern void pthread_testcancel (void);
 
 typedef struct
 {
-  struct
-  {
-    __jmp_buf __cancel_jmp_buf;
-    int __mask_was_saved;
-  } __cancel_jmp_buf[1];
+  struct __cancel_jmp_buf_tag __cancel_jmp_buf[1];
   void *__pad[4];
 } __pthread_unwind_buf_t __attribute__ ((__aligned__));