From b244d01c4d1f0d892a66a78485850cf28a6db242 Mon Sep 17 00:00:00 2001 From: mini Date: Thu, 11 Jul 2002 02:18:33 +0000 Subject: 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 --- sys/kern/kern_fork.c | 3 +++ sys/kern/kern_prot.c | 13 +++++++++++++ sys/kern/subr_trap.c | 3 +++ 3 files changed, 19 insertions(+) diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index eac0267..d5fd231 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -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); } diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 3ddd286..8f85803 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -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. */ diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 85edeed..951283a 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -236,5 +236,8 @@ ast(struct trapframe *framep) } userret(td, framep, sticks); +#ifdef DIAGNOSTIC + cred_free_thread(td); +#endif mtx_assert(&Giant, MA_NOTOWNED); } -- cgit v1.1