]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hfs: clear offset and space out of valid records in b-tree node
authorViacheslav Dubeyko <slava@dubeyko.com>
Fri, 15 Aug 2025 19:49:19 +0000 (12:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2025 13:04:35 +0000 (14:04 +0100)
commit92c037de74efae53ca195926bde67136c76de262
tree1d86129ecce2989068b6b66966b8fae4d5594aa0
parent5c3e38a367822f036227dd52bac82dc4a05157e2
hfs: clear offset and space out of valid records in b-tree node

[ Upstream commit 18b07c44f245beb03588b00b212b38fce9af7cc9 ]

Currently, hfs_brec_remove() executes moving records
towards the location of deleted record and it updates
offsets of moved records. However, the hfs_brec_remove()
logic ignores the "mess" of b-tree node's free space and
it doesn't touch the offsets out of records number.
Potentially, it could confuse fsck or driver logic or
to be a reason of potential corruption cases.

This patch reworks the logic of hfs_brec_remove()
by means of clearing freed space of b-tree node
after the records moving. And it clear the last
offset that keeping old location of free space
because now the offset before this one is keeping
the actual offset to the free space after the record
deletion.

Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
cc: Yangtao Li <frank.li@vivo.com>
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/20250815194918.38165-1-slava@dubeyko.com
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/hfs/brec.c