#syz test
diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index 6add6ebfef89..e8d7431ce178 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -15,7 +15,7 @@
#include "btree.h"
-void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len)
+int hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len)
{
struct page *page;
int pagenum;
@@ -37,13 +37,16 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len)
pagenum++;
off = 0; /* page offset only applies to the first page */
}
+
+ return bytes_to_read;
}
u16 hfs_bnode_read_u16(struct hfs_bnode *node, int off)
{
- __be16 data;
+ __be16 data = 0;
// optimize later...
- hfs_bnode_read(node, &data, off, 2);
+ if(hfs_bnode_read(node, &data, off, 2) < sizeof(u16))
+ return 0;
return be16_to_cpu(data);
}
diff --git a/fs/hfs/btree.h b/fs/hfs/btree.h
index 0e6baee93245..54f310c52643 100644
--- a/fs/hfs/btree.h
+++ b/fs/hfs/btree.h
@@ -94,7 +94,7 @@ extern struct hfs_bnode * hfs_bmap_alloc(struct hfs_btree *);
extern void hfs_bmap_free(struct hfs_bnode *node);
/* bnode.c */
-extern void hfs_bnode_read(struct hfs_bnode *, void *, int, int);
+extern int hfs_bnode_read(struct hfs_bnode *, void *, int, int);
extern u16 hfs_bnode_read_u16(struct hfs_bnode *, int);
extern u8 hfs_bnode_read_u8(struct hfs_bnode *, int);
extern void hfs_bnode_read_key(struct hfs_bnode *, void *, int);
--
Hello, syzbot has tested the proposed patch and the reproducer did not trigger any issue: Reported-by: syzbot+5405d1265a66aa313343@syzkaller.appspotmail.com Tested-by: syzbot+5405d1265a66aa313343@syzkaller.appspotmail.com Tested on: commit: fc96b232 Merge tag 'pci-v6.15-fixes-2' of git://git.ke.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=132614cc580000 kernel config: https://syzkaller.appspot.com/x/.config?x=a27b81e0cf56c60b dashboard link: https://syzkaller.appspot.com/bug?extid=5405d1265a66aa313343 compiler: Debian clang version 15.0.6, Debian LLD 15.0.6 patch: https://syzkaller.appspot.com/x/patch.diff?x=112aa204580000 Note: testing is done by a robot and is best-effort only.
© 2016 - 2025 Red Hat, Inc.