From: Qu Wenruo <wqu@suse.com>
To: ZhengYuan Huang <gality369@gmail.com>, dsterba@suse.com, clm@fb.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
baijiaju1990@gmail.com, r33s3n6@gmail.com, zzzccc427@gmail.com
Subject: Re: [PATCH v2 0/2] btrfs: verify cached extent buffers against tree parent checks
Date: Sat, 14 Mar 2026 10:19:31 +1030 [thread overview]
Message-ID: <1c34e37c-9a5c-4063-9e4d-84c797c0daa8@suse.com> (raw)
In-Reply-To: <20260313091924.570554-1-gality369@gmail.com>
在 2026/3/13 19:49, ZhengYuan Huang 写道:
> This series fixes a btrfs crash caused by reusing a cached extent buffer
> without re-running the caller supplied tree-parent verification.
>
> The problem happens when a tree block is first read and validated with one
> expected level, then later looked up again through a path that derives a
> different expected level from corrupted metadata. If the extent buffer is
> already marked EXTENT_BUFFER_UPTODATE, the cached-hit path returns it
> without re-validating the supplied btrfs_tree_parent_check. This can allow
> an inconsistent btrfs_root to be constructed and later lead to a
> null-ptr-deref during backref walking.
>
> Patch 1/2 is a preparatory change that extends
> btrfs_buffer_uptodate() to support tree-parent verification on cached
> buffers. Patch 2/2 uses that support on the cached-hit path and contains
> the actual fix.
>
> Together, these changes make cache hits and fresh reads follow the same
> tree-parent verification rules, turning the corruption into a read failure
> instead of constructing an inconsistent root object and crashing later.
>
> For reference, a more detailed analysis of the trigger path is available at:
> https://lore.kernel.org/all/CAOmEq9U14a=pwN_dw2M70gfujhMKki434cfmegoxcyUpkYs5bQ@mail.gmail.com/
>
> Changes since v1:
> - drop the adhoc root-specific consistency check in read_tree_root_path()
> - move the validation into the cached-hit path as suggested by Qu Wenruo
> - extend btrfs_buffer_uptodate() with an optional tree-parent check
> - make read_tree_root_path() pass its check when validating a cached root
>
> ZhengYuan Huang (2):
> btrfs: add tree parent check to btrfs_buffer_uptodate()
> btrfs: revalidate cached tree blocks on the uptodate path
The code looks good to me, but considering both patches are small, and
without the second patch the first one doesn't make much sense.
So I'll merge both into a single patch at merging.
Thanks,
Qu
>
> fs/btrfs/ctree.c | 2 +-
> fs/btrfs/disk-io.c | 18 ++++++++++++++----
> fs/btrfs/disk-io.h | 3 ++-
> fs/btrfs/extent-tree.c | 2 +-
> fs/btrfs/extent_io.c | 12 ++++++++++--
> fs/btrfs/tree-log.c | 2 +-
> 6 files changed, 29 insertions(+), 10 deletions(-)
>
prev parent reply other threads:[~2026-03-13 23:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 9:19 ZhengYuan Huang
2026-03-13 9:19 ` [PATCH v2 1/2] btrfs: add tree parent check to btrfs_buffer_uptodate() ZhengYuan Huang
2026-03-13 9:19 ` [PATCH v2 2/2] btrfs: revalidate cached tree blocks on the uptodate path ZhengYuan Huang
2026-03-15 21:17 ` Qu Wenruo
2026-03-13 23:49 ` Qu Wenruo [this message]
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=1c34e37c-9a5c-4063-9e4d-84c797c0daa8@suse.com \
--to=wqu@suse.com \
--cc=baijiaju1990@gmail.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=gality369@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=r33s3n6@gmail.com \
--cc=zzzccc427@gmail.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®