diff options
| author | Eric W. Biederman <[email protected]> | 2008-02-08 12:18:31 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2008-02-08 17:22:23 +0000 |
| commit | ee992744ea53db0a90c986fd0a70fbbf91e7f8bd (patch) | |
| tree | 2d15727e92c407bb22c4842923cbfb2dfda82306 /fs/proc/base.c | |
| parent | proc: implement proc_single_file_operations (diff) | |
| download | kernel-ee992744ea53db0a90c986fd0a70fbbf91e7f8bd.tar.gz kernel-ee992744ea53db0a90c986fd0a70fbbf91e7f8bd.zip | |
proc: rewrite do_task_stat to correctly handle pid namespaces.
Currently (as pointed out by Oleg) do_task_stat has a race when calling
task_pid_nr_ns with the task exiting. In addition do_task_stat is not
currently displaying information in the context of the pid namespace that
mounted the /proc filesystem. So "cut -d' ' -f 1 /proc/<pid>/stat" may not
equal <pid>.
This patch fixes the problem by converting to a single_open seq_file show
method. Getting the pid namespace from the filesystem superblock instead of
current, and simply using the the struct pid from the inode instead of
attempting to get that same pid from the task.
Signed-off-by: Eric W. Biederman <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'fs/proc/base.c')
| -rw-r--r-- | fs/proc/base.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index f4b1e14bd95b..f77818ecaa8a 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2280,7 +2280,7 @@ static const struct pid_entry tgid_base_stuff[] = { REG("sched", S_IRUGO|S_IWUSR, pid_sched), #endif INF("cmdline", S_IRUGO, pid_cmdline), - INF("stat", S_IRUGO, tgid_stat), + ONE("stat", S_IRUGO, tgid_stat), INF("statm", S_IRUGO, pid_statm), REG("maps", S_IRUGO, maps), #ifdef CONFIG_NUMA @@ -2611,7 +2611,7 @@ static const struct pid_entry tid_base_stuff[] = { REG("sched", S_IRUGO|S_IWUSR, pid_sched), #endif INF("cmdline", S_IRUGO, pid_cmdline), - INF("stat", S_IRUGO, tid_stat), + ONE("stat", S_IRUGO, tid_stat), INF("statm", S_IRUGO, pid_statm), REG("maps", S_IRUGO, maps), #ifdef CONFIG_NUMA |
