glibc/sysdeps/generic
Florian Weimer 5097cd344f elf: Avoid re-initializing already allocated TLS in dlopen (bug 31717)
The old code used l_init_called as an indicator for whether TLS
initialization was complete.  However, it is possible that
TLS for an object is initialized, written to, and then dlopen
for this object is called again, and l_init_called is not true at
this point.  Previously, this resulted in TLS being initialized
twice, discarding any interim writes (technically introducing a
use-after-free bug even).

This commit introduces an explicit per-object flag, l_tls_in_slotinfo.
It indicates whether _dl_add_to_slotinfo has been called for this
object.  This flag is used to avoid double-initialization of TLS.
In update_tls_slotinfo, the first_static_tls micro-optimization
is removed because preserving the initalization flag for subsequent
use by the second loop for static TLS is a bit complicated, and
another per-object flag does not seem to be worth it.  Furthermore,
the l_init_called flag is dropped from the second loop (for static
TLS initialization) because l_need_tls_init on its own prevents
double-initialization.

The remaining l_init_called usage in resize_scopes and update_scopes
is just an optimization due to the use of scope_has_map, so it is
not changed in this commit.

The isupper check ensures that libc.so.6 is TLS is not reverted.
Such a revert happens if l_need_tls_init is not cleared in
_dl_allocate_tls_init for the main_thread case, now that
l_init_called is not checked anymore in update_tls_slotinfo
in elf/dl-open.c.

Reported-by: Jonathon Anderson <janderson@rice.edu>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-08-05 18:26:52 +02:00
..
net Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
netinet Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
nfs Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
sys Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
_G_config.h
_itoa.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
a.out.h
abort-instr.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
adaptive_spin_count.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
aio_misc.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
allocalim.h
arch-fd_to_filename.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
asm-syntax.h
atomic-machine.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
c++-types.data
confstr.h
crti.S
crtn.S
device-nrs.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dirstream.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-affinity.h elf: Add CPU iteration support for future use in ld.so diagnostics 2024-04-08 16:48:55 +02:00
dl-audit-check.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-auxv.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-cache.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-call_tls_init_tp.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-debug.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-dtprocnum.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-dtv.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-execve.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-fcntl.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-fileid.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-fixup-attribute.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-fptr.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-hash.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-hwcap-check.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-irel.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-isa-level.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-lookupcfg.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-machine-rel.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-machine.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-minimal-malloc.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-mman.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-new-hash.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-osinfo.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-procinfo.c
dl-procinfo.h elf: Remove HWCAP_IMPORTANT 2024-06-18 10:45:36 +02:00
dl-procruntime.c
dl-prop.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-protected.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-r_debug.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-relocate-ld.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-symbol-redir-ifunc.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-sysdep.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-tls.h
dl-tunables-parse.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-unistd.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-vdso-setup.c
dl-vdso-setup.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dl-vdso.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
dwarf2.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
elf_machine_sym_no_match.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
elf-initfini.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
elf-read-prop.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
elide.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
eloop-threshold.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
entry.h
errqueue.h
fast-jitter.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fd_to_filename.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
features-time64.h Reinstate generic features-time64.h 2024-04-05 09:02:36 -03:00
fenv_private.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fix-float-double-convert-nan.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fix-fp-int-compare-invalid.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fix-fp-int-convert-overflow.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fix-int-fp-convert-zero.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
float128-abi.h
fork.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
fpu_control.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
framestate.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gcc-compat.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gccframe.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
get-rounding-mode.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gmp-mparam.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
hp-timing-common.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
hp-timing.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ifreq.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ifunc-init.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ifunc-sel.h
internal-signals.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
intr-msg.h
ld.abilist
ldbl-classify-compat.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ldconfig.h Remove ia64-linux-gnu 2024-01-08 17:09:36 -03:00
ldsodefs.h elf: Avoid re-initializing already allocated TLS in dlopen (bug 31717) 2024-08-05 18:26:52 +02:00
libanl.abilist
libBrokenLocale.abilist
libc_malloc_debug.abilist
libc_start_call_main.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libc-lock-arch.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libc-lock.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libc-mmap.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libc-mtag.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libc-start.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libc-symver.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libc-tsd.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libc.abilist
libdl.abilist
libm-alias-double.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libm-alias-float128.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libm-alias-float.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libm-alias-ldouble.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
libm-test-ulps
libm-test-ulps-name
libm.abilist
libnsl.abilist
libnss_compat.abilist
libnss_db.abilist
libnss_dns.abilist
libnss_files.abilist
libnss_hesiod.abilist
libnss_nis.abilist
libnss_nisplus.abilist
libpthread.abilist
libresolv.abilist
librt.abilist
libutil.abilist
link_map.h
linkmap.h
local-setxid.h
localplt.data
machine-gmon.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
machine-lock.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
machine-sp.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Makefile Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
malloc-alignment.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
malloc-hugepages.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
malloc-hugepages.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
malloc-machine.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
malloc-size.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
malloc-sysdep.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math_ldbl_opt.h
math_ldbl.h
math_private_calls.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math_private.h aarch64: Add vector implementations of cos routines 2023-06-30 09:04:10 +01:00
math-barriers.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-nan-payload-double.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-nan-payload-float.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-narrow-alias-float128.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-narrow-alias.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests-arch.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests-exceptions.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests-rounding.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests-snan-cast.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests-snan-payload.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests-snan.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests-trap-force.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests-trap.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-tests.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-type-macros-double.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-type-macros-float128.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-type-macros-float.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-type-macros-ldouble.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-type-macros.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
math-use-builtins-ceil.h
math-use-builtins-copysign.h
math-use-builtins-fabs.h
math-use-builtins-ffs.h string: Use builtins for ffs and ffsll 2024-02-01 09:31:33 -03:00
math-use-builtins-floor.h
math-use-builtins-fma.h
math-use-builtins-fmax.h
math-use-builtins-fmin.h
math-use-builtins-llrint.h
math-use-builtins-logb.h
math-use-builtins-lrint.h
math-use-builtins-nearbyint.h
math-use-builtins-rint.h
math-use-builtins-round.h
math-use-builtins-roundeven.h
math-use-builtins-sqrt.h
math-use-builtins-trunc.h
math-use-builtins.h string: Use builtins for ffs and ffsll 2024-02-01 09:31:33 -03:00
memcopy.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
memswap.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
mmap_info.h
mremap-failure.h Add mremap tests 2024-08-01 05:06:12 -07:00
nan-high-order-bit.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
not-cancel.h Make __getrandom_nocancel set errno and add a _nostatus version 2024-01-12 14:23:11 +01:00
not-errno.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
nscd-types.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
pagecopy.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
paths.h
pointer_guard.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
profil-counter.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
pty-private.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
rtld_static_init.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
rtld-lowlevel.h
safe-fatal.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
set-freeres-fp.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
set-freeres-os.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
set-freeres-system.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
set-hooks-arch.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
setjmpP.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
setvmaname.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
sigcontextinfo.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
siglist-compat-def.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
siglist.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
sigset-cvt-mask.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
sigsetops.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
single-thread.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
spawn_int_def.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
stackguard-macros.h
stackinfo.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
stap-probe-machine.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
startup.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
stdio-lock.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
string-fza.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
string-fzb.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
string-fzc.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
string-fzi.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
string-misc.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
string-opthr.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
string-optype.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
string-shift.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
struct_stat_time64.h
symbol-hacks.h
sysdep-cancel.h
sysdep.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
thread_state.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
time64-compat.h
time-clockid.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tininess.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tls-internal-struct.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tls-internal.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tls-internal.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tls-setup.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tls.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-audit.h
tst-file-align.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
tst-stack-align.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unsecvars.h elf: Remove LD_HWCAP_MASK / tunable glibc.cpu.hwcap_mask 2024-06-18 10:45:36 +02:00
unwind-arch.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unwind-dw2-fde-glibc.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unwind-dw2-fde.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unwind-dw2-fde.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unwind-dw2.c Remove ia64-linux-gnu 2024-01-08 17:09:36 -03:00
unwind-link.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unwind-pe.c
unwind-pe.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unwind-resume.c Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unwind-resume.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unwind.h Remove ia64-linux-gnu 2024-01-08 17:09:36 -03:00
utmp-equal.h Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
utmp-size.h login: Check default sizes of structs utmp, utmpx, lastlog 2024-04-19 14:38:17 +02:00
xstatver.h