[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a9b53a9a-ddcb-4113-8769-40a918223ecf@suse.com>
Date: Tue, 9 Dec 2025 06:49:06 +1030
From: Qu Wenruo <wqu@...e.com>
To: Edward Adam Davis <eadavis@...com>,
syzbot+b44d4a4885bc82af2a06@...kaller.appspotmail.com
Cc: clm@...com, dsterba@...e.com, josef@...icpanda.com,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
syzkaller-bugs@...glegroups.com
Subject: Re: [PATCH] btrfs: Optimize the timing of prealloc memory allocation
在 2025/12/8 21:35, Edward Adam Davis 写道:
> Too many abnormal exits can cause the prealloc assertion to fail, as
> reported by syzbot in [1].
>
> Move the prealloc memory allocation to before it is actually used.
>
> [1]
> assertion failed: prealloc == NULL :: 0, in fs/btrfs/qgroup.c:3529
> kernel BUG at fs/btrfs/qgroup.c:3529!
> Call Trace:
> <TASK>
> create_subvol+0x5ad/0x18f0 fs/btrfs/ioctl.c:570
> btrfs_mksubvol+0x6e4/0x12c0 fs/btrfs/ioctl.c:928
> __btrfs_ioctl_snap_create+0x2b2/0x730 fs/btrfs/ioctl.c:1201
> btrfs_ioctl_snap_create+0x131/0x180 fs/btrfs/ioctl.c:1259
> btrfs_ioctl+0xb4d/0xd00 fs/btrfs/ioctl.c:-1
There is already a full revert, and your fix misses all the other error
cases.
https://lore.kernel.org/linux-btrfs/20251208195407.GC4859@twin.jikos.cz/T/#t
>
> Fixes: 252877a87015 ("btrfs: add ASSERTs on prealloc in qgroup functions")
> Reported-by: syzbot+b44d4a4885bc82af2a06@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=b44d4a4885bc82af2a06
> Tested-by: syzbot+b44d4a4885bc82af2a06@...kaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@...com>
> ---
> fs/btrfs/qgroup.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 9e2b53e90dcb..ac5380520152 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -3289,10 +3289,6 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
> if (!btrfs_qgroup_enabled(fs_info))
> return 0;
>
> - prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS);
> - if (!prealloc)
> - return -ENOMEM;
> -
> /*
> * There are only two callers of this function.
> *
> @@ -3388,6 +3384,12 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
> }
> }
>
> + prealloc = kzalloc(sizeof(*prealloc), GFP_NOFS);
> + if (!prealloc) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> spin_lock(&fs_info->qgroup_lock);
>
> dstgroup = add_qgroup_rb(fs_info, prealloc, objectid);
Powered by blists - more mailing lists