aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-tls.c
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>2020-07-06 10:21:16 +0200
committerFlorian Weimer <fweimer@redhat.com>2020-07-06 10:21:16 +0200
commit0c76fc3c2b346dc5401dc055d97d4279632b0fb3 (patch)
tree67d7a99ad801c38a137fbb9d08ac54137bb901b9 /elf/dl-tls.c
parentf9cf87353772ca370b7bb901d86365a564fba49f (diff)
downloadglibc-0c76fc3c2b346dc5401dc055d97d4279632b0fb3.zip
glibc-0c76fc3c2b346dc5401dc055d97d4279632b0fb3.tar.gz
glibc-0c76fc3c2b346dc5401dc055d97d4279632b0fb3.tar.bz2
Linux: Perform rseq registration at C startup and thread creation
Register rseq TLS for each thread (including main), and unregister for each thread (excluding main). "rseq" stands for Restartable Sequences. See the rseq(2) man page proposed here: https://lkml.org/lkml/2018/9/19/647 Those are based on glibc master branch commit 3ee1e0ec5c. The rseq system call was merged into Linux 4.18. The TLS_STATIC_SURPLUS define is increased to leave additional room for dlopen'd initial-exec TLS, which keeps elf/tst-auditmany working. The increase (76 bytes) is larger than 32 bytes because it has not been increased in quite a while. The cost in terms of additional TLS storage is quite significant, but it will also obscure some initial-exec-related dlopen failures.
Diffstat (limited to 'elf/dl-tls.c')
-rw-r--r--elf/dl-tls.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index fa03234..ca13778 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -31,7 +31,7 @@
/* Amount of excess space to allocate in the static TLS area
to allow dynamic loading of modules defining IE-model TLS data. */
-#define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
+#define TLS_STATIC_SURPLUS 64 + DL_NNS * 176
/* Out-of-memory handler. */
@@ -134,6 +134,12 @@ void
_dl_determine_tlsoffset (void)
{
size_t max_align = TLS_TCB_ALIGN;
+ /* libc.so with rseq has TLS with 32-byte alignment. Since TLS is
+ initialized before audit modules are loaded and slotinfo
+ information is available, this is not taken into account below in
+ the audit case. */
+ max_align = MAX (max_align, 32U);
+
size_t freetop = 0;
size_t freebottom = 0;