summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2016-05-17 00:38:50 +0000
committerchristos <christos@NetBSD.org>2016-05-17 00:38:50 +0000
commit5fbdd2fd11a1a7bbcd2ef9fd5b84adb65dd87de0 (patch)
treeb2c3d2de68c9e97c9a9ae09a76b17ebc1f3b2f4c /sys
parentbe705d01a013350b7e0464a1fc8a03df91f45a76 (diff)
Hook to clamp the random value for mmap for machies that don't have enough
VA bits.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_pax.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/kern_pax.c b/sys/kern/kern_pax.c
index ff843e66d08..97ac8b795de 100644
--- a/sys/kern/kern_pax.c
+++ b/sys/kern/kern_pax.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_pax.c,v 1.45 2016/05/14 17:04:09 christos Exp $ */
+/* $NetBSD: kern_pax.c,v 1.46 2016/05/17 00:38:50 christos Exp $ */
/*
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_pax.c,v 1.45 2016/05/14 17:04:09 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_pax.c,v 1.46 2016/05/17 00:38:50 christos Exp $");
#include "opt_pax.h"
@@ -482,6 +482,9 @@ pax_aslr_init_vm(struct lwp *l, struct vmspace *vm, struct exec_package *ep)
if (pax_aslr_flags & PAX_ASLR_FIXED)
rand = pax_aslr_rand;
#endif
+#ifdef PAX_ASLR_RAND_MMAP_MAX
+ rand &= PAX_ASLR_RAND_MMAP_MAX - 1;
+#endif
vm->vm_aslr_delta_mmap = PAX_ASLR_DELTA(rand,
PAX_ASLR_DELTA_MMAP_LSB, len);