aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatoru takeuchi <satoru.takeuchi@gmail.com>2017-09-12 09:42:52 -0400
committerDavid Sterba <dsterba@suse.com>2017-09-26 08:52:25 -0400
commit6d6d282932d1a609e60dc4467677e0e863682f57 (patch)
tree142569afd142892f054790b43311ab8d74e34063
parentca6842bf01dc1ad41195eac1e343b4f08c496ba8 (diff)
btrfs: prevent to set invalid default subvolid
`btrfs sub set-default` succeeds to set an ID which isn't corresponding to any fs/file tree. If such the bad ID is set to a filesystem, we can't mount this filesystem without specifying `subvol` or `subvolid` mount options. Fixes: 6ef5ed0d386b ("Btrfs: add ioctl and incompat flag to set the default mount subvol") Cc: <stable@vger.kernel.org> Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com> Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/ioctl.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index cf1c2ee030dd..d4a77993e52f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4057,6 +4057,10 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
4057 ret = PTR_ERR(new_root); 4057 ret = PTR_ERR(new_root);
4058 goto out; 4058 goto out;
4059 } 4059 }
4060 if (!is_fstree(new_root->objectid)) {
4061 ret = -ENOENT;
4062 goto out;
4063 }
4060 4064
4061 path = btrfs_alloc_path(); 4065 path = btrfs_alloc_path();
4062 if (!path) { 4066 if (!path) {