From 77523d5e43cb5721c23855eb6045b0607a3b30a0 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 4 Oct 2019 21:23:51 +0200 Subject: elf: Assign TLS modid later during dlopen [BZ #24930] Commit a42faf59d6d9f82e5293a9ebcc26d9c9e562b12b ("Fix BZ #16634.") attempted to fix a TLS modid consistency issue by adding additional checks to the open_verify function. However, this is fragile because open_verify cannot reliably predict whether _dl_map_object_from_fd will later fail in the more complex cases (such as memory allocation failures). Therefore, this commit assigns the TLS modid as late as possible. At that point, the link map pointer will eventually be passed to _dl_close, which will undo the TLS modid assignment. Reviewed-by: Gabriel F. T. Gomes --- elf/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'elf/Makefile') diff --git a/elf/Makefile b/elf/Makefile index 8f962991a3..dea51ca182 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -308,8 +308,8 @@ test-xfail-tst-protected1b = yes endif ifeq (yesyes,$(have-fpie)$(build-shared)) modules-names += tst-piemod1 -tests += tst-pie1 tst-pie2 tst-dlopen-pie -tests-pie += tst-pie1 tst-pie2 +tests += tst-pie1 tst-pie2 tst-dlopen-pie tst-dlopen-aout-pie +tests-pie += tst-pie1 tst-pie2 tst-dlopen-aout-pie ifeq (yes,$(have-protected-data)) tests += vismain tests-pie += vismain @@ -1267,7 +1267,11 @@ tst-leaks1-static-ENV = MALLOC_TRACE=$(objpfx)tst-leaks1-static.mtrace $(objpfx)tst-addr1: $(libdl) $(objpfx)tst-thrlock: $(libdl) $(shared-thread-library) + +tst-tst-dlopen-aout-no-pie = yes $(objpfx)tst-dlopen-aout: $(libdl) $(shared-thread-library) +CFLAGS-tst-dlopen-aout-pie.c += $(pie-ccflag) +$(objpfx)tst-dlopen-aout-pie: $(libdl) $(shared-thread-library) $(objpfx)tst-dlopen-aout-container: $(libdl) $(shared-thread-library) LDFLAGS-tst-dlopen-aout-container += -Wl,-rpath,\$$ORIGIN -- cgit 1.4.1