freebsd-skq/sys/cddl
Mark Johnston 48fcd357c4 Avoid dereferencing curthread->td_proc->p_cred in DTrace probe context.
When a process is exiting, there is a narrow window where p_cred may be
NULL while its threads are still executing. Specifically, the last thread
to exit a process sets the process state to PRS_ZOMBIE with the proc
spinlock held and then calls thread_exit(). thread_exit() drops the spin
lock, permitting the process to be reaped and thus causing its cred struct
to be released. However, the exiting thread may still cause DTrace probes
to fire by calling sched_throw(), resulting in a double fault if such a
probe enabling attempts to access the GID or UID DIF variables.

The thread's cred reference is not susceptible to this race since it is not
released until after the thread has exited.

MFC after:	1 week
2015-08-02 00:11:56 +00:00
..
boot/zfs MFV r274273: 2014-11-10 08:20:21 +00:00
compat/opensolaris Add an API for easily creating userspace threads in kernelspace. 2015-07-20 10:20:04 +00:00
contrib/opensolaris Avoid dereferencing curthread->td_proc->p_cred in DTrace probe context. 2015-08-02 00:11:56 +00:00
dev Remove checks for a NULL return value from M_WAITOK allocations. 2015-07-21 23:44:36 +00:00