diff options
author | Ariane van der Steldt <ariane@cvs.openbsd.org> | 2012-01-05 17:49:46 +0000 |
---|---|---|
committer | Ariane van der Steldt <ariane@cvs.openbsd.org> | 2012-01-05 17:49:46 +0000 |
commit | 022407caf27caa2ba39950fd5ded1b672f022a1e (patch) | |
tree | 7078aeecd6bf65f1be2eaecc1bde9f41dd5a1b0f /sys | |
parent | 0d5977d542f5ba0e3ad3675b14092f4400ffba90 (diff) |
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')
-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); |