All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Miquel Sabaté Solà" <mssola@mssola.com>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/2] btrfs: reject too high tree level during backref walk
Date: Mon, 23 Nov 2026 21:49:32 +0100	[thread overview]
Message-ID: <87ik1n1der.fsf@> (raw)
In-Reply-To: <220d8ed1b3a8d502c4260d01e4ac4ece942873f4.1795466145.git.wqu@suse.com>

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]

Qu Wenruo @ 2026-11-24 07:07 +1030:

> In handle_indirect_tree_backref(), if we got @cur->level set to 7
> (the max level valid), @level will be 8, then later path->slots[level]
> and path->nodes[level] will all go beyond the array boundary.
>
> Fix it by rejecting such high level before calling btrfs_search_slot().
>
> Link: https://sashiko.dev/#/bug/linux-8a4f92b4-daf7-4f57-8369-8e6ef323652f
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/btrfs/backref.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index a0fb90b7a9ed..e9434e033372 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -3316,6 +3316,11 @@ static int handle_indirect_tree_backref(struct btrfs_trans_handle *trans,
>  	}
>
>  	level = cur->level + 1;
> +	if (unlikely(level >= BTRFS_MAX_LEVEL)) {
> +		btrfs_put_root(root);
> +		btrfs_err(fs_info, "invalid searcch level %d", level);

Very minor, mind the typo in "search".

> +		return -EUCLEAN;
> +	}
>
>  	/* Search the tree to find parent blocks referring to the block */
>  	path->search_commit_root = true;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 897 bytes --]

  reply	other threads:[~2026-11-23 20:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 20:37 [PATCH v2 0/2] btrfs: minor fixes in handle_indirect_tree_backref() Qu Wenruo
2026-11-23 20:37 ` [PATCH v2 1/2] btrfs: reject too high tree level during backref walk Qu Wenruo
2026-11-23 20:49   ` Miquel Sabaté Solà [this message]
     [not found]   ` <6b04a6e2.0b3c54ea.4a96a.e3b7SMTPIN_ADDED_BROKEN@mx.google.com>
2026-11-23 21:09     ` Qu Wenruo
2026-11-25 17:38   ` Filipe Manana
2026-11-23 20:37 ` [PATCH v2 2/2] btrfs: avoid NULL-ptr-dreference after a lowest_level search Qu Wenruo
2026-11-25 17:37   ` Filipe Manana

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=87ik1n1der.fsf@ \
    --to=mssola@mssola.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.