From d020b3ebded332d4f073bdb51c1d0c6fa98f756a Mon Sep 17 00:00:00 2001 From: Brandon Bergren Date: Sat, 14 Sep 2019 21:18:10 +0000 Subject: [PATCH] Fix aux_info corruption in rtld direct execution mode. After the aux vector is moved, it is necessary to re-digest aux_info so the pointers are updated to the new locations. This was causing thread creation to fail on powerpc64 when using direct execution due to a nonsense value being read for aux_info[AT_STACKPROT]. Approved by: jhibbits (mentor) Differential Revision: https://reviews.freebsd.org/D21656 --- libexec/rtld-elf/rtld.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index a42192dce8db..46bf1efddbd1 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -499,6 +499,13 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) if (auxp->a_type == AT_NULL) break; } + /* Since the auxiliary vector has moved, redigest it. */ + for (i = 0; i < AT_COUNT; i++) + aux_info[i] = NULL; + for (auxp = aux; auxp->a_type != AT_NULL; auxp++) { + if (auxp->a_type < AT_COUNT) + aux_info[auxp->a_type] = auxp; + } } else { _rtld_error("No binary"); rtld_die();