- Push down Giant into crfree() in the case that we actually free a ucred.

- Add a cred_free_thread() function (conditional on DIAGNOSTICS) that drops
  a per-thread ucred reference to be used in debugging code when leaving
  the kernel.
This commit is contained in:
John Baldwin 2002-03-20 21:00:50 +00:00
parent 565f27f116
commit c1a513c951
2 changed files with 18 additions and 1 deletions

View File

@ -1699,6 +1699,7 @@ crfree(cr)
* allocate a uidinfo structure. * allocate a uidinfo structure.
*/ */
mtx_unlock(mtxp); mtx_unlock(mtxp);
mtx_lock(&Giant);
if (cr->cr_uidinfo != NULL) if (cr->cr_uidinfo != NULL)
uifree(cr->cr_uidinfo); uifree(cr->cr_uidinfo);
if (cr->cr_ruidinfo != NULL) if (cr->cr_ruidinfo != NULL)
@ -1709,6 +1710,7 @@ crfree(cr)
if (jailed(cr)) if (jailed(cr))
prison_free(cr->cr_prison); prison_free(cr->cr_prison);
FREE((caddr_t)cr, M_CRED); FREE((caddr_t)cr, M_CRED);
mtx_unlock(&Giant);
} else { } else {
mtx_unlock(mtxp); mtx_unlock(mtxp);
} }
@ -1761,6 +1763,19 @@ crdup(cr)
return (newcr); return (newcr);
} }
#ifdef DIAGNOSTIC
void
cred_free_thread(struct thread *td)
{
struct ucred *cred;
cred = td->td_ucred;
td->td_ucred = NULL;
if (cred != NULL)
crfree(cred);
}
#endif
/* /*
* Fill in a struct xucred based on a struct ucred. * Fill in a struct xucred based on a struct ucred.
*/ */

View File

@ -83,7 +83,9 @@ struct xucred {
#ifdef _KERNEL #ifdef _KERNEL
#ifdef DIAGNOSTIC
void cred_free_thread(struct thread *td);
#endif
void cred_update_thread(struct thread *td); void cred_update_thread(struct thread *td);
void change_egid(struct ucred *newcred, gid_t egid); void change_egid(struct ucred *newcred, gid_t egid);
void change_euid(struct ucred *newcred, uid_t euid); void change_euid(struct ucred *newcred, uid_t euid);