Implement _dl_catch_error, _dl_signal_error in libc.so [BZ #16628]

Message ID a00c7a1c-2ed9-a50d-8668-e8c213210875@linux.vnet.ibm.com
State New
Headers show

Commit Message

Stefan Liebler Dec. 1, 2016, 4:25 p.m.
On 11/29/2016 06:31 PM, Florian Weimer wrote:
> On 11/14/2016 04:07 PM, Florian Weimer wrote:

>> The attached patch depends on the elf/dl-load.c clean I posted today,

>> and the addition of the __sigsetjmp hidden definitions on architectures

>> which lack them.

>>

>> The removal of the two function pointers from libc.so (the one in

>> rtld_global, and the receiver pointer internal to elf/dl-error.c) is

>> desirable from a security perspective, too.

>

> I added a test.  This is what I want to commit soon unless some objects.

>

> Thanks,

> Florian

>


Hi Florian,

The first dlopen ("tst-latepthreadmod.so", RTLD_LOCAL | RTLD_LAZY) call 
in elf/tst-latepthread.c fails on s390x with "error: dlopen failed: 
.../build-s390x/elf/tst-latepthreadmod.so: undefined symbol: 
this_function_is_not_defined".

In elf/tst-latepthreadmod.c, this_function_is_not_defined is a sibling 
call which leads to a R_390_GLOB_DAT relocation in .rela.dyn instead of 
a R_390_JMP_SLOT in .rela.plt.

As RTLD_LAZY skips the JMP_SLOT relocations, but not GLOB_DAT ones, the 
dlopen call fails.
If elf/tst-latepthreadmod.c is build with -fno-optimize-sibling-calls, a 
JMP_SLOT relocation is generated for this_function_is_not_defined and 
the test passes.

Okay to commit?

Bye.
Stefan

---

ChangeLog:

	* elf/Makefile (CFLAGS-tst-latepthreadmod.c): Add
	-fno-optimize-sibling-calls.

Comments

Florian Weimer Dec. 2, 2016, 6:11 a.m. | #1
On 12/01/2016 05:25 PM, Stefan Liebler wrote:

>     * elf/Makefile (CFLAGS-tst-latepthreadmod.c): Add

>     -fno-optimize-sibling-calls.


Please commit this.  Thanks for finding a way to make the test work on 
s390x.  I had no idea it would break there, sorry.

Florian
Stefan Liebler Dec. 2, 2016, 8:19 a.m. | #2
On 12/02/2016 07:11 AM, Florian Weimer wrote:
> On 12/01/2016 05:25 PM, Stefan Liebler wrote:

>

>>     * elf/Makefile (CFLAGS-tst-latepthreadmod.c): Add

>>     -fno-optimize-sibling-calls.

>

> Please commit this.  Thanks for finding a way to make the test work on

> s390x.  I had no idea it would break there, sorry.

>

> Florian

>

Committed

Patch hide | download patch | download mbox

diff --git a/elf/Makefile b/elf/Makefile
index 33b003b..18b3e2a 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1271,6 +1271,9 @@  LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map
 # Force lazy binding for the same reason.
 LDFLAGS-tst-latepthreadmod.so = \
   -Wl,-z,lazy -Wl,--unresolved-symbols=ignore-all
+# Do not optimize sibling calls as the test relies on a JMP_SLOT relocation for
+# function this_function_is_not_defined.
+CFLAGS-tst-latepthreadmod.c = -fno-optimize-sibling-calls
 $(objpfx)tst-latepthreadmod.so: $(shared-thread-library)
 $(objpfx)tst-latepthread: $(libdl)
 $(objpfx)tst-latepthread.out: $(objpfx)tst-latepthreadmod.so