Author: kib
Date: Sat Sep 21 18:00:23 2019
New Revision: 352582
URL: https://svnweb.freebsd.org/changeset/base/352582

Log:
  Make non-ASLR pie base tunable.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/kern/imgact_elf.c

Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c  Sat Sep 21 17:59:15 2019        (r352581)
+++ head/sys/kern/imgact_elf.c  Sat Sep 21 18:00:23 2019        (r352582)
@@ -135,6 +135,11 @@ SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_R
     "enable execution from readable segments");
 #endif
 
+static u_long __elfN(pie_base) = ET_DYN_LOAD_ADDR;
+SYSCTL_ULONG(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, pie_base,
+    CTLFLAG_RWTUN, &__elfN(pie_base), 0,
+    "PIE load base without randomization");
+
 SYSCTL_NODE(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, aslr, CTLFLAG_RW, 
0,
     "");
 #define        ASLR_NODE_OID   __CONCAT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), 
_aslr)
@@ -1146,13 +1151,13 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i
                if (baddr == 0) {
                        if ((sv->sv_flags & SV_ASLR) == 0 ||
                            (fctl0 & NT_FREEBSD_FCTL_ASLR_DISABLE) != 0)
-                               et_dyn_addr = ET_DYN_LOAD_ADDR;
+                               et_dyn_addr = __elfN(pie_base);
                        else if ((__elfN(pie_aslr_enabled) &&
                            (imgp->proc->p_flag2 & P2_ASLR_DISABLE) == 0) ||
                            (imgp->proc->p_flag2 & P2_ASLR_ENABLE) != 0)
                                et_dyn_addr = ET_DYN_ADDR_RAND;
                        else
-                               et_dyn_addr = ET_DYN_LOAD_ADDR;
+                               et_dyn_addr = __elfN(pie_base);
                }
        }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to