svn commit: r340137 - head/libexec/rtld-elf

Ed Maste emaste at FreeBSD.org
Sun Nov 4 19:21:14 UTC 2018


Author: emaste
Date: Sun Nov  4 19:21:12 2018
New Revision: 340137
URL: https://svnweb.freebsd.org/changeset/base/340137

Log:
  rtld: move relro enforcement after ifunc processing
  
  Previously the combination of relro (implicit), -z now and ifunc use
  resulted in a segfault when applying ifuncs after relro (test binary
  here just calls amd64_get_fsbase()):
  
  | % env LD_DEBUG=1 libexec/rtld-elf/obj/ld-elf.so.1 a.out
  | ...
  | enforcing main obj relro
  | ...
  | resolving ifuncs
  | reloc_jmpslot: *0x203198 = 0x189368ea4570
  | zsh: bus error (core dumped)  LD_DEBUG=1 obj/ld-elf.so.1 ~/a.out
  
  Reported by:	Shawn Webb
  Reviewed by:	kib
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Sun Nov  4 19:11:32 2018	(r340136)
+++ head/libexec/rtld-elf/rtld.c	Sun Nov  4 19:21:12 2018	(r340137)
@@ -700,10 +700,6 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entr
     if (do_copy_relocations(obj_main) == -1)
 	rtld_die();
 
-    dbg("enforcing main obj relro");
-    if (obj_enforce_relro(obj_main) == -1)
-	rtld_die();
-
     if (getenv(_LD("DUMP_REL_POST")) != NULL) {
        dump_relocations(obj_main);
        exit (0);
@@ -737,6 +733,10 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entr
     if (resolve_objects_ifunc(obj_main,
       ld_bind_now != NULL && *ld_bind_now != '\0', SYMLOOK_EARLY,
       NULL) == -1)
+	rtld_die();
+
+    dbg("enforcing main obj relro");
+    if (obj_enforce_relro(obj_main) == -1)
 	rtld_die();
 
     if (!obj_main->crt_no_init) {


More information about the svn-src-all mailing list