Re: [syzbot] [hfs?] KMSAN: uninit-value in hfs_iget
From: Edward Adam Davis
Date: Mon Sep 23 2024 - 10:06:58 EST
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;
}