summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2014-07-02 05:50:00 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2014-07-02 05:50:00 +0000
commit50322e4353efd442904b1d206427cfbcadcf6c62 (patch)
treec4e0bce064e89923436ad298bf07f409ab1de9bd /sys/kern
parent03bb4d8e2f6a7bb59fc57a5cbac442b6ea39889c (diff)
take the pools mutex when copying stats out of it in the sysctl
path so we are guaranteed a consistent snapshot.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_pool.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index 19e552bc422..a5b2ee4d093 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.130 2014/07/02 05:42:40 dlg Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.131 2014/07/02 05:49:59 dlg Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -1484,6 +1484,8 @@ sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep)
break;
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;
@@ -1499,6 +1501,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);
+
rv = copyout(&pi, where, buflen);
break;
}