public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs : Fix potential null pointer dereference in xfs_exchmaps_dir_to_sf()
@ 2025-11-25 14:22 Chelsy Ratnawat
  2025-11-25 17:04 ` Darrick J. Wong
  2025-12-03  6:21 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Chelsy Ratnawat @ 2025-11-25 14:22 UTC (permalink / raw)
  To: cem, djwong; +Cc: linux-xfs, Chelsy Ratnawat

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.

Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-03 10:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-12-03  6:21 ` Christoph Hellwig
2025-12-03 10:32   ` Carlos Maiolino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox