Re: [PATCH] btrfs: prevent to set invalid default subvolid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2017年09月12日 21:42, Satoru Takeuchi wrote:
`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.

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@xxxxxxxxx>

Reviewed-by: Qu Wenruo <quwenruo.btrfs@xxxxxxx>

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
-
  fs/btrfs/ioctl.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index ae8fbf9..8e1bc19 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)
  		ret = PTR_ERR(new_root);
  		goto out;
  	}
+	if (!is_fstree(new_root->objectid)) {
+		ret = -ENOENT;
+		goto out;
+	}
path = btrfs_alloc_path();
  	if (!path) {

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux