From 5ec534b84a8a5eb5bfca9ad4edeb04fac69fadf6 Mon Sep 17 00:00:00 2001 From: mpi Date: Fri, 19 Aug 2022 05:53:19 +0000 Subject: [PATCH] Grab the mutex before iterating on the global list. Prevent race reported some months ago. ok mlarkin@, jsg@, kn@ --- sys/uvm/uvm_pager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)); -- 2.20.1