Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Run binaries with ELF_TYPE==DYN at virtual address ...



details:   https://anonhg.NetBSD.org/src/rev/7770f0252b2c
branches:  trunk
changeset: 752310:7770f0252b2c
user:      drochner <drochner%NetBSD.org@localhost>
date:      Mon Feb 22 19:46:18 2010 +0000

description:
Run binaries with ELF_TYPE==DYN at virtual address PAGE_SIZE rather
than 0. This is still not the intent of PIE, but it allows them to
run with VA 0 disabled.
(The PAX_ASLR stuff which should deal with this needs work.)
CV: ----------------------------------------------------------------------

diffstat:

 sys/kern/exec_elf.c |  18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diffs (48 lines):

diff -r 4890f777608c -r 7770f0252b2c sys/kern/exec_elf.c
--- a/sys/kern/exec_elf.c       Mon Feb 22 19:20:33 2010 +0000
+++ b/sys/kern/exec_elf.c       Mon Feb 22 19:46:18 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_elf.c,v 1.12 2009/12/14 00:48:35 matt Exp $       */
+/*     $NetBSD: exec_elf.c,v 1.13 2010/02/22 19:46:18 drochner Exp $   */
 
 /*-
  * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.12 2009/12/14 00:48:35 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.13 2010/02/22 19:46:18 drochner Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -155,6 +155,16 @@
            pax_offset, (unsigned long long)eh->e_entry);
 #endif
 }
+#else
+static void
+elf_placedynexec(Elf_Ehdr *eh, Elf_Phdr *ph)
+{
+       int i;
+
+       for (i = 0; i < eh->e_phnum; i++)
+               ph[i].p_vaddr += PAGE_SIZE;
+       eh->e_entry += PAGE_SIZE;
+}
 #endif /* PAX_ASLR */
 
 /*
@@ -715,9 +725,11 @@
        p->p_pax = epp->ep_pax_flags;
 #endif /* PAX_MPROTECT || PAX_SEGVGUARD || PAX_ASLR */
 
+       if (is_dyn)
 #ifdef PAX_ASLR
-       if (is_dyn)
                pax_aslr_elf(l, epp, eh, ph);
+#else
+               elf_placedynexec(eh, ph);
 #endif /* PAX_ASLR */
 
        /*



Home | Main Index | Thread Index | Old Index