glibc/sysdeps
Florian Weimer 440b7f8653 Avoid late failure in dlopen in global scope update [BZ #25112]
The call to add_to_global in dl_open_worker happens after running ELF
constructors for new objects.  At this point, proper recovery from
malloc failure would be quite complicated: We would have to run the
ELF destructors and close all opened objects, something that we
currently do not do.

Instead, this change splits add_to_global into two phases,
add_to_global_resize (which can raise an exception, called before ELF
constructors run), and add_to_global_update (which cannot, called
after ELF constructors).  A complication arises due to recursive
dlopen: After the inner dlopen consumes some space, the pre-allocation
in the outer dlopen may no longer be sufficient.  A new member in the
namespace structure, _ns_global_scope_pending_adds keeps track of the
maximum number of objects that need to be added to the global scope.
This enables the inner add_to_global_resize call to take into account
the needs of an outer dlopen.

Most code in the dynamic linker assumes that the number of global
scope entries fits into an unsigned int (matching the r_nlist member
of struct r_scop_elem).  Therefore, change the type of
_ns_global_scope_alloc to unsigned int (from size_t), and add overflow
checks.

Change-Id: Ie08e2f318510d5a6a4bcb1c315f46791b5b77524
2019-11-27 20:55:35 +01:00
..
aarch64 nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
alpha nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
arm nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
csky nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
generic Avoid late failure in dlopen in global scope update [BZ #25112] 2019-11-27 20:55:35 +01:00
gnu Add TCP_TX_DELAY from Linux 5.3 to netinet/tcp.h. 2019-09-27 13:37:36 +00:00
hppa nptl: Add struct_rwlock.h 2019-11-26 13:53:36 +00:00
htl time: Introduce function to check correctness of nanoseconds value 2019-10-27 21:49:25 +01:00
hurd Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
i386 nptl: Add tests for internal pthread_rwlock_t offsets 2019-11-26 13:53:36 +00:00
ia64 nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
ieee754 ldbl-128ibm-compat: Add syslog functions 2019-11-27 15:52:41 -03:00
init_array Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
m68k nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
mach hurd: Suppress GCC 10 -Warray-bounds warning in init-first.c [BZ #25097] 2019-11-16 15:40:59 +01:00
microblaze nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
mips nptl: Add struct_rwlock.h 2019-11-26 13:53:36 +00:00
nios2 nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
nptl nptl: Fix __PTHREAD_MUTEX_INITIALIZER for !__PTHREAD_MUTEX_HAVE_PREV 2019-11-26 17:00:19 -03:00
posix sysdeps/posix/getaddrinfo: Return early on invalid address family 2019-11-26 10:19:33 +01:00
powerpc nptl: Add default pthreadtypes-arch.h 2019-11-26 13:53:36 +00:00
pthread Change most internal uses of __gettimeofday to __clock_gettime. 2019-10-30 17:04:10 -03:00
riscv nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
s390 S390: Fix handling of needles crossing a page in strstr z15 ifunc-variant. [BZ #25226] 2019-11-27 12:35:40 +01:00
sh nptl: Add default pthread-offsets.h 2019-11-26 13:53:36 +00:00
sparc sparc: Use atomic compiler builtins on sparc 2019-11-27 10:31:13 -03:00
unix sparc: Use atomic compiler builtins on sparc 2019-11-27 10:31:13 -03:00
wordsize-32 Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
wordsize-64 Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
x86 nptl: Add struct_rwlock.h 2019-11-26 13:53:36 +00:00
x86_64 nptl: Add tests for internal pthread_rwlock_t offsets 2019-11-26 13:53:36 +00:00