From: mpi Date: Fri, 19 Aug 2022 05:53:19 +0000 (+0000) Subject: Grab the mutex before iterating on the global list. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5ec534b84a8a5eb5bfca9ad4edeb04fac69fadf6;p=openbsd Grab the mutex before iterating on the global list. Prevent race reported some months ago. ok mlarkin@, jsg@, kn@ --- diff --git a/sys/uvm/uvm_pager.c b/sys/uvm/uvm_pager.c index ed10740ef86..adb3632045c 100644 --- a/sys/uvm/uvm_pager.c +++ b/sys/uvm/uvm_pager.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pager.c,v 1.88 2022/08/15 03:21:04 jsg Exp $ */ +/* $OpenBSD: uvm_pager.c,v 1.89 2022/08/19 05:53:19 mpi Exp $ */ /* $NetBSD: uvm_pager.c,v 1.36 2000/11/27 18:26:41 chs Exp $ */ /* @@ -209,6 +209,7 @@ uvm_pseg_release(vaddr_t segaddr) struct uvm_pseg *pseg; vaddr_t va = 0; + mtx_enter(&uvm_pseg_lck); for (pseg = &psegs[0]; pseg != &psegs[PSEG_NUMSEGS]; pseg++) { if (pseg->start <= segaddr && segaddr < pseg->start + MAX_PAGER_SEGS * MAXBSIZE) @@ -222,7 +223,6 @@ uvm_pseg_release(vaddr_t segaddr) /* test for no remainder */ KDASSERT(segaddr == pseg->start + id * MAXBSIZE); - mtx_enter(&uvm_pseg_lck); KASSERT(UVM_PSEG_INUSE(pseg, id));