Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Nov 2018 18:12:19 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r340227 - stable/11/libexec/rtld-elf
Message-ID:  <201811071812.wA7ICJBg037750@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Wed Nov  7 18:12:18 2018
New Revision: 340227
URL: https://svnweb.freebsd.org/changeset/base/340227

Log:
  MFC r340137: 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

Modified:
  stable/11/libexec/rtld-elf/rtld.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/libexec/rtld-elf/rtld.c
==============================================================================
--- stable/11/libexec/rtld-elf/rtld.c	Wed Nov  7 18:07:29 2018	(r340226)
+++ stable/11/libexec/rtld-elf/rtld.c	Wed Nov  7 18:12:18 2018	(r340227)
@@ -705,10 +705,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);
@@ -741,6 +737,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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811071812.wA7ICJBg037750>