Source-Changes-HG archive

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

[src/trunk]: src/sys/kern do_setresuid: add an assert.



details:   https://anonhg.NetBSD.org/src/rev/485fd8c4f2e3
branches:  trunk
changeset: 791607:485fd8c4f2e3
user:      rmind <rmind%NetBSD.org@localhost>
date:      Mon Nov 25 16:28:20 2013 +0000

description:
do_setresuid: add an assert.

diffstat:

 sys/kern/kern_prot.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (37 lines):

diff -r 77370764a433 -r 485fd8c4f2e3 sys/kern/kern_prot.c
--- a/sys/kern/kern_prot.c      Mon Nov 25 07:59:03 2013 +0000
+++ b/sys/kern/kern_prot.c      Mon Nov 25 16:28:20 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_prot.c,v 1.116 2012/06/09 02:55:32 christos Exp $ */
+/*     $NetBSD: kern_prot.c,v 1.117 2013/11/25 16:28:20 rmind Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.116 2012/06/09 02:55:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_prot.c,v 1.117 2013/11/25 16:28:20 rmind Exp $");
 
 #include "opt_compat_43.h"
 
@@ -343,12 +343,15 @@
        kauth_cred_clone(cred, ncred);
 
        if (r != -1 && r != kauth_cred_getuid(ncred)) {
-               /* Update count of processes for this user */
+               u_long nlwps;
+
+               /* Update count of processes for this user. */
                (void)chgproccnt(kauth_cred_getuid(ncred), -1);
                (void)chgproccnt(r, 1);
 
-               /* The first lwp of a process is not counted */
-               int nlwps = p->p_nlwps - 1;
+               /* The first LWP of a process is excluded. */
+               KASSERT(mutex_owned(p->p_lock));
+               nlwps = p->p_nlwps - 1;
                (void)chglwpcnt(kauth_cred_getuid(ncred), -nlwps);
                (void)chglwpcnt(r, nlwps);
 



Home | Main Index | Thread Index | Old Index