diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2008-02-08 07:18:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:23 -0500 |
commit | ee992744ea53db0a90c986fd0a70fbbf91e7f8bd (patch) | |
tree | 2d15727e92c407bb22c4842923cbfb2dfda82306 /fs/proc/internal.h | |
parent | be614086a4aff163d5aa0dc160638d1193b59cde (diff) |
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 <ebiederm@xmission.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/internal.h')
-rw-r--r-- | fs/proc/internal.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 7d57e8069924..f1cc6f1f4e34 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
@@ -46,10 +46,13 @@ extern int nommu_vma_show(struct seq_file *, struct vm_area_struct *); | |||
46 | 46 | ||
47 | extern int maps_protect; | 47 | extern int maps_protect; |
48 | 48 | ||
49 | extern void create_seq_entry(char *name, mode_t mode, const struct file_operations *f); | 49 | extern void create_seq_entry(char *name, mode_t mode, |
50 | const struct file_operations *f); | ||
50 | extern int proc_exe_link(struct inode *, struct dentry **, struct vfsmount **); | 51 | extern int proc_exe_link(struct inode *, struct dentry **, struct vfsmount **); |
51 | extern int proc_tid_stat(struct task_struct *, char *); | 52 | extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, |
52 | extern int proc_tgid_stat(struct task_struct *, char *); | 53 | struct pid *pid, struct task_struct *task); |
54 | extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, | ||
55 | struct pid *pid, struct task_struct *task); | ||
53 | extern int proc_pid_status(struct task_struct *, char *); | 56 | extern int proc_pid_status(struct task_struct *, char *); |
54 | extern int proc_pid_statm(struct task_struct *, char *); | 57 | extern int proc_pid_statm(struct task_struct *, char *); |
55 | extern loff_t mem_lseek(struct file *file, loff_t offset, int orig); | 58 | extern loff_t mem_lseek(struct file *file, loff_t offset, int orig); |