Skip to contentSkip to conversation

hfsplus: fix uninit-value in hfsplus_rename_cat

PATCH New Tristan Madani 1 participant 1 message Apr 18 Hfsplus filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hfsplus: fix uninit-value in hfsplus_rename_cat

From: Tristan Madani <[email protected]>

hfsplus_rename_cat() uses subfolder counts from the on-disk record without zero-initializing the destination buffer when the else branch is taken. This leads to KMSAN-detected use of uninitialized memory.

Zero-initialize the relevant fields in the else branch to prevent reading uninitialized data.

Reported-by [email protected]
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 fs/hfsplus/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/hfsplus/inode.c +2 -0
index d05891ec492e3..356847ab3abf2 100644
@@ -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;
Signature · 1 line
2.47.3