Skip to content

Commit

Permalink
btrfs: prevent to set invalid default subvolid
Browse files Browse the repository at this point in the history
`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: 6ef5ed0 ("Btrfs: add ioctl and incompat flag to set the default mount subvol")
Cc: <[email protected]>
Signed-off-by: Satoru Takeuchi <[email protected]>
Reviewed-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
satoru-takeuchi authored and kdave committed Sep 26, 2017
1 parent ca6842b commit 6d6d282
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4057,6 +4057,10 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
ret = PTR_ERR(new_root);
goto out;
}
if (!is_fstree(new_root->objectid)) {
ret = -ENOENT;
goto out;
}

path = btrfs_alloc_path();
if (!path) {
Expand Down

0 comments on commit 6d6d282

Please sign in to comment.