Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Mar 2009 16:38:39 +0300
From:      pluknet <pluknet@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Non-existing p_vmspace. When is it possible?
Message-ID:  <a31046fc0903110638x52d9b6cbt4d39656c0be61442@mail.gmail.com>
In-Reply-To: <a31046fc0903110606r7c398ef1ud2921e7c30658fe6@mail.gmail.com>
References:  <a31046fc0903110606r7c398ef1ud2921e7c30658fe6@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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
=A0and
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 !=3D NULL is not need.
Am I right?

Thanks.

--=20
wbr,
pluknet



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a31046fc0903110638x52d9b6cbt4d39656c0be61442>