]> git.karo-electronics.de Git - karo-tx-linux.git/commit
proc: don't (ab)use ->group_leader in proc_task_readdir() paths
authorOleg Nesterov <oleg@redhat.com>
Fri, 3 Jan 2014 03:10:29 +0000 (14:10 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 3 Jan 2014 03:10:29 +0000 (14:10 +1100)
commit985082bf4c98d8311bccf3ffe0770298acbce4ac
tree9743aeaf566a79aeb8409955d8cd6922305bbc30
parentf47458c3aea850823537440d1b33497d3eaceb02
proc: don't (ab)use ->group_leader in proc_task_readdir() paths

proc_task_readdir() does not really need "leader", first_tid() has to
revalidate it anyway.  Just pass proc_pid(inode) to first_tid() instead,
it can do pid_task(PIDTYPE_PID) itself and read ->group_leader only if
necessary.

The patch also extracts the "inode is dead" code from
pid_delete_dentry(dentry) into the new trivial helper,
proc_inode_is_dead(inode), proc_task_readdir() uses it to return -ENOENT
if this dir was removed.

This is a bit racy, but the race is very inlikely and the getdents() after
openndir() can see the empty "." + ".." dir only once.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Sameer Nanda <snanda@chromium.org>
Cc: Sergey Dyasly <dserrg@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/proc/base.c