diff options
author | 2016-09-02 16:45:12 +0000 | |
---|---|---|
committer | 2016-09-02 16:45:12 +0000 | |
commit | ee1647d456c9adf89589036ae2fb6965eb766e39 (patch) | |
tree | cae7607808b3531c24413d5ea2afd1162ac80784 | |
parent | Make functions and variables static whenever possible. (diff) | |
download | wireguard-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.c | 6 |
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. */ |