Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Fedor Pchelkin <pchelkin@ispras.ru>, David Sterba <dsterba@suse.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	Boris Burkov <boris@bur.io>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org,
	syzbot+81670362c283f3dd889c@syzkaller.appspotmail.com,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: qgroup: don't use extent changeset when not needed
Date: Thu, 29 Aug 2024 07:06:06 +0930	[thread overview]
Message-ID: <1a972f83-d583-466d-9fc4-d96baf2e057c@gmx.com> (raw)
In-Reply-To: <20240828161411.534042-1-pchelkin@ispras.ru>



在 2024/8/29 01:44, Fedor Pchelkin 写道:
> The local extent changeset is passed to clear_record_extent_bits() where
> it may have some additional memory dynamically allocated for ulist. When
> qgroup is disabled, the memory is leaked because in this case the
> changeset is not released upon __btrfs_qgroup_release_data() return.
>
> Since the recorded contents of the changeset are not used thereafter, just
> don't pass it.
>
> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
>
> Reported-by: syzbot+81670362c283f3dd889c@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/lkml/000000000000aa8c0c060ade165e@google.com
> Fixes: af0e2aab3b70 ("btrfs: qgroup: flush reservations during quota disable")
> Cc: stable@vger.kernel.org # 6.10+
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
> v2: rework the fix as Qu Wenruo suggested - just don't pass unneeded
>      changeset. Update the commit title and description accordingly.
>
>   fs/btrfs/qgroup.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 5d57a285d59b..f6118c5f3c9f 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -4344,10 +4344,9 @@ static int __btrfs_qgroup_release_data(struct btrfs_inode *inode,
>   	int ret;
>
>   	if (btrfs_qgroup_mode(inode->root->fs_info) == BTRFS_QGROUP_MODE_DISABLED) {
> -		extent_changeset_init(&changeset);
>   		return clear_record_extent_bits(&inode->io_tree, start,
>   						start + len - 1,
> -						EXTENT_QGROUP_RESERVED, &changeset);
> +						EXTENT_QGROUP_RESERVED, NULL);
>   	}
>
>   	/* In release case, we shouldn't have @reserved */

  parent reply	other threads:[~2024-08-28 21:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27 15:12 [PATCH] btrfs: qgroup: add missing extent changeset release Fedor Pchelkin
2024-08-27 16:03 ` David Sterba
2024-08-28  9:19   ` Fedor Pchelkin
2024-08-28  9:24 ` Qu Wenruo
2024-08-28  9:30   ` Qu Wenruo
2024-08-28 16:14     ` [PATCH v2] btrfs: qgroup: don't use extent changeset when not needed Fedor Pchelkin
2024-08-28 16:57       ` Boris Burkov
2024-08-28 21:36       ` Qu Wenruo [this message]
2024-08-28 21:56       ` David Sterba

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=1a972f83-d583-466d-9fc4-d96baf2e057c@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-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=pchelkin@ispras.ru \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+81670362c283f3dd889c@syzkaller.appspotmail.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