Author: mjg Date: Mon May 25 12:41:44 2020 New Revision: 361448 URL: https://svnweb.freebsd.org/changeset/base/361448
Log: proc: refactor clearing credentials into proc_unset_cred Modified: head/sys/kern/kern_exit.c head/sys/kern/kern_prot.c head/sys/sys/ucred.h Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Mon May 25 12:37:45 2020 (r361447) +++ head/sys/kern/kern_exit.c Mon May 25 12:41:44 2020 (r361448) @@ -928,8 +928,7 @@ proc_reap(struct thread *td, struct proc *p, int *stat /* * Free credentials, arguments, and sigacts. */ - crfree(p->p_ucred); - proc_set_cred(p, NULL); + proc_unset_cred(p); pargs_drop(p->p_args); p->p_args = NULL; sigacts_free(p->p_sigacts); Modified: head/sys/kern/kern_prot.c ============================================================================== --- head/sys/kern/kern_prot.c Mon May 25 12:37:45 2020 (r361447) +++ head/sys/kern/kern_prot.c Mon May 25 12:41:44 2020 (r361448) @@ -2000,14 +2000,20 @@ proc_set_cred(struct proc *p, struct ucred *newcred) { MPASS(p->p_ucred != NULL); - if (newcred == NULL) - MPASS(p->p_state == PRS_ZOMBIE); - else - PROC_LOCK_ASSERT(p, MA_OWNED); - + PROC_LOCK_ASSERT(p, MA_OWNED); p->p_ucred = newcred; - if (newcred != NULL) - PROC_UPDATE_COW(p); + PROC_UPDATE_COW(p); +} + +void +proc_unset_cred(struct proc *p) +{ + struct ucred *cr; + + MPASS(p->p_state == PRS_ZOMBIE); + cr = p->p_ucred; + p->p_ucred = NULL; + crfree(cr); } struct ucred * Modified: head/sys/sys/ucred.h ============================================================================== --- head/sys/sys/ucred.h Mon May 25 12:37:45 2020 (r361447) +++ head/sys/sys/ucred.h Mon May 25 12:41:44 2020 (r361448) @@ -113,6 +113,7 @@ struct ucred *crdup(struct ucred *cr); void crextend(struct ucred *cr, int n); void proc_set_cred_init(struct proc *p, struct ucred *cr); void proc_set_cred(struct proc *p, struct ucred *cr); +void proc_unset_cred(struct proc *p); void crfree(struct ucred *cr); struct ucred *crget(void); struct ucred *crhold(struct ucred *cr); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"