From 7ca6a9a248f60891bc51b5d702eae10f3ebd398c Mon Sep 17 00:00:00 2001 From: dlg Date: Mon, 11 Aug 2014 12:37:36 +0000 Subject: [PATCH] bring back r1.131: take the pools mutex when copying stats out of it in the sysctl path so we are guaranteed a consistent snapshot. --- sys/kern/subr_pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index 438f065a267..97971900843 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.138 2014/07/10 13:34:39 tedu Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.139 2014/08/11 12:37:36 dlg Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -1473,6 +1473,8 @@ sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep) return copyout(pp->pr_wchan, where, len); case KERN_POOL_POOL: memset(&pi, 0, sizeof(pi)); + + mtx_enter(&pp->pr_mtx); pi.pr_size = pp->pr_size; pi.pr_pgsize = pp->pr_alloc->pa_pagesz; pi.pr_itemsperpage = pp->pr_itemsperpage; @@ -1488,6 +1490,8 @@ sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep) pi.pr_npagefree = pp->pr_npagefree; pi.pr_hiwat = pp->pr_hiwat; pi.pr_nidle = pp->pr_nidle; + mtx_leave(&pp->pr_mtx); + return copyout(&pi, where, buflen); } /* NOTREACHED */ -- 2.20.1