diff options
author | Herbert Poetzl <herbert@13thfloor.at> | 2006-03-31 05:31:35 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-31 15:18:59 -0500 |
commit | e4e5d3fc80d26ed26ebe42907b224f08d7eccfbf (patch) | |
tree | 081fc0bb38f91caa3b546ae030c03b87e3807b04 | |
parent | 158d9ebd19280582da172626ad3edda1a626dace (diff) |
[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: Herbert Poetzl <herbert@13thfloor.at>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/proc/base.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 8f1f49ceebec..a3a3eecef689 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -534,12 +534,15 @@ static int proc_oom_score(struct task_struct *task, char *buffer) | |||
534 | 534 | ||
535 | /* If the process being read is separated by chroot from the reading process, | 535 | /* If the process being read is separated by chroot from the reading process, |
536 | * don't let the reader access the threads. | 536 | * don't let the reader access the threads. |
537 | * | ||
538 | * note: this does dput(root) and mntput(vfsmnt) on exit. | ||
537 | */ | 539 | */ |
538 | static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) | 540 | static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) |
539 | { | 541 | { |
540 | struct dentry *de, *base; | 542 | struct dentry *de, *base; |
541 | struct vfsmount *our_vfsmnt, *mnt; | 543 | struct vfsmount *our_vfsmnt, *mnt; |
542 | int res = 0; | 544 | int res = 0; |
545 | |||
543 | read_lock(¤t->fs->lock); | 546 | read_lock(¤t->fs->lock); |
544 | our_vfsmnt = mntget(current->fs->rootmnt); | 547 | our_vfsmnt = mntget(current->fs->rootmnt); |
545 | base = dget(current->fs->root); | 548 | base = dget(current->fs->root); |
@@ -549,11 +552,11 @@ static int proc_check_chroot(struct dentry *root, struct vfsmount *vfsmnt) | |||
549 | de = root; | 552 | de = root; |
550 | mnt = vfsmnt; | 553 | mnt = vfsmnt; |
551 | 554 | ||
552 | while (vfsmnt != our_vfsmnt) { | 555 | while (mnt != our_vfsmnt) { |
553 | if (vfsmnt == vfsmnt->mnt_parent) | 556 | if (mnt == mnt->mnt_parent) |
554 | goto out; | 557 | goto out; |
555 | de = vfsmnt->mnt_mountpoint; | 558 | de = mnt->mnt_mountpoint; |
556 | vfsmnt = vfsmnt->mnt_parent; | 559 | mnt = mnt->mnt_parent; |
557 | } | 560 | } |
558 | 561 | ||
559 | if (!is_subdir(de, base)) | 562 | if (!is_subdir(de, base)) |
@@ -564,7 +567,7 @@ exit: | |||
564 | dput(base); | 567 | dput(base); |
565 | mntput(our_vfsmnt); | 568 | mntput(our_vfsmnt); |
566 | dput(root); | 569 | dput(root); |
567 | mntput(mnt); | 570 | mntput(vfsmnt); |
568 | return res; | 571 | return res; |
569 | out: | 572 | out: |
570 | spin_unlock(&vfsmount_lock); | 573 | spin_unlock(&vfsmount_lock); |