Skip to content

hfs/hfsplus: harden btree node 0 bitmap corruption handling

Tao Yu linux-fsdevel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2hfs: detect node 0 btree map corruption at mount timefs/hfs/btree.c+60 -01 reply
2/2hfs/hfsplus: stop btree allocators from reusing node 0fs/hfs/btree.c fs/hfsplus/btree.c+22 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] hfs/hfsplus: harden btree node 0 bitmap corruption handling

Hi,

This series addresses btree bitmap corruption around node 0 in HFS and HFS+.

Node 0 is the reserved btree header node. If the on-disk bitmap ever presents node 0 as free, the filesystem is already corrupted and should not continue normal allocation from that state.

The series does two things:

1. Port the existing HFS+ style mount-time node 0 bitmap validation to HFS, so HFS detects the corrupted btree map earlier and forces the filesystem read-only.

2. Harden the HFS and HFS+ btree allocators so that attempts to allocate node 0 are treated as bitmap corruption. Instead of continuing into the reserved header node and later tripping the "new node 0 already hashed?" warning, the allocator now emits a repair hint, forces the filesystem read-only, and aborts the allocation.

This keeps the existing warning as a last-resort invariant check, while moving the actual corruption handling to earlier and more appropriate control points.

Patch 1 ports the mount-time validation to HFS. Patch 2 adds the runtime allocator guard to both HFS and HFS+.

Comments are welcome.

Tao Yu (2):
hfs: detect node 0 btree map corruption at mount time hfs/hfsplus: stop btree allocators from reusing node 0

 fs/hfs/btree.c     | 71 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/hfsplus/btree.c | 11 +++++++
 2 files changed, 82 insertions(+)

Thanks,
Tao

Signature · 1 line
2.34.1