提交 e4e5d3fc 编写于 作者: H Herbert Poetzl 提交者: Linus Torvalds

[PATCH] cleanup in proc_check_chroot()

proc_check_chroot() does the check in a very unintuitive way (keeping a
copy of the argument, then modifying the argument), and has uncommented
sideeffects.
Signed-off-by: NHerbert Poetzl <herbert@13thfloor.at>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 158d9ebd
...@@ -534,12 +534,15 @@ static int proc_oom_score(struct task_struct *task, char *buffer) ...@@ -534,12 +534,15 @@ static int proc_oom_score(struct task_struct *task, char *buffer)
/* If the process being read is separated by chroot from the reading process, /* If the process being read is separated by chroot from the reading process,
* don't let the reader access the threads. * don't let the reader access the threads.
*
* note: this does dput(root) and mntput(vfsmnt) on exit.
*/ */
static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt)
{ {
struct dentry *de, *base; struct dentry *de, *base;
struct vfsmount *our_vfsmnt, *mnt; struct vfsmount *our_vfsmnt, *mnt;
int res = 0; int res = 0;
read_lock(&current->fs->lock); read_lock(&current->fs->lock);
our_vfsmnt = mntget(current->fs->rootmnt); our_vfsmnt = mntget(current->fs->rootmnt);
base = dget(current->fs->root); base = dget(current->fs->root);
...@@ -549,11 +552,11 @@ static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) ...@@ -549,11 +552,11 @@ static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt)
de = root; de = root;
mnt = vfsmnt; mnt = vfsmnt;
while (vfsmnt != our_vfsmnt) { while (mnt != our_vfsmnt) {
if (vfsmnt == vfsmnt->mnt_parent) if (mnt == mnt->mnt_parent)
goto out; goto out;
de = vfsmnt->mnt_mountpoint; de = mnt->mnt_mountpoint;
vfsmnt = vfsmnt->mnt_parent; mnt = mnt->mnt_parent;
} }
if (!is_subdir(de, base)) if (!is_subdir(de, base))
...@@ -564,7 +567,7 @@ static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) ...@@ -564,7 +567,7 @@ static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt)
dput(base); dput(base);
mntput(our_vfsmnt); mntput(our_vfsmnt);
dput(root); dput(root);
mntput(mnt); mntput(vfsmnt);
return res; return res;
out: out:
spin_unlock(&vfsmount_lock); spin_unlock(&vfsmount_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册