From 8d1ffc0f13fc683ff86ba0254afba9b99565fab7 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 29 Sep 2011 13:11:33 +0200 Subject: [PATCH] --- yaml --- r: 274675 b: refs/heads/master c: f9d9ef62cd3ecbd6cbb7957a253c1e81f69d5586 h: refs/heads/master i: 274673: 0580bef50b1e648356dc29d31626ad0d5c55cfe7 274671: d57bc7702e49c453a59259a3f6a52d34aa00aa42 v: v3 --- [refs] | 2 +- trunk/fs/btrfs/super.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 790c0dc5fb2c..6f585509d58e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 20bcd64934e4eb8f3f90a0dca54fb0ac2edd7795 +refs/heads/master: f9d9ef62cd3ecbd6cbb7957a253c1e81f69d5586 diff --git a/trunk/fs/btrfs/super.c b/trunk/fs/btrfs/super.c index 29eecbb6ec3a..5429b1fa0bfc 100644 --- a/trunk/fs/btrfs/super.c +++ b/trunk/fs/btrfs/super.c @@ -740,6 +740,16 @@ static int btrfs_set_super(struct super_block *s, void *data) return set_anon_super(s, data); } +/* + * subvolumes are identified by ino 256 + */ +static inline int is_subvolume_inode(struct inode *inode) +{ + if (inode && inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) + return 1; + return 0; +} + /* * This will strip out the subvol=%s argument for an argument string and add * subvolid=0 to make sure we get the actual tree root for path walking to the @@ -843,6 +853,15 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags, if (error) return ERR_PTR(error); + if (!is_subvolume_inode(path.dentry->d_inode)) { + path_put(&path); + mntput(mnt); + error = -EINVAL; + printk(KERN_ERR "btrfs: '%s' is not a valid subvolume\n", + subvol_name); + return ERR_PTR(-EINVAL); + } + /* Get a ref to the sb and the dentry we found and return it */ s = path.mnt->mnt_sb; atomic_inc(&s->s_active);