Non-existing p_vmspace. When is it possible?
pluknet
pluknet at gmail.com
Wed Mar 11 06:38:42 PDT 2009
Hi.
I perform in FOREACH_PROC_IN_SYSTEM(), where I conditionally
look at p_vmspace internals. I'd like to know the safe way to
reference p_vmspace fields without potential null-dereference.
I see an example in vm_pageout_oom(), where making access to
p->p_vmspace fields is done without additional checks.
Nevertheless I want to further catch on how it works.
Currently I additionally explicitly check on P_SYSTEM and PRS_NEW,
then p->p_vmspace against NULL.
So I'd wish to understand if a time-window between
1) placing a new process to proclist
and
2) attaching vmspace to this process
is possible at all, and then in what cases.
I see in fork1() that a new process' (named p2 here) state is set to
PRS_NEW just before LIST_INSERT_HEAD(&allproc, p2, p_list) and then
(after vmspace is already attached in vm_forkproc()) is set to PRS_NORMAL.
So an additional check on p_vmspace != NULL is not need.
Am I right?
Thanks.
--
wbr,
pluknet
More information about the freebsd-hackers
mailing list