From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Lizhi Xu <lizhi.xu@windriver.com>,
syzbot+4d81015bc10889fd12ea@syzkaller.appspotmail.com
Cc: boris@bur.io, clm@fb.com, dsterba@suse.com, josef@toxicpanda.com,
linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] btrfs: fix warning in create_pending_snapshot
Date: Sat, 11 Nov 2023 07:06:56 +1030 [thread overview]
Message-ID: <9e0559d3-c46f-4da6-8974-3790f1dfd3d8@gmx.com> (raw)
In-Reply-To: <20231110114806.3366681-1-lizhi.xu@windriver.com>
On 2023/11/10 22:18, Lizhi Xu wrote:
> r0 = open(&(0x7f0000000080)='./file0\x00', 0x0, 0x0)
> ioctl$BTRFS_IOC_QUOTA_CTL(r0, 0xc0109428, &(0x7f0000000000)={0x1})
> r1 = openat$cgroup_ro(0xffffffffffffff9c, &(0x7f0000000100)='blkio.bfq.time_recursive\x00', 0x275a, 0x0)
> ioctl$BTRFS_IOC_QGROUP_CREATE(r1, 0x4010942a, &(0x7f0000000640)={0x1, 0x100})
> r2 = openat(0xffffffffffffff9c, &(0x7f0000000500)='.\x00', 0x0, 0x0)
> ioctl$BTRFS_IOC_SNAP_CREATE(r0, 0x50009401, &(0x7f0000000a80)={{r2},
>
> From the logs, it can be seen that syz can execute to btrfs_ioctl_qgroup_create()
> through two paths.
> Syz enters btrfs_ioctl_qgroup_create() by calling ioctl$BTRFS_IOC_QGROUP_CREATE(
> r1, 0x4010942a,&(0x7f000000 640)={0x1, 0x100}) or ioctl$BTRFS_IOC_SNAP_CREATE(r0,
> 0x50009401,&(0x7f000000 a80)={r2}," respectively;
>
> The most crucial thing is that when calling ioctl$BTRFS_IOC_QGROUP_CREATE,
> the passed parameter qgroupid value is 256, while BTRFS_FIRST_FREE_OBJECTID
> is also equal to 256, indicating that the passed parameter qgroupid is
> obviously incorrect.
This conclusion looks incorrect to me.
Subvolumes are allowed to have any id in the range
[BTRFS_FIRST_TREE_OBJECTID, BTRFS_LAST_TREE_OBJECTID].
In fact, you can easily create a subvolume with 256 as its subvolumeid.
Just create an empty fs, and create a new subvolume in it, then you got;
item 11 key (256 ROOT_ITEM 0) itemoff 12961 itemsize 439
generation 7 root_dirid 256 bytenr 30441472 byte_limit 0 bytes_used 16384
...
So it's completely valid.
The root cause is just snapshot creation conflicts with an existing qgroup.
Thanks,
Qu
>
> Reported-and-tested-by: syzbot+4d81015bc10889fd12ea@syzkaller.appspotmail.com
> Fixes: 6ed05643ddb1 ("btrfs: create qgroup earlier in snapshot creation")
> Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
> ---
> fs/btrfs/ioctl.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 752acff2c734..21cf7a7f18ab 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3799,6 +3799,11 @@ static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg)
> goto out;
> }
>
> + if (sa->create && sa->qgroupid == BTRFS_FIRST_FREE_OBJECTID) { > + ret = -EINVAL;
> + goto out;
> + }
> +
> trans = btrfs_join_transaction(root);
> if (IS_ERR(trans)) {
> ret = PTR_ERR(trans);
next prev parent reply other threads:[~2023-11-10 20:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 17:16 [syzbot] [btrfs?] WARNING " syzbot
2023-11-10 6:26 ` [syzbot] [PATCH] test 305230142ae0 syzbot
2023-11-10 11:07 ` syzbot
2023-11-10 11:48 ` [PATCH] btrfs: fix warning in create_pending_snapshot Lizhi Xu
2023-11-10 20:36 ` Qu Wenruo [this message]
2023-11-11 0:43 ` [syzbot] [PATCH] test 305230142ae0 syzbot
2023-11-11 1:37 ` syzbot
2023-11-11 1:44 ` syzbot
2023-11-11 2:37 ` syzbot
2023-11-11 2:56 ` syzbot
2023-11-11 3:06 ` syzbot
2023-11-11 3:40 ` syzbot
2023-11-11 5:04 ` syzbot
[not found] ` <tencent_DB6BA6C1B369A367C96C83A36457D7735705@qq.com>
2023-11-11 6:20 ` [PATCH] btrfs: fix warning in create_pending_snapshot Matthew Wilcox
[not found] ` <tencent_82622979A3A74448177BF772E6D1736E4305@qq.com>
2023-11-11 20:48 ` [PATCH] test 305230142ae0 Qu Wenruo
2023-11-11 6:54 ` [PATCH] btrfs: fix warning in create_pending_snapshot Qu Wenruo
2023-11-12 3:13 ` [syzbot] [PATCH] test 305230142ae0 syzbot
2023-11-12 3:32 ` syzbot
2023-11-12 3:35 ` syzbot
[not found] ` <tencent_B9A7767566563D4D376C96BE36524B147409@qq.com>
2023-11-12 7:35 ` [PATCH V2] btrfs: fix warning in create_pending_snapshot Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9e0559d3-c46f-4da6-8974-3790f1dfd3d8@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=boris@bur.io \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.xu@windriver.com \
--cc=syzbot+4d81015bc10889fd12ea@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®