diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-07-22 17:05:04 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-07-22 17:05:04 +0000 |
commit | d37648bc1fa202ca6ba0cfb549bdd91c0e4d916c (patch) | |
tree | 3146046dd3d76d114a26fe68bd3f5d2b11ed01c7 /sys/kern/kern_prot.c | |
parent | 01be595ab33612b855914baf3ef7b67166cbe2ed (diff) | |
download | FreeBSD-src-d37648bc1fa202ca6ba0cfb549bdd91c0e4d916c.zip FreeBSD-src-d37648bc1fa202ca6ba0cfb549bdd91c0e4d916c.tar.gz |
suser() accepts a thread argument; as suser() dereferences td_ucred, a
thread-local pointer, in practice that thread needs to be curthread. If
we're running with INVARIANTS, generate a warning if not. If we have
KDB compiled in, generate a stack trace. This doesn't fire at all in my
local test environment, but could be irritating if it fires frequently
for someone, so there will be motivation to fix things quickly when it
does.
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r-- | sys/kern/kern_prot.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index e352496..5132d2e 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/acct.h> +#include <sys/kdb.h> #include <sys/kernel.h> #include <sys/lock.h> #include <sys/mac.h> @@ -1245,6 +1246,17 @@ int suser(struct thread *td) { +#ifdef INVARIANTS + if (td != curthread) { + printf("suser: thread %p (%d %s) != curthread %p (%d %s)\n", + td, td->td_proc->p_pid, td->td_proc->p_comm, + curthread, curthread->td_proc->p_pid, + curthread->td_proc->p_comm); +#ifdef KDB + kdb_backtrace(); +#endif + } +#endif return (suser_cred(td->td_ucred, 0)); } |