Our ld hasn't generated __plt_{start,end} symbols for over a year, back in 
6.0, so it's time to kill support for them in ld.so.

(Where it matters, the need for the writable PLT is handled by
 a) marking it RWE which is automatically mapped as RW and then 
    mprotect()ed to RX after relocation process, and
 b) kbind(2) permiting direct modification.)

ok?

I strongly suspect the --no-secureplt option to ld on alpha has been 
useless for this last year, given the lack of __plt_{start,end} handling 
in ld's default script, but I don't have a box to prove it.  If someone 
can confirm that then there's still more code that can be thrown in the 
chipper-shredder.



Index: alpha/rtld_machine.c
===================================================================
RCS file: /data/src/openbsd/src/libexec/ld.so/alpha/rtld_machine.c,v
retrieving revision 1.61
diff -u -p -r1.61 rtld_machine.c
--- alpha/rtld_machine.c        16 Feb 2017 13:31:10 -0000      1.61
+++ alpha/rtld_machine.c        9 Sep 2017 03:34:08 -0000
@@ -306,11 +306,6 @@ _dl_md_reloc_got(elf_object_t *object, i
        _dl_protect_segment(object, seg_start, "__got_start", "__got_end",
            PROT_READ);
 
-       /* mprotect the PLT, if it isn't already read-only */
-       if (pltro == 0)
-               _dl_protect_segment(object, (Elf_Addr)pltgot, "__plt_start",
-                   "__plt_end", PROT_READ|PROT_EXEC);
-
        return (fails);
 }
 
Index: powerpc/rtld_machine.c
===================================================================
RCS file: /data/src/openbsd/src/libexec/ld.so/powerpc/rtld_machine.c,v
retrieving revision 1.62
diff -u -p -r1.62 rtld_machine.c
--- powerpc/rtld_machine.c      24 Jan 2017 10:59:10 -0000      1.62
+++ powerpc/rtld_machine.c      9 Sep 2017 03:28:38 -0000
@@ -573,10 +573,6 @@ _dl_md_reloc_got(elf_object_t *object, i
        if (prot_exec != 0 && got_addr != NULL)
                _dl_syncicache(got_addr, 4);
 
-       /* mprotect the PLT */
-       _dl_protect_segment(object, 0, "__plt_start", "__plt_end",
-           PROT_READ|prot_exec);
-
        return (fails);
 }
 
Index: sparc64/rtld_machine.c
===================================================================
RCS file: /data/src/openbsd/src/libexec/ld.so/sparc64/rtld_machine.c,v
retrieving revision 1.60
diff -u -p -r1.60 rtld_machine.c
--- sparc64/rtld_machine.c      28 Aug 2017 14:06:22 -0000      1.60
+++ sparc64/rtld_machine.c      9 Sep 2017 03:25:15 -0000
@@ -841,10 +841,6 @@ _dl_md_reloc_got(elf_object_t *object, i
        if (object->traced)
                lazy = 1;
 
-       /* temporarily make the PLT writable */
-       _dl_protect_segment(object, 0, "__plt_start", "__plt_end",
-           PROT_READ|PROT_WRITE);
-
        if (!lazy) {
                fails = _dl_md_reloc_all_plt(object);
        } else {
@@ -856,10 +852,6 @@ _dl_md_reloc_got(elf_object_t *object, i
 
        /* mprotect the GOT */
        _dl_protect_segment(object, 0, "__got_start", "__got_end", PROT_READ);
-
-       /* mprotect the PLT */
-       _dl_protect_segment(object, 0, "__plt_start", "__plt_end",
-           PROT_READ|PROT_EXEC);
 
        return (fails);
 }

Reply via email to