diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -2792,10 +2792,6 @@ MPASS(oldcred != NULL); PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(newcred->cr_users == 0, ("%s: users %d not 0 on cred %p", - __func__, newcred->cr_users, newcred)); - KASSERT(newcred->cr_ref == 1, ("%s: ref %ld not 1 on cred %p", - __func__, newcred->cr_ref, newcred)); if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) { /* @@ -2821,8 +2817,10 @@ __func__, oldcred->cr_users, oldcred)); oldcred->cr_users--; mtx_unlock(&oldcred->cr_mtx); + mtx_lock(&newcred->cr_mtx); + newcred->cr_users++; + mtx_unlock(&newcred->cr_mtx); p->p_ucred = newcred; - newcred->cr_users = 1; PROC_UPDATE_COW(p); if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) (void)chgproccnt(oldcred->cr_ruidinfo, -1, 0);