Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern Account for lwps so that rump_sys_...



details:   https://anonhg.NetBSD.org/src/rev/c87c85e0f115
branches:  trunk
changeset: 335687:c87c85e0f115
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Jan 21 14:39:37 2015 +0000

description:
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

diffstat:

 sys/rump/librump/rumpkern/lwproc.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (44 lines):

diff -r 896ebf73f91b -r c87c85e0f115 sys/rump/librump/rumpkern/lwproc.c
--- a/sys/rump/librump/rumpkern/lwproc.c        Wed Jan 21 11:02:55 2015 +0000
+++ b/sys/rump/librump/rumpkern/lwproc.c        Wed Jan 21 14:39:37 2015 +0000
@@ -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 @@
        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 @@
 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;
 



Home | Main Index | Thread Index | Old Index