Forwarded: Re: [syzbot] KMSAN: uninit-value in hfsplus_cat_read_inode

syzbot posted 1 patch 1 month, 4 weeks ago
fs/hfsplus/inode.c | 2 ++
1 file changed, 2 insertions(+)
Forwarded: Re: [syzbot] KMSAN: uninit-value in hfsplus_cat_read_inode
Posted by syzbot 1 month, 4 weeks ago
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: Re: [syzbot] KMSAN: uninit-value in hfsplus_cat_read_inode
Author: tristmd@gmail.com

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>From c548b434d782cb365bfeae52c7278548b16d6e85 Mon Sep 17 00:00:00 2001
From: Tristan Madani <tristan@talencesecurity.com>
Date: Fri, 17 Apr 2026 16:15:17 +0000
Subject: [PATCH] hfsplus: initialize subfolders field when HAS_FOLDER_COUNT is
 not set
hfsplus_cat_read_inode() only initializes the subfolders field when
the HFSPLUS_HAS_FOLDER_COUNT flag is set. When it is not set, the
field retains stale data from previous use, which KMSAN detects as
uninit-value during rename operations.
Add an else branch to zero-initialize subfolders when the flag is
not set.
Reported-by: syzbot+93f4402297a457fc6895@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=93f4402297a457fc6895
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
 fs/hfsplus/inode.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index d05891e..356847a 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -592,6 +592,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
 		if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
 			HFSPLUS_I(inode)->subfolders =
 				be32_to_cpu(folder->subfolders);
+		} else {
+			HFSPLUS_I(inode)->subfolders = 0;
 		}
 		inode->i_op = &hfsplus_dir_inode_operations;
 		inode->i_fop = &hfsplus_dir_operations;
-- 
2.47.3