From owner-svn-src-stable@freebsd.org Fri Jun 22 09:18:40 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3D95010140B5; Fri, 22 Jun 2018 09:18:40 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D01B086382; Fri, 22 Jun 2018 09:18:39 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 924081EB61; Fri, 22 Jun 2018 09:18:39 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5M9IdX3028062; Fri, 22 Jun 2018 09:18:39 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5M9Iclp028057; Fri, 22 Jun 2018 09:18:38 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201806220918.w5M9Iclp028057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 22 Jun 2018 09:18:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r335536 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 335536 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jun 2018 09:18:40 -0000 Author: avg Date: Fri Jun 22 09:18:38 2018 New Revision: 335536 URL: https://svnweb.freebsd.org/changeset/base/335536 Log: MFC r332816: call racct_proc_ucred_changed() under the proc lock Modified: stable/11/sys/kern/kern_jail.c stable/11/sys/kern/kern_loginclass.c stable/11/sys/kern/kern_prot.c stable/11/sys/kern/kern_racct.c stable/11/sys/kern/kern_rctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_jail.c ============================================================================== --- stable/11/sys/kern/kern_jail.c Fri Jun 22 09:10:50 2018 (r335535) +++ stable/11/sys/kern/kern_jail.c Fri Jun 22 09:18:38 2018 (r335536) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2409,10 +2410,15 @@ do_jail_attach(struct thread *td, struct prison *pr) newcred->cr_prison = pr; proc_set_cred(p, newcred); setsugid(p); - PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); + crhold(newcred); #endif + PROC_UNLOCK(p); +#ifdef RCTL + rctl_proc_ucred_changed(p, newcred); + crfree(newcred); +#endif prison_deref(oldcred->cr_prison, PD_DEREF | PD_DEUREF); crfree(oldcred); return (0); @@ -3959,6 +3965,7 @@ prison_racct_modify(struct prison *pr) */ racct_move(pr->pr_prison_racct->prr_racct, oldprr->prr_racct); +#ifdef RCTL /* * Force rctl to reattach rules to processes. */ @@ -3966,9 +3973,10 @@ prison_racct_modify(struct prison *pr) PROC_LOCK(p); cred = crhold(p->p_ucred); PROC_UNLOCK(p); - racct_proc_ucred_changed(p, cred, cred); + rctl_proc_ucred_changed(p, cred); crfree(cred); } +#endif sx_sunlock(&allproc_lock); prison_racct_free_locked(oldprr); Modified: stable/11/sys/kern/kern_loginclass.c ============================================================================== --- stable/11/sys/kern/kern_loginclass.c Fri Jun 22 09:10:50 2018 (r335535) +++ stable/11/sys/kern/kern_loginclass.c Fri Jun 22 09:18:38 2018 (r335536) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -222,9 +223,14 @@ sys_setloginclass(struct thread *td, struct setlogincl oldcred = crcopysafe(p, newcred); newcred->cr_loginclass = newlc; proc_set_cred(p, newcred); - PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); + crhold(newcred); +#endif + PROC_UNLOCK(p); +#ifdef RCTL + rctl_proc_ucred_changed(p, newcred); + crfree(newcred); #endif loginclass_free(oldcred->cr_loginclass); crfree(oldcred); Modified: stable/11/sys/kern/kern_prot.c ============================================================================== --- stable/11/sys/kern/kern_prot.c Fri Jun 22 09:10:50 2018 (r335535) +++ stable/11/sys/kern/kern_prot.c Fri Jun 22 09:18:38 2018 (r335536) @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -579,10 +580,15 @@ sys_setuid(struct thread *td, struct setuid_args *uap) setsugid(p); } proc_set_cred(p, newcred); - PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); + crhold(newcred); #endif + PROC_UNLOCK(p); +#ifdef RCTL + rctl_proc_ucred_changed(p, newcred); + crfree(newcred); +#endif uifree(uip); crfree(oldcred); return (0); @@ -927,10 +933,15 @@ sys_setreuid(struct thread *td, struct setreuid_args * setsugid(p); } proc_set_cred(p, newcred); - PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); + crhold(newcred); #endif + PROC_UNLOCK(p); +#ifdef RCTL + rctl_proc_ucred_changed(p, newcred); + crfree(newcred); +#endif uifree(ruip); uifree(euip); crfree(oldcred); @@ -1068,9 +1079,14 @@ sys_setresuid(struct thread *td, struct setresuid_args setsugid(p); } proc_set_cred(p, newcred); - PROC_UNLOCK(p); #ifdef RACCT racct_proc_ucred_changed(p, oldcred, newcred); + crhold(newcred); +#endif + PROC_UNLOCK(p); +#ifdef RCTL + rctl_proc_ucred_changed(p, newcred); + crfree(newcred); #endif uifree(ruip); uifree(euip); Modified: stable/11/sys/kern/kern_racct.c ============================================================================== --- stable/11/sys/kern/kern_racct.c Fri Jun 22 09:10:50 2018 (r335535) +++ stable/11/sys/kern/kern_racct.c Fri Jun 22 09:18:38 2018 (r335536) @@ -1048,7 +1048,7 @@ racct_proc_ucred_changed(struct proc *p, struct ucred if (!racct_enable) return; - PROC_LOCK_ASSERT(p, MA_NOTOWNED); + PROC_LOCK_ASSERT(p, MA_OWNED); newuip = newcred->cr_ruidinfo; olduip = oldcred->cr_ruidinfo; @@ -1075,10 +1075,6 @@ racct_proc_ucred_changed(struct proc *p, struct ucred p->p_racct); } RACCT_UNLOCK(); - -#ifdef RCTL - rctl_proc_ucred_changed(p, newcred); -#endif } void Modified: stable/11/sys/kern/kern_rctl.c ============================================================================== --- stable/11/sys/kern/kern_rctl.c Fri Jun 22 09:10:50 2018 (r335535) +++ stable/11/sys/kern/kern_rctl.c Fri Jun 22 09:18:38 2018 (r335536) @@ -1954,12 +1954,15 @@ rctl_proc_ucred_changed(struct proc *p, struct ucred * struct prison_racct *newprr; int rulecnt, i; - ASSERT_RACCT_ENABLED(); + if (!racct_enable) + return; + PROC_LOCK_ASSERT(p, MA_NOTOWNED); + newuip = newcred->cr_ruidinfo; newlc = newcred->cr_loginclass; newprr = newcred->cr_prison->pr_prison_racct; - + LIST_INIT(&newrules); again: