svn commit: r303846 - in stable/10/sys: kern sys
Bryan Drewery
bdrewery at FreeBSD.org
Mon Aug 8 18:31:29 UTC 2016
Author: bdrewery
Date: Mon Aug 8 18:31:28 2016
New Revision: 303846
URL: https://svnweb.freebsd.org/changeset/base/303846
Log:
MFC r280331:
cred: add proc_set_cred_init helper
PR: D7431
Modified:
stable/10/sys/kern/init_main.c
stable/10/sys/kern/kern_fork.c
stable/10/sys/kern/kern_prot.c
stable/10/sys/sys/ucred.h
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/kern/init_main.c
==============================================================================
--- stable/10/sys/kern/init_main.c Mon Aug 8 18:30:50 2016 (r303845)
+++ stable/10/sys/kern/init_main.c Mon Aug 8 18:31:28 2016 (r303846)
@@ -520,7 +520,7 @@ proc0_init(void *dummy __unused)
newcred->cr_ruidinfo = uifind(0);
newcred->cr_prison = &prison0;
newcred->cr_loginclass = loginclass_find("default");
- proc_set_cred(p, newcred);
+ proc_set_cred_init(p, newcred);
#ifdef AUDIT
audit_cred_kproc0(newcred);
#endif
Modified: stable/10/sys/kern/kern_fork.c
==============================================================================
--- stable/10/sys/kern/kern_fork.c Mon Aug 8 18:30:50 2016 (r303845)
+++ stable/10/sys/kern/kern_fork.c Mon Aug 8 18:31:28 2016 (r303846)
@@ -910,7 +910,7 @@ fork1(struct thread *td, int flags, int
* XXX: This is ugly; when we copy resource usage, we need to bump
* per-cred resource counters.
*/
- proc_set_cred(newproc, crhold(td->td_ucred));
+ proc_set_cred_init(newproc, crhold(td->td_ucred));
/*
* Initialize resource accounting for the child process.
Modified: stable/10/sys/kern/kern_prot.c
==============================================================================
--- stable/10/sys/kern/kern_prot.c Mon Aug 8 18:30:50 2016 (r303845)
+++ stable/10/sys/kern/kern_prot.c Mon Aug 8 18:31:28 2016 (r303846)
@@ -1957,8 +1957,19 @@ cred_update_thread(struct thread *td)
}
/*
+ * Set initial process credentials.
+ * Callers are responsible for providing the reference for provided credentials.
+ */
+void
+proc_set_cred_init(struct proc *p, struct ucred *newcred)
+{
+
+ p->p_ucred = newcred;
+}
+
+/*
* Change process credentials.
- * Callers are responsible for providing the reference for current credentials
+ * Callers are responsible for providing the reference for passed credentials
* and for freeing old ones.
*
* Process has to be locked except when it does not have credentials (as it
@@ -1971,9 +1982,10 @@ proc_set_cred(struct proc *p, struct ucr
{
struct ucred *oldcred;
+ MPASS(p->p_ucred != NULL);
if (newcred == NULL)
MPASS(p->p_state == PRS_ZOMBIE);
- else if (p->p_ucred != NULL)
+ else
PROC_LOCK_ASSERT(p, MA_OWNED);
oldcred = p->p_ucred;
Modified: stable/10/sys/sys/ucred.h
==============================================================================
--- stable/10/sys/sys/ucred.h Mon Aug 8 18:30:50 2016 (r303845)
+++ stable/10/sys/sys/ucred.h Mon Aug 8 18:31:28 2016 (r303846)
@@ -106,6 +106,7 @@ struct ucred *crcopysafe(struct proc *p,
struct ucred *crdup(struct ucred *cr);
void crextend(struct ucred *cr, int n);
void cred_update_thread(struct thread *td);
+void proc_set_cred_init(struct proc *p, struct ucred *cr);
struct ucred *proc_set_cred(struct proc *p, struct ucred *cr);
void crfree(struct ucred *cr);
struct ucred *crget(void);
More information about the svn-src-all
mailing list