summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_elf.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2011-10-15 12:35:18 +0000
committerkib <kib@FreeBSD.org>2011-10-15 12:35:18 +0000
commit8e118d38cf6e48ba3629cca5b7d2412a6a37847a (patch)
tree10ce3b912b307ff0aab5766c25781e0abda0ab10 /sys/kern/imgact_elf.c
parenta4fb38841fe96fae9a2afe75cc7c7c3d67b4488d (diff)
downloadFreeBSD-src-8e118d38cf6e48ba3629cca5b7d2412a6a37847a.zip
FreeBSD-src-8e118d38cf6e48ba3629cca5b7d2412a6a37847a.tar.gz
Control the execution permission of the readable segments for
i386 binaries on the amd64 and ia64 with the sysctl, instead of unconditionally enabling it. Reviewed by: marcel
Diffstat (limited to 'sys/kern/imgact_elf.c')
-rw-r--r--sys/kern/imgact_elf.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 669c652..8455f48 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -123,6 +123,14 @@ SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
nxstack, CTLFLAG_RW, &__elfN(nxstack), 0,
__XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": enable non-executable stack");
+#if __ELF_WORD_SIZE == 32
+#if defined(__amd64__) || defined(__ia64__)
+int i386_read_exec = 0;
+SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_RW, &i386_read_exec, 0,
+ "enable execution from readable segments");
+#endif
+#endif
+
static Elf_Brandinfo *elf_brand_list[MAX_BRANDS];
#define trunc_page_ps(va, ps) ((va) & ~(ps - 1))
@@ -1666,7 +1674,7 @@ __elfN(trans_prot)(Elf_Word flags)
prot |= VM_PROT_READ;
#if __ELF_WORD_SIZE == 32
#if defined(__amd64__) || defined(__ia64__)
- if (flags & PF_R)
+ if (i386_read_exec && (flags & PF_R))
prot |= VM_PROT_EXECUTE;
#endif
#endif
OpenPOWER on IntegriCloud