summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstefan <stefan@openbsd.org>2016-09-02 16:45:12 +0000
committerstefan <stefan@openbsd.org>2016-09-02 16:45:12 +0000
commitee1647d456c9adf89589036ae2fb6965eb766e39 (patch)
treecae7607808b3531c24413d5ea2afd1162ac80784
parentMake functions and variables static whenever possible. (diff)
downloadwireguard-openbsd-ee1647d456c9adf89589036ae2fb6965eb766e39.tar.xz
wireguard-openbsd-ee1647d456c9adf89589036ae2fb6965eb766e39.zip
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.
-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. */