btrfs: prevent to set invalid default subvolid
PATCH 1/1 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.
--- fs/btrfs/ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/ioctl.c +4 -0
@@ -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) {
Signature · 1 line
2.7.4
Quoted 5 lines · Satoru Takeuchi
btrfs sub set-defaultsucceeds 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 specifyingsubvolorsubvolidmount options.Signed-off-by Satoru Takeuchi <[email protected]>
I was a little worried about the handling of special treeid like RECLOC and DATA_RELOC, but is_fstree() called btrfs_qgroup_level() check so we don't need to worry about that.
Nice catch.
Thanks,
Qu
Quoted 20 lines
(quoted diff) +0
-1- fs/btrfs/ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)fs/btrfs/ioctl.c +4
-0@@ -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) {
Quoted 5 lines · Satoru Takeuchi
btrfs sub set-defaultsucceeds 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 specifyingsubvolorsubvolidmount options.Signed-off-by Satoru Takeuchi <[email protected]>