From: Carlos Maiolino <cem@kernel.org>
To: Henry Martin <bsdhenrymartin@gmail.com>
Cc: "Darrick J . Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] xfs: fix out-of-bounds cursor access from rtrmap level off-by-one
Date: Fri, 9 Oct 2026 14:04:00 +0200 [thread overview]
Message-ID: <asjVgZJijA4r1MlV@cronus.toxiclabs.cc> (raw)
In-Reply-To: <20261009114503.3669142-1-bsdhenrymartin@gmail.com>
On Fri, Oct 09, 2026 at 07:45:03PM +0800, Henry Martin wrote:
> m_rtrmap_maxlevels includes the inode root level, so a valid on-disk
> bb_level is strictly less than m_rtrmap_maxlevels. Both
> xfs_rtrmapbt_verify() and xfs_iformat_rtrmap() compare with ">"
> instead of ">=", letting a forged block with level == maxlevels pass
> validation.
So you need a maliciously crafted filesystem image and enough privileges
to be able to mount it.
> The cursor is then sized for maxlevels entries while
> bc_nlevels is set to level + 1, so the generic btree code indexes one
> element past bc_levels[] - an out-of-bounds read/write on the cursor
> allocation.
>
> xfs_rtrmapbt_mem_verify() in the same file (from commit
> 4a61f12eb1195 "xfs: create a shadow rmap btree during realtime rmap
> repair") already uses ">=".
>
> This vulnerability was discovered by Tencent CodeBuddy Security.
What is the "vulnerability" you are claiming here? How can this be
exploited? For what you described, it requires a crafted filesystem
image, which should require a privileged user to mount, so while this is
a bug, calling it a vulnerability is a big stretch.
So, giving you claimed it to be a vulnerability, how can it be
exploited by a non-privileged user? Where is the reproducer? You can
even share it off-list if you prefer.
>
> Cc: stable@vger.kernel.org
> Fixes: fc6856c6ff086 ("xfs: introduce realtime rmap btree ondisk definitions")
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
> ---
> fs/xfs/libxfs/xfs_rtrmap_btree.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_rtrmap_btree.c b/fs/xfs/libxfs/xfs_rtrmap_btree.c
> index a15e460a1ec7..6833c924a383 100644
> --- a/fs/xfs/libxfs/xfs_rtrmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_rtrmap_btree.c
> @@ -256,7 +256,7 @@ xfs_rtrmapbt_verify(
> if (fa)
> return fa;
> level = be16_to_cpu(block->bb_level);
> - if (level > mp->m_rtrmap_maxlevels)
> + if (level >= mp->m_rtrmap_maxlevels)
> return __this_address;
>
> return xfs_btree_fsblock_verify(bp, mp->m_rtrmap_mxr[level != 0]);
> @@ -888,7 +888,7 @@ xfs_iformat_rtrmap(
> numrecs = be16_to_cpu(dfp->bb_numrecs);
> level = be16_to_cpu(dfp->bb_level);
>
> - if (level > mp->m_rtrmap_maxlevels ||
> + if (level >= mp->m_rtrmap_maxlevels ||
> xfs_rtrmap_droot_space_calc(level, numrecs) > dsize) {
> xfs_inode_mark_sick(ip, XFS_SICK_INO_CORE);
> return -EFSCORRUPTED;
> --
> 2.43.7
>
>
prev parent reply other threads:[~2026-10-09 12:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 11:45 Henry Martin
2026-10-09 12:04 ` Carlos Maiolino [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=asjVgZJijA4r1MlV@cronus.toxiclabs.cc \
--to=cem@kernel.org \
--cc=bsdhenrymartin@gmail.com \
--cc=djwong@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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®