Module Name: src Committed By: drochner Date: Mon Feb 22 19:46:18 UTC 2010
Modified Files: src/sys/kern: exec_elf.c Log Message: 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: ---------------------------------------------------------------------- To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/kern/exec_elf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/exec_elf.c diff -u src/sys/kern/exec_elf.c:1.12 src/sys/kern/exec_elf.c:1.13 --- src/sys/kern/exec_elf.c:1.12 Mon Dec 14 00:48:35 2009 +++ src/sys/kern/exec_elf.c Mon Feb 22 19:46:18 2010 @@ -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 */ -#ifdef PAX_ASLR if (is_dyn) +#ifdef PAX_ASLR pax_aslr_elf(l, epp, eh, ph); +#else + elf_placedynexec(eh, ph); #endif /* PAX_ASLR */ /*