Skip to content

Commit 4822b3e

Browse files
satoru-takeuchiscafroglia93
authored andcommitted
btrfs: prevent to set invalid default subvolid
commit 6d6d282932d1a609e60dc4467677e0e863682f57 upstream. `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") 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 00bd90e commit 4822b3e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/btrfs/ioctl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,6 +3963,10 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
39633963
ret = PTR_ERR(new_root);
39643964
goto out;
39653965
}
3966+
if (!is_fstree(new_root->objectid)) {
3967+
ret = -ENOENT;
3968+
goto out;
3969+
}
39663970

39673971
path = btrfs_alloc_path();
39683972
if (!path) {

0 commit comments

Comments
 (0)