From: "Darrick J. Wong" <djwong@kernel.org>
To: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
Cc: cem@kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs : Fix potential null pointer dereference in xfs_exchmaps_dir_to_sf()
Date: Tue, 25 Nov 2025 09:04:54 -0800 [thread overview]
Message-ID: <20251125170454.GF23418@frogsfrogsfrogs> (raw)
In-Reply-To: <20251125142205.432890-1-chelsyratnawat2001@gmail.com>
On Tue, Nov 25, 2025 at 06:22:05AM -0800, Chelsy Ratnawat wrote:
> xfs_dir3_block_read() can return a NULL buffer with no error, but
> xfs_exchmaps_dir_to_sf() dereferences bp without checking it.
> Fix this by adding a check for NULL and returning -EFSCORRUPTED if bp is
> missing, since block-format directories must have a valid data block.
How did you encounter this bug? Did you hit it in production? syzbot
report? Something else?
Also, are there similar functions in xfs_exchmaps.c that suffer from the
same problem?
> Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
Cc: <stable@vger.kernel.org> # v6.10
Fixes: da165fbde23b84 ("xfs: condense directories after a mapping exchange operation")
--D
> ---
> fs/xfs/libxfs/xfs_exchmaps.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_exchmaps.c b/fs/xfs/libxfs/xfs_exchmaps.c
> index 932ee4619e9e..e33a401d9766 100644
> --- a/fs/xfs/libxfs/xfs_exchmaps.c
> +++ b/fs/xfs/libxfs/xfs_exchmaps.c
> @@ -475,6 +475,9 @@ xfs_exchmaps_dir_to_sf(
> if (error)
> return error;
>
> + if (!bp)
> + return -EFSCORRUPTED;
> +
> size = xfs_dir2_block_sfsize(xmi->xmi_ip2, bp->b_addr, &sfh);
> if (size > xfs_inode_data_fork_size(xmi->xmi_ip2))
> return 0;
> --
> 2.47.3
>
next prev parent reply other threads:[~2025-11-25 17:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 14:22 [PATCH] xfs : Fix potential null pointer dereference in xfs_exchmaps_dir_to_sf() Chelsy Ratnawat
2025-11-25 17:04 ` Darrick J. Wong [this message]
2025-12-03 6:21 ` Christoph Hellwig
2025-12-03 10:32 ` Carlos Maiolino
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=20251125170454.GF23418@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=chelsyratnawat2001@gmail.com \
--cc=linux-xfs@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