about summary refs log tree commit diff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@redhat.com>2014-02-25 13:00:36 -0500
committerCarlos O'Donell <carlos@redhat.com>2014-02-25 13:18:15 -0500
commitd050367659e04685a0eab910e86ea6829a8d24f9 (patch)
treeeb094a22fb28449c7723b9463c388505ca31a5a3 /elf/rtld.c
parent4cbf380ce948ca15a965a78f0c1a092cf5956792 (diff)
downloadglibc-d050367659e04685a0eab910e86ea6829a8d24f9.tar.gz
glibc-d050367659e04685a0eab910e86ea6829a8d24f9.tar.xz
glibc-d050367659e04685a0eab910e86ea6829a8d24f9.zip
BZ #16613: Support TLS in audit libraries.
This commit fixes a bug where the dynamic loader would crash
when loading audit libraries, via LD_AUDIT, where those libraries
used TLS. The dynamic loader was not considering that the audit
libraries would use TLS and failed to bump the TLS generation
counter leaving TLS usage inconsistent after loading the audit
libraries.

https://sourceware.org/ml/libc-alpha/2014-02/msg00569.html
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index aa50cab0a9..7f1413af08 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1569,6 +1569,10 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
 	}
     }
 
+  /* Keep track of the currently loaded modules to count how many
+     non-audit modules which use TLS are loaded.  */
+  size_t count_modids = _dl_count_modids ();
+
   /* Set up debugging before the debugger is notified for the first time.  */
 #ifdef ELF_MACHINE_DEBUG_SETUP
   /* Some machines (e.g. MIPS) don't use DT_DEBUG in this way.  */
@@ -2220,7 +2224,8 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
 	_dl_start_profile ();
     }
 
-  if (!was_tls_init_tp_called && GL(dl_tls_max_dtv_idx) > 0)
+  if ((!was_tls_init_tp_called && GL(dl_tls_max_dtv_idx) > 0)
+      || count_modids != _dl_count_modids ())
     ++GL(dl_tls_generation);
 
   /* Now that we have completed relocation, the initializer data