about summary refs log tree commit diff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-11-27 16:37:17 +0100
committerFlorian Weimer <fweimer@redhat.com>2019-11-27 20:55:35 +0100
commita509eb117fac1d764b15eba64993f4bdb63d7f3c (patch)
tree072758cc02e49c7982abb01bc4a62106358188ad /elf/rtld.c
parent440b7f8653e4ed8f6e1425145208050b795e9a6c (diff)
downloadglibc-a509eb117fac1d764b15eba64993f4bdb63d7f3c.tar.gz
glibc-a509eb117fac1d764b15eba64993f4bdb63d7f3c.tar.xz
glibc-a509eb117fac1d764b15eba64993f4bdb63d7f3c.zip
Avoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112]
This change splits the scope and TLS slotinfo updates in dlopen into
two parts: one to resize the data structures, and one to actually apply
the update.  The call to add_to_global_resize in dl_open_worker is moved
before the demarcation point at which no further memory allocations are
allowed.

_dl_add_to_slotinfo is adjusted to make the list update optional.  There
is some optimization possibility here because we could grow the slotinfo
list of arrays in a single call, one the largest TLS modid is known.

This commit does not fix the fatal meory allocation failure in
_dl_update_slotinfo.  Ideally, this error during dlopen should be
recoverable.

The update order of scopes and TLS data structures is retained, although
it appears to be more correct to fully initialize TLS first, and then
expose symbols in the newly loaded objects via the scope update.

Tested on x86_64-linux-gnu.

Change-Id: I240c58387dabda3ca1bcab48b02115175fa83d6c
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index e22c7560c9..dd8fc5e6c6 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -2215,7 +2215,7 @@ ERROR: '%s': cannot process note segment.\n", _dl_argv[0]);
 
 	  /* Add object to slot information data if necessasy.  */
 	  if (l->l_tls_blocksize != 0 && tls_init_tp_called)
-	    _dl_add_to_slotinfo (l);
+	    _dl_add_to_slotinfo (l, true);
 	}
     }
   else
@@ -2260,7 +2260,7 @@ ERROR: '%s': cannot process note segment.\n", _dl_argv[0]);
 
 	  /* Add object to slot information data if necessasy.  */
 	  if (l->l_tls_blocksize != 0 && tls_init_tp_called)
-	    _dl_add_to_slotinfo (l);
+	    _dl_add_to_slotinfo (l, true);
 	}
       rtld_timer_stop (&relocate_time, start);