diff options
Diffstat (limited to 'sys/kern/kern_prot.c')
| -rw-r--r-- | sys/kern/kern_prot.c | 23 | 
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index a4c5bcc52529..3c145851b683 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -696,7 +696,7 @@ kern_setcred(struct thread *const td, const u_int flags,  	gid_t *groups = NULL;  	gid_t smallgroups[CRED_SMALLGROUPS_NB];  	int error; -	bool cred_set; +	bool cred_set = false;  	/* Bail out on unrecognized flags. */  	if (flags & ~SETCREDF_MASK) @@ -839,17 +839,32 @@ kern_setcred(struct thread *const td, const u_int flags,  	if (cred_set) {  		setsugid(p);  		to_free_cred = old_cred; +#ifdef RACCT +		racct_proc_ucred_changed(p, old_cred, new_cred); +#endif +#ifdef RCTL +		crhold(new_cred); +#endif  		MPASS(error == 0);  	} else  		error = EAGAIN;  unlock_finish:  	PROC_UNLOCK(p); +  	/*  	 * Part 3: After releasing the process lock, we perform cleanups and  	 * finishing operations.  	 */ +#ifdef RCTL +	if (cred_set) { +		rctl_proc_ucred_changed(p, new_cred); +		/* Paired with the crhold() just above. */ +		crfree(new_cred); +	} +#endif +  #ifdef MAC  	if (mac_set_proc_data != NULL)  		mac_set_proc_finish(td, proc_label_set, mac_set_proc_data); @@ -982,6 +997,8 @@ sys_setuid(struct thread *td, struct setuid_args *uap)  	proc_set_cred(p, newcred);  #ifdef RACCT  	racct_proc_ucred_changed(p, oldcred, newcred); +#endif +#ifdef RCTL  	crhold(newcred);  #endif  	PROC_UNLOCK(p); @@ -1390,6 +1407,8 @@ sys_setreuid(struct thread *td, struct setreuid_args *uap)  	proc_set_cred(p, newcred);  #ifdef RACCT  	racct_proc_ucred_changed(p, oldcred, newcred); +#endif +#ifdef RCTL  	crhold(newcred);  #endif  	PROC_UNLOCK(p); @@ -1536,6 +1555,8 @@ sys_setresuid(struct thread *td, struct setresuid_args *uap)  	proc_set_cred(p, newcred);  #ifdef RACCT  	racct_proc_ucred_changed(p, oldcred, newcred); +#endif +#ifdef RCTL  	crhold(newcred);  #endif  	PROC_UNLOCK(p);  | 
