about summary refs log tree commit diff
path: root/sysdeps/x86_64/dl-tls.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2020-12-30 19:19:37 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2021-04-12 14:33:02 +0100
commit10fb15a36b3f6bc3e5ca62cda081c86512f47d32 (patch)
treec5592e531ca3a73bedecd9911762dcedca94d52a /sysdeps/x86_64/dl-tls.c
parentae990875879c5c4c14bb837c0971e88e2369193c (diff)
downloadglibc-10fb15a36b3f6bc3e5ca62cda081c86512f47d32.tar.gz
glibc-10fb15a36b3f6bc3e5ca62cda081c86512f47d32.tar.xz
glibc-10fb15a36b3f6bc3e5ca62cda081c86512f47d32.zip
elf: Use relaxed atomics for racy accesses [BZ #19329]
This is a follow up patch to the fix for bug 19329.  This adds
relaxed MO atomics to accesses that are racy, but relaxed MO is
enough.

--
v2:
- handle x86_64 dl-tls.c too
Diffstat (limited to 'sysdeps/x86_64/dl-tls.c')
-rw-r--r--sysdeps/x86_64/dl-tls.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sysdeps/x86_64/dl-tls.c b/sysdeps/x86_64/dl-tls.c
index 6595f6615b..24ef560b71 100644
--- a/sysdeps/x86_64/dl-tls.c
+++ b/sysdeps/x86_64/dl-tls.c
@@ -40,7 +40,8 @@ __tls_get_addr_slow (GET_ADDR_ARGS)
 {
   dtv_t *dtv = THREAD_DTV ();
 
-  if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation)))
+  size_t gen = atomic_load_relaxed (&GL(dl_tls_generation));
+  if (__glibc_unlikely (dtv[0].counter != gen))
     return update_get_addr (GET_ADDR_PARAM);
 
   return tls_get_addr_tail (GET_ADDR_PARAM, dtv, NULL);