diff options
author | mini <mini@FreeBSD.org> | 2002-07-11 02:18:33 +0000 |
---|---|---|
committer | mini <mini@FreeBSD.org> | 2002-07-11 02:18:33 +0000 |
commit | b244d01c4d1f0d892a66a78485850cf28a6db242 (patch) | |
tree | 998c964f1dba7a37a9c8f3efc2c0d6275c26d219 /sys/kern | |
parent | 88b937fe29c8492a2cb68b853f5aef5cbdb23c1f (diff) | |
download | FreeBSD-src-b244d01c4d1f0d892a66a78485850cf28a6db242.zip FreeBSD-src-b244d01c4d1f0d892a66a78485850cf28a6db242.tar.gz |
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
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_fork.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_prot.c | 13 | ||||
-rw-r--r-- | sys/kern/subr_trap.c | 3 |
3 files changed, 19 insertions, 0 deletions
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); } |