Forwarded: [PATCH] hfsplus: initialize data in hfs_bnode_read_u16 and

From: syzbot

Date: Fri Apr 17 2026 - 06:17:08 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx, syzkaller-bugs@xxxxxxxxxxxxxxxx.

***

Subject: [PATCH] hfsplus: initialize data in hfs_bnode_read_u16 and
Author: tristmd@xxxxxxxxx

From: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

hfs_bnode_read_u8

hfs_bnode_read_u16() and hfs_bnode_read_u8() declare a local variable
on the stack and pass it to hfs_bnode_read() to be filled. However,
when the requested offset is invalid (e.g. from a corrupted filesystem
image), hfs_bnode_read() returns early via the is_bnode_offset_valid()
check without writing to the buffer, leaving the local variable
uninitialized.

The callers then use the uninitialized value via be16_to_cpu() or
directly, which KMSAN flags as a use of uninitialized memory.

This is triggered during hfsplus_bnode_find() when mounting a crafted
HFS+ image with node_size=1 and invalid offsets.

Fix this by zero-initializing the local variables so that an invalid
read returns 0 rather than stack garbage.

Reported-by: syzbot+217eb327242d08197efb@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=217eb327242d08197efb
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
---
fs/hfsplus/bnode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index XXXXXXX..XXXXXXX 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -98,14 +98,14 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len)
u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off)
{
- __be16 data;
+ __be16 data = 0;
/* TODO: optimize later... */
hfs_bnode_read(node, &data, off, 2);
return be16_to_cpu(data);
}

u8 hfs_bnode_read_u8(struct hfs_bnode *node, int off)
{
- u8 data;
+ u8 data = 0;
/* TODO: optimize later... */
hfs_bnode_read(node, &data, off, 1);
return data;
--
2.43.0