* [PATCH] btrfs: prevent to set invalid default subvolid
@ 2017-09-12 13:42 Satoru Takeuchi
2017-09-13 1:28 ` Qu Wenruo
2017-09-13 15:19 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Satoru Takeuchi @ 2017-09-12 13:42 UTC (permalink / raw)
To: linux-btrfs
`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@gmail.com>
---
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) {
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: prevent to set invalid default subvolid
2017-09-12 13:42 [PATCH] btrfs: prevent to set invalid default subvolid Satoru Takeuchi
@ 2017-09-13 1:28 ` Qu Wenruo
2017-09-13 15:19 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2017-09-13 1:28 UTC (permalink / raw)
To: Satoru Takeuchi, linux-btrfs
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@gmail.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
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) {
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: prevent to set invalid default subvolid
2017-09-12 13:42 [PATCH] btrfs: prevent to set invalid default subvolid Satoru Takeuchi
2017-09-13 1:28 ` Qu Wenruo
@ 2017-09-13 15:19 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2017-09-13 15:19 UTC (permalink / raw)
To: Satoru Takeuchi; +Cc: linux-btrfs
On Tue, Sep 12, 2017 at 10:42:52PM +0900, 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@gmail.com>
Fixes: 6ef5ed0d386b
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-13 15:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 13:42 [PATCH] btrfs: prevent to set invalid default subvolid Satoru Takeuchi
2017-09-13 1:28 ` Qu Wenruo
2017-09-13 15:19 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).