<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/pid.c, branch v2.6.19</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.19</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.19'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2006-10-02T14:57:25Z</updated>
<entry>
<title>[PATCH] introduce get_task_pid() to fix unsafe get_pid()</title>
<updated>2006-10-02T14:57:25Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@tv-sign.ru</email>
</author>
<published>2006-10-02T09:18:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1a657f78dcc8ea7c53eaa1f2a45ea2315738c15f'/>
<id>urn:sha1:1a657f78dcc8ea7c53eaa1f2a45ea2315738c15f</id>
<content type='text'>
proc_pid_make_inode:

	ei-&gt;pid = get_pid(task_pid(task));

I think this is not safe.  get_pid() can be preempted after checking "pid
!= NULL".  Then the task exits, does detach_pid(), and RCU frees the pid.

Signed-off-by: Oleg Nesterov &lt;oleg@tv-sign.ru&gt;
Cc: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] Use struct pspace in next_pidmap and find_ge_pid</title>
<updated>2006-10-02T14:57:15Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2006-10-02T09:17:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f40f50d3bb33b52dfd550ca80be7daaddad21883'/>
<id>urn:sha1:f40f50d3bb33b52dfd550ca80be7daaddad21883</id>
<content type='text'>
This updates my proc: readdir race fix (take 3) patch
to account for the changes made by: Sukadev Bhattiprolu &lt;sukadev@us.ibm.com&gt;
to introduce struct pspace.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] Define struct pspace</title>
<updated>2006-10-02T14:57:15Z</updated>
<author>
<name>Sukadev Bhattiprolu</name>
<email>sukadev@us.ibm.com</email>
</author>
<published>2006-10-02T09:17:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3fbc96486459324e182717b03c50c90c880be6ec'/>
<id>urn:sha1:3fbc96486459324e182717b03c50c90c880be6ec</id>
<content type='text'>
Define a per-container pid space object.  And create one instance of this
object, init_pspace, to define the entire pid space.  Subsequent patches
will provide/use interfaces to create/destroy pid spaces.

Its a subset/rework of Eric Biederman's patch
http://lkml.org/lkml/2006/2/6/285 .

Signed-off-by: Eric Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Sukadev Bhattiprolu &lt;sukadev@us.ibm.com&gt;
Cc: Dave Hansen &lt;haveblue@us.ibm.com&gt;
Cc: Serge Hallyn &lt;serue@us.ibm.com&gt;
Cc: Cedric Le Goater &lt;clg@fr.ibm.com&gt;
Cc: Kirill Korotaev &lt;dev@sw.ru&gt;
Cc: Andrey Savochkin &lt;saw@sw.ru&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] Move pidmap to pspace.h</title>
<updated>2006-10-02T14:57:15Z</updated>
<author>
<name>Sukadev Bhattiprolu</name>
<email>sukadev@us.ibm.com</email>
</author>
<published>2006-10-02T09:17:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=aa5a6662f93f52605b6c447ba6f7291e92f515c5'/>
<id>urn:sha1:aa5a6662f93f52605b6c447ba6f7291e92f515c5</id>
<content type='text'>
Move struct pidmap and PIDMAP_ENTRIES to a new file, include/linux/pspace.h
where it will be used in subsequent patches to define pid spaces.

Its a subset of Eric Biederman's patch http://lkml.org/lkml/2006/2/6/285

[akpm@osdl.org: cleanups]
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Sukadev Bhattiprolu &lt;sukadev@us.ibm.com&gt;
Cc: Dave Hansen &lt;haveblue@us.ibm.com&gt;
Cc: Serge Hallyn &lt;serue@us.ibm.com&gt;
Cc: Cedric Le Goater &lt;clg@fr.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] pids coding style use struct pidmap in next_pidmap</title>
<updated>2006-10-02T14:57:15Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2006-10-02T09:17:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c88be3eb2e01bbb21c9ccdc3805f0d3546c1898c'/>
<id>urn:sha1:c88be3eb2e01bbb21c9ccdc3805f0d3546c1898c</id>
<content type='text'>
Use struct pidmap instead of pidmap_t.

This updates my proc: readdir race fix (take 3) patch
to account for the changes made by: Sukadev Bhattiprolu &lt;sukadev@us.ibm.com&gt;
to kill pidmap_t.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] pids: coding style: use struct pidmap</title>
<updated>2006-10-02T14:57:14Z</updated>
<author>
<name>Sukadev Bhattiprolu</name>
<email>sukadev@us.ibm.com</email>
</author>
<published>2006-10-02T09:17:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6a1f3b84557774a46af68747c92d8f36382027ae'/>
<id>urn:sha1:6a1f3b84557774a46af68747c92d8f36382027ae</id>
<content type='text'>
Use struct pidmap instead of pidmap_t.

Its a subset of Eric Biederman's patch http://lkml.org/lkml/2006/2/6/271.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Sukadev Bhattiprolu &lt;sukadev@us.ibm.com&gt;
Cc: Dave Hansen &lt;haveblue@us.ibm.com&gt;
Cc: Serge Hallyn &lt;serue@us.ibm.com&gt;
Cc: Cedric Le Goater &lt;clg@fr.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] pid: export the symbols needed to use struct pid *</title>
<updated>2006-10-02T14:57:13Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2006-10-02T09:17:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bbf73147e2d46611fbdcbc126f887c614c32350b'/>
<id>urn:sha1:bbf73147e2d46611fbdcbc126f887c614c32350b</id>
<content type='text'>
pids aren't something that drivers should care about.  However there are a lot
of helper layers in the kernel that do care, and are built as modules.  Before
I can convert them to using struct pid instead of pid_t I need to export the
appropriate symbols so they can continue to be built.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] proc: readdir race fix (take 3)</title>
<updated>2006-10-02T14:57:12Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2006-10-02T09:17:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0804ef4b0de7121261f77c565b20a11ac694e877'/>
<id>urn:sha1:0804ef4b0de7121261f77c565b20a11ac694e877</id>
<content type='text'>
The problem: An opendir, readdir, closedir sequence can fail to report
process ids that are continually in use throughout the sequence of system
calls.  For this race to trigger the process that proc_pid_readdir stops at
must exit before readdir is called again.

This can cause ps to fail to report processes, and it is in violation of
posix guarantees and normal application expectations with respect to
readdir.

Currently there is no way to work around this problem in user space short
of providing a gargantuan buffer to user space so the directory read all
happens in on system call.

This patch implements the normal directory semantics for proc, that
guarantee that a directory entry that is neither created nor destroyed
while reading the directory entry will be returned.  For directory that are
either created or destroyed during the readdir you may or may not see them.
 Furthermore you may seek to a directory offset you have previously seen.

These are the guarantee that ext[23] provides and that posix requires, and
more importantly that user space expects.  Plus it is a simple semantic to
implement reliable service.  It is just a matter of calling readdir a
second time if you are wondering if something new has show up.

These better semantics are implemented by scanning through the pids in
numerical order and by making the file offset a pid plus a fixed offset.

The pid scan happens on the pid bitmap, which when you look at it is
remarkably efficient for a brute force algorithm.  Given that a typical
cache line is 64 bytes and thus covers space for 64*8 == 200 pids.  There
are only 40 cache lines for the entire 32K pid space.  A typical system
will have 100 pids or more so this is actually fewer cache lines we have to
look at to scan a linked list, and the worst case of having to scan the
entire pid bitmap is pretty reasonable.

If we need something more efficient we can go to a more efficient data
structure for indexing the pids, but for now what we have should be
sufficient.

In addition this takes no additional locks and is actually less code than
what we are doing now.

Also another very subtle bug in this area has been fixed.  It is possible
to catch a task in the middle of de_thread where a thread is assuming the
thread of it's thread group leader.  This patch carefully handles that case
so if we hit it we don't fail to return the pid, that is undergoing the
de_thread dance.

Thanks to KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt; for
providing the first fix, pointing this out and working on it.

[oleg@tv-sign.ru: fix it]
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Acked-by: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Signed-off-by: Oleg Nesterov &lt;oleg@tv-sign.ru&gt;
Cc: Jean Delvare &lt;jdelvare@suse.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] pid: remove temporary debug code in attach_pid</title>
<updated>2006-09-27T15:26:19Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2006-09-27T08:51:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=65800ac77e080cf159d6c1207b6886e18f22bc08'/>
<id>urn:sha1:65800ac77e080cf159d6c1207b6886e18f22bc08</id>
<content type='text'>
With the patches flying between Oleg and myself somehow this temporary
debug code got left in pid.c.  It was never intended to make it to the
stable kernel.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Oleg Nesterov &lt;oleg@tv-sign.ru&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] pid: Implement transfer_pid and use it to simplify de_thread</title>
<updated>2006-09-27T15:26:19Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2006-09-27T08:51:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c18258c6f0848f97e85287f6271c511a092bb784'/>
<id>urn:sha1:c18258c6f0848f97e85287f6271c511a092bb784</id>
<content type='text'>
In de_thread we move pids from one process to another, a rather ugly case.
The function transfer_pid makes it clear what we are doing, and makes the
action atomic.  This is useful we ever want to atomically traverse the
process group and session lists, in a rcu safe manner.

Even if the atomic properties this change should be a win as transfer_pid
should be less code to execute than executing both attach_pid and
detach_pid, and this should make de_thread slightly smaller as only a
single function call needs to be emitted.  The only downside is that the
code might be slower to execute as the odds are against transfer_pid being
in cache.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Oleg Nesterov &lt;oleg@tv-sign.ru&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
</feed>
