From e3e589829d16af9f7e73c7b70f74f3c5d5003e45 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 9 Dec 2021 09:49:32 +0100 Subject: nptl: Add glibc.pthread.rseq tunable to control rseq registration This tunable allows applications to register the rseq area instead of glibc. Reviewed-by: Szabolcs Nagy Reviewed-by: Siddhesh Poyarekar --- sysdeps/nptl/dl-tls_init_tp.c | 11 ++++++++++- sysdeps/nptl/dl-tunables.list | 6 ++++++ sysdeps/nptl/internaltypes.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'sysdeps/nptl') diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c index fedb876..b39dfbf 100644 --- a/sysdeps/nptl/dl-tls_init_tp.c +++ b/sysdeps/nptl/dl-tls_init_tp.c @@ -23,6 +23,9 @@ #include #include +#define TUNABLE_NAMESPACE pthread +#include + #ifndef __ASSUME_SET_ROBUST_LIST bool __nptl_set_robust_list_avail; rtld_hidden_data_def (__nptl_set_robust_list_avail) @@ -92,7 +95,13 @@ __tls_init_tp (void) } } - rseq_register_current_thread (pd); + { + bool do_rseq = true; +#if HAVE_TUNABLES + do_rseq = TUNABLE_GET (rseq, int, NULL); +#endif + rseq_register_current_thread (pd, do_rseq); + } /* Set initial thread's stack block from 0 up to __libc_stack_end. It will be bigger than it actually is, but for unwind.c/pt-longjmp.c diff --git a/sysdeps/nptl/dl-tunables.list b/sysdeps/nptl/dl-tunables.list index ac5d053..d24f4be 100644 --- a/sysdeps/nptl/dl-tunables.list +++ b/sysdeps/nptl/dl-tunables.list @@ -27,5 +27,11 @@ glibc { type: SIZE_T default: 41943040 } + rseq { + type: INT_32 + minval: 0 + maxval: 1 + default: 1 + } } } diff --git a/sysdeps/nptl/internaltypes.h b/sysdeps/nptl/internaltypes.h index 6032a6b..dec8c5b 100644 --- a/sysdeps/nptl/internaltypes.h +++ b/sysdeps/nptl/internaltypes.h @@ -48,6 +48,7 @@ struct pthread_attr #define ATTR_FLAG_OLDATTR 0x0010 #define ATTR_FLAG_SCHED_SET 0x0020 #define ATTR_FLAG_POLICY_SET 0x0040 +#define ATTR_FLAG_DO_RSEQ 0x0080 /* Used to allocate a pthread_attr_t object which is also accessed internally. */ -- cgit v1.1