summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2023-08-12 07:22:57 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2023-08-12 07:22:57 +0000
commit08d1e65289e393b12c649de09037e310be33997f (patch)
tree9cba21bbf40761acb6cc0916e4a56b53269b260b
parentb2f7adbd8f3b732e19212ff7278b3598620e4889 (diff)
Add sanity checks in uvm_pagelookup().
ok kettenis@
-rw-r--r--sys/uvm/uvm_page.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c
index bab50a86fcc..774345acc2c 100644
--- a/sys/uvm/uvm_page.c
+++ b/sys/uvm/uvm_page.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_page.c,v 1.172 2023/05/13 09:24:59 mpi Exp $ */
+/* $OpenBSD: uvm_page.c,v 1.173 2023/08/12 07:22:56 mpi Exp $ */
/* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */
/*
@@ -1219,10 +1219,15 @@ struct vm_page *
uvm_pagelookup(struct uvm_object *obj, voff_t off)
{
/* XXX if stack is too much, handroll */
- struct vm_page pg;
+ struct vm_page p, *pg;
- pg.offset = off;
- return RBT_FIND(uvm_objtree, &obj->memt, &pg);
+ p.offset = off;
+ pg = RBT_FIND(uvm_objtree, &obj->memt, &p);
+
+ KASSERT(pg == NULL || obj->uo_npages != 0);
+ KASSERT(pg == NULL || (pg->pg_flags & PG_RELEASED) == 0 ||
+ (pg->pg_flags & PG_BUSY) != 0);
+ return (pg);
}
/*