aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-22 12:31:21 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2011-11-22 12:31:21 -0500
commitd31da0f0ba3bc0a827a63879310818c22d9a95be (patch)
treed89bbdf299c4cbc37f49a9964b8127f09eedd50b
parentb46413367961c2e8bd827e067a231be982aaeee2 (diff)
mount_subtree() pointless use-after-free
d'oh... we'd carefully pinned mnt->mnt_sb down, dropped mnt and attempt to grab s_umount on mnt->mnt_sb. The trouble is, *mnt might've been overwritten by now... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/namespace.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 50ee30345b4f..6d3a1963879b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2493,6 +2493,7 @@ EXPORT_SYMBOL(create_mnt_ns);
2493struct dentry *mount_subtree(struct vfsmount *mnt, const char *name) 2493struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
2494{ 2494{
2495 struct mnt_namespace *ns; 2495 struct mnt_namespace *ns;
2496 struct super_block *s;
2496 struct path path; 2497 struct path path;
2497 int err; 2498 int err;
2498 2499
@@ -2509,10 +2510,11 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
2509 return ERR_PTR(err); 2510 return ERR_PTR(err);
2510 2511
2511 /* trade a vfsmount reference for active sb one */ 2512 /* trade a vfsmount reference for active sb one */
2512 atomic_inc(&path.mnt->mnt_sb->s_active); 2513 s = path.mnt->mnt_sb;
2514 atomic_inc(&s->s_active);
2513 mntput(path.mnt); 2515 mntput(path.mnt);
2514 /* lock the sucker */ 2516 /* lock the sucker */
2515 down_write(&path.mnt->mnt_sb->s_umount); 2517 down_write(&s->s_umount);
2516 /* ... and return the root of (sub)tree on it */ 2518 /* ... and return the root of (sub)tree on it */
2517 return path.dentry; 2519 return path.dentry;
2518} 2520}