Date: Wed, 7 Nov 2018 18:04: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-12@freebsd.org Subject: svn commit: r340225 - stable/12/libexec/rtld-elf Message-ID: <201811071804.wA7I4JiR032763@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Wed Nov 7 18:04:19 2018 New Revision: 340225 URL: https://svnweb.freebsd.org/changeset/base/340225 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 Approved by: re (gjb) Modified: stable/12/libexec/rtld-elf/rtld.c Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rtld-elf/rtld.c ============================================================================== --- stable/12/libexec/rtld-elf/rtld.c Wed Nov 7 17:44:27 2018 (r340224) +++ stable/12/libexec/rtld-elf/rtld.c Wed Nov 7 18:04:19 2018 (r340225) @@ -683,10 +683,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); @@ -719,6 +715,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?201811071804.wA7I4JiR032763>