diff options
author | 2012-01-05 17:49:45 +0000 | |
---|---|---|
committer | 2012-01-05 17:49:45 +0000 | |
commit | c6b412777645829fefce0ba2fc437bd62b31ce56 (patch) | |
tree | 67841bbf57b20285b404508da095cbc46e560fad /sys/uvm/uvm_pmemrange.c | |
parent | -execdir only supports the first form of -exec with ; suffix, not the new (diff) | |
download | wireguard-openbsd-c6b412777645829fefce0ba2fc437bd62b31ce56.tar.xz wireguard-openbsd-c6b412777645829fefce0ba2fc437bd62b31ce56.zip |
Prevent integer wrap-around in pmemrange.
Found by and original fix from Geoff Steckel.
While here, switch the assert that prevents this from happening from DEBUG to DIAGNOSTIC.
ok thib@, miod@
Diffstat (limited to 'sys/uvm/uvm_pmemrange.c')
-rw-r--r-- | sys/uvm/uvm_pmemrange.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c index 82fdb4fc8a2..bf5ec5c78c7 100644 --- a/sys/uvm/uvm_pmemrange.c +++ b/sys/uvm/uvm_pmemrange.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pmemrange.c,v 1.33 2011/12/03 20:07:06 miod Exp $ */ +/* $OpenBSD: uvm_pmemrange.c,v 1.34 2012/01/05 17:49:45 ariane Exp $ */ /* * Copyright (c) 2009, 2010 Ariane van der Steldt <ariane@stack.nl> @@ -673,7 +673,7 @@ uvm_pmr_extract_range(struct uvm_pmemrange *pmr, struct vm_page *pg, /* Add selected pages to result. */ for (pg_i = pg + before_sz; pg_i != after; pg_i++) { - KDASSERT(pg_i->pg_flags & PQ_FREE); + KASSERT(pg_i->pg_flags & PQ_FREE); pg_i->fpgsz = 0; TAILQ_INSERT_TAIL(result, pg_i, pageq); } @@ -910,14 +910,14 @@ drain_found: fstart = PMR_ALIGN(fstart, align); fend = atop(VM_PAGE_TO_PHYS(found)) + found->fpgsz; - if (fstart >= fend) - continue; + if (end != 0) + fend = MIN(end, fend); if (boundary != 0) { fend = MIN(fend, PMR_ALIGN(fstart + 1, boundary)); } - if (end != 0) - fend = MIN(end, fend); + if (fstart >= fend) + continue; if (fend - fstart > count - fcount) fend = fstart + (count - fcount); |