aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-19 02:40:11 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:40 -0400
commit6f4e643353aea52d80f33960bd88954a7c074f0f (patch)
tree5b7e452f7e31be89f06a52a2c077183b7fe74c3b /fs/proc
parent130f77ecb2e7d5ac3e53e620f55e374f4a406b20 (diff)
pid namespaces: initialize the namespace's proc_mnt
The namespace's proc_mnt must be kern_mount-ed to make this pointer always valid, independently of whether the user space mounted the proc or not. This solves raced in proc_flush_task, etc. with the proc_mnt switching from NULL to not-NULL. The initialization is done after the init's pid is created and hashed to make proc_get_sb() finr it and get for root inode. Sice the namespace holds the vfsmnt, vfsmnt holds the superblock and the superblock holds the namespace we must explicitly break this circle to destroy all the stuff. This is done after the init of the namespace dies. Running a few steps forward - when init exits it will kill all its children, so no proc_mnt will be needed after its death. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com> Cc: Paul Menage <menage@google.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c4
-rw-r--r--fs/proc/root.c16
2 files changed, 20 insertions, 0 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 5e0c6a1ce8b3..21510c9aa89c 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2275,6 +2275,10 @@ void proc_flush_task(struct task_struct *task)
2275 proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr, 2275 proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr,
2276 leader ? 0 : tgid->numbers[i].nr); 2276 leader ? 0 : tgid->numbers[i].nr);
2277 } 2277 }
2278
2279 upid = &pid->numbers[pid->level];
2280 if (upid->nr == 1)
2281 pid_ns_release_proc(upid->ns);
2278} 2282}
2279 2283
2280static struct dentry *proc_pid_instantiate(struct inode *dir, 2284static struct dentry *proc_pid_instantiate(struct inode *dir,
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 94e9d734384e..ec9cb3b6c93b 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -212,6 +212,22 @@ struct proc_dir_entry proc_root = {
212 .parent = &proc_root, 212 .parent = &proc_root,
213}; 213};
214 214
215int pid_ns_prepare_proc(struct pid_namespace *ns)
216{
217 struct vfsmount *mnt;
218
219 mnt = kern_mount_data(&proc_fs_type, ns);
220 if (IS_ERR(mnt))
221 return PTR_ERR(mnt);
222
223 return 0;
224}
225
226void pid_ns_release_proc(struct pid_namespace *ns)
227{
228 mntput(ns->proc_mnt);
229}
230
215EXPORT_SYMBOL(proc_symlink); 231EXPORT_SYMBOL(proc_symlink);
216EXPORT_SYMBOL(proc_mkdir); 232EXPORT_SYMBOL(proc_mkdir);
217EXPORT_SYMBOL(create_proc_entry); 233EXPORT_SYMBOL(create_proc_entry);