Module Name: src
Committed By: pooka
Date: Wed Jan 21 14:39:37 UTC 2015
Modified Files:
src/sys/rump/librump/rumpkern: lwproc.c
Log Message:
Account for lwps so that rump_sys_setuid() doesn't hit a KASSERT when
it tries to reaccount a switching procs lwps.
from Mato Lucina
To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/rump/librump/rumpkern/lwproc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/librump/rumpkern/lwproc.c
diff -u src/sys/rump/librump/rumpkern/lwproc.c:1.31 src/sys/rump/librump/rumpkern/lwproc.c:1.32
--- src/sys/rump/librump/rumpkern/lwproc.c:1.31 Fri Apr 25 13:20:45 2014
+++ src/sys/rump/librump/rumpkern/lwproc.c Wed Jan 21 14:39:37 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: lwproc.c,v 1.31 2014/04/25 13:20:45 pooka Exp $ */
+/* $NetBSD: lwproc.c,v 1.32 2015/01/21 14:39:37 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#define RUMP__CURLWP_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.31 2014/04/25 13:20:45 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.32 2015/01/21 14:39:37 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -246,6 +246,8 @@ lwproc_freelwp(struct lwp *l)
if (--p->p_nlwps == 0) {
KASSERT(p != &proc0);
p->p_stat = SDEAD;
+ } else {
+ chglwpcnt(kauth_cred_getuid(p->p_cred), -1);
}
cv_broadcast(&p->p_lwpcv); /* nobody sleeps on this in a rump kernel? */
kauth_cred_free(l->l_cred);
@@ -276,7 +278,15 @@ static void
lwproc_makelwp(struct proc *p, struct lwp *l, bool doswitch, bool procmake)
{
- p->p_nlwps++;
+ /*
+ * Account the new lwp to the owner of the process.
+ * For some reason, NetBSD doesn't count the first lwp
+ * in a process as a lwp, so skip that.
+ */
+ if (p->p_nlwps++) {
+ chglwpcnt(kauth_cred_getuid(p->p_cred), 1);
+ }
+
l->l_refcnt = 1;
l->l_proc = p;