summaryrefslogtreecommitdiff
path: root/sys/uvm
diff options
context:
space:
mode:
authorStefan Kempf <stefan@cvs.openbsd.org>2016-09-02 16:45:13 +0000
committerStefan Kempf <stefan@cvs.openbsd.org>2016-09-02 16:45:13 +0000
commit87ae46400df7e5c46e75a22fe964ee06a55a9908 (patch)
tree0f692e2a97a8ea846509bd66b7aa2ee5d0088d84 /sys/uvm
parentfcf9752bb7cfa0955234368e43600610c4308242 (diff)
Mask out lower bits of randomly selected address
Fixes uvm pivots bug that would create non-page aligned addresses. This fix is in code that's not yet enabled.
Diffstat (limited to 'sys/uvm')
-rw-r--r--sys/uvm/uvm_addr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/uvm/uvm_addr.c b/sys/uvm/uvm_addr.c
index 93469fbbcb8..cc920b12e9b 100644
--- a/sys/uvm/uvm_addr.c
+++ b/sys/uvm/uvm_addr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_addr.c,v 1.17 2016/07/30 16:37:54 kettenis Exp $ */
+/* $OpenBSD: uvm_addr.c,v 1.18 2016/09/02 16:45:12 stefan Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -1170,10 +1170,10 @@ uaddr_pivot_newpivot(struct vm_map *map, struct uaddr_pivot_state *uaddr,
arc4_arg = found_maxaddr - found_minaddr;
if (arc4_arg > 0xffffffff) {
*addr_out = found_minaddr +
- (arc4random() & (align - 1));
+ (arc4random() & ~(align - 1));
} else {
*addr_out = found_minaddr +
- (arc4random_uniform(arc4_arg) & (align - 1));
+ (arc4random_uniform(arc4_arg) & ~(align - 1));
}
}
/* Address was found in this entry. */