Re: [PATCH 0/3] hfs: fix writes to b-tree nodes larger than a page
From: Mar Dominguez
Date: Fri Dec 04 2026 - 17:23:00 EST
On Fri, 2026-12-04 at 19:32 +0000, Viacheslav Dubeyko wrote:
> Please, correct me if I wrong. Have you implemented support of node
> size bigger than 512 bytes in HFS?
No, patch 1 didn't add a new feature. hfs_btree_open() has accepted
any power-of-two node size since 2.6.12, and the read and node creation
paths already loop over the pages of a node, so patch 1 only made the
four write helpers do the same.
[...]
> So, we should support only 512 bytes node size. This a difference
> between HFS and HFS+. HFS supports only 512 bytes b-tree nodes and
> nodes share memory page. For the case of HFS+, b-tree node cannot be
> smaller than 4K, if I remember correctly. I assume that we could have
> issue in HFS b-tree nodes management code. But node size should be 512
> bytes always for the case of HFS.
Agreed, thanks for the spec references. I've sent a v2 that replaces
the series with one patch: hfs_btree_open() now rejects any node size
other than 512 bytes, for both the catalog and the extents tree. That
also closes the out-of-bounds write on crafted images, since a 512-byte
node never crosses a page boundary:
https://lore.kernel.org/linux-fsdevel/cqBIXnOxXx3ey7plxkEtHUghzAOub4g70HWj@xxxxxxxxxxxx/
v2 drops the KUnit patch, since its cases were for nodes larger than a
page. If you'd like KUnit tests for the write helpers on 512-byte
nodes, I can send them as a separate patch.
Thanks,
Mar