The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/2] hfsplus: avoid re-allocating header node 0 and stop on already-hashed nodes
@ 2025-12-24 15:13 Shardul Bankar
  2025-12-24 15:13 ` [PATCH v2 1/2] hfsplus: skip node 0 in hfs_bmap_alloc Shardul Bankar
  2025-12-24 15:13 ` [PATCH v2 2/2] hfsplus: return error when node already exists in hfs_bnode_create Shardul Bankar
  0 siblings, 2 replies; 6+ messages in thread
From: Shardul Bankar @ 2025-12-24 15:13 UTC (permalink / raw)
  To: slava, zippel, linux-fsdevel, glaubitz, frank.li
  Cc: akpm, linux-kernel, janak, shardulsb08, stable,
	syzbot+1c8ff72d0cd8a50dfeaa, Shardul Bankar

Hi,

syzbot reported a warning and crash when mounting a corrupted HFS+ image where
the on-disk B-tree bitmap has node 0 (header node) marked free. In that case
hfs_bmap_alloc() can try to allocate node 0 and reach hfs_bnode_create() with
an already-hashed node number.

Patch 1 prevents allocating the reserved header node (node 0) even if the bitmap
is corrupted.

Patch 2 follows Slava's review suggestion and changes the "already hashed" path
in hfs_bnode_create() to return ERR_PTR(-EEXIST) instead of returning the existing
node pointer, so we don't continue in a non-"business as usual" situation.

v2 changes:
  - Implement Slava's suggestion: return ERR_PTR(-EEXIST) for already-hashed nodes.
  - Keep the node-0 allocation guard as a minimal, targeted hardening measure.

Reported-by: syzbot+1c8ff72d0cd8a50dfeaa@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=1c8ff72d0cd8a50dfeaa
Link: https://lore.kernel.org/all/20251213233215.368558-1-shardul.b@mpiricsoftware.com/

Shardul Bankar (2):
  hfsplus: skip node 0 in hfs_bmap_alloc
  hfsplus: return error when node already exists in hfs_bnode_create

 fs/hfsplus/bnode.c | 2 +-
 fs/hfsplus/btree.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

-- 
2.34.1


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

end of thread, other threads:[~2025-12-29 20:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-24 15:13 [PATCH v2 0/2] hfsplus: avoid re-allocating header node 0 and stop on already-hashed nodes Shardul Bankar
2025-12-24 15:13 ` [PATCH v2 1/2] hfsplus: skip node 0 in hfs_bmap_alloc Shardul Bankar
2025-12-25  4:02   ` Viacheslav Dubeyko
2025-12-25  6:32     ` Shardul Bankar
2025-12-29 20:12       ` Viacheslav Dubeyko
2025-12-24 15:13 ` [PATCH v2 2/2] hfsplus: return error when node already exists in hfs_bnode_create Shardul Bankar

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