Module Name: src Committed By: christos Date: Mon Nov 25 16:29:25 UTC 2013
Modified Files: src/sys/kern: kern_lwp.c Log Message: Use the process credentials instead of the lwp credentials because if the process just did a setuid() call, the lwp might not have had a chance to refresh l->l_cred (still has LPR_CRMOD), and we don't want to bother spending time syncing the creds of a dying lwp. Should fix the problem with hald people have been observing. To generate a diff of this commit: cvs rdiff -u -r1.176 -r1.177 src/sys/kern/kern_lwp.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/kern/kern_lwp.c diff -u src/sys/kern/kern_lwp.c:1.176 src/sys/kern/kern_lwp.c:1.177 --- src/sys/kern/kern_lwp.c:1.176 Fri Nov 22 16:04:11 2013 +++ src/sys/kern/kern_lwp.c Mon Nov 25 11:29:25 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lwp.c,v 1.176 2013/11/22 21:04:11 christos Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.177 2013/11/25 16:29:25 christos Exp $ */ /*- * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -211,7 +211,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.176 2013/11/22 21:04:11 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.177 2013/11/25 16:29:25 christos Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -1174,8 +1174,14 @@ lwp_free(struct lwp *l, bool recycle, bo KASSERT(l != curlwp); KASSERT(last || mutex_owned(p->p_lock)); + /* + * We use the process credentials instead of the lwp credentials here + * because the lwp credentials maybe cached (just after a setuid call) + * and we don't want pay for syncing, since the lwp is going away + * anyway + */ if (p != &proc0 && p->p_nlwps != 1) - (void)chglwpcnt(kauth_cred_getuid(l->l_cred), -1); + (void)chglwpcnt(kauth_cred_getuid(p->p_cred), -1); /* * If this was not the last LWP in the process, then adjust * counters and unlock.