Revert removal of cred_free_thread(): It is used to ensure that a thread's

credentials are not improperly borrowed when the thread is not current in
the kernel.

Requested by:	jhb, alfred
This commit is contained in:
Jonathan Mini 2002-07-11 02:18:33 +00:00
parent 74496412c4
commit aaa1c7715b
3 changed files with 19 additions and 0 deletions

View file

@ -875,6 +875,9 @@ fork_exit(callout, arg, frame)
kthread_exit(0);
}
PROC_UNLOCK(p);
#ifdef DIAGNOSTIC
cred_free_thread(td);
#endif
mtx_assert(&Giant, MA_NOTOWNED);
}

View file

@ -1765,6 +1765,19 @@ crdup(struct ucred *cr)
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.
*/

View file

@ -236,5 +236,8 @@ ast(struct trapframe *framep)
}
userret(td, framep, sticks);
#ifdef DIAGNOSTIC
cred_free_thread(td);
#endif
mtx_assert(&Giant, MA_NOTOWNED);
}