Re: [syzbot] [hfs?] KMSAN: uninit-value in hfs_iget

Edward Adam Davis
2024-09-23T14:06:45Z

When the read data is insufficient to fill the rec, use 0 to fill it

#syz test

diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c
index ef9498a6e88a..f0292b76e3d4 100644
--- a/fs/hfs/bfind.c
+++ b/fs/hfs/bfind.c
@@ -168,6 +168,8 @@ int hfs_brec_read(struct hfs_find_data *fd, void *rec, int rec_len)
if (fd->entrylength > rec_len)
return -EINVAL;
hfs_bnode_read(fd->bnode, rec, fd->entryoffset, fd->entrylength);
+ if (rec_len > fd->entrylength)
+ memset(rec + fd->entrylength, 0, rec_len - fd->entrylength);
return 0;
}