Skip to contentSkip to conversation

fs/ntfs3: fix uninitialized memory in ni_create_attr_list()

PATCH New Swaraj Gaikwad 1 participant 1 message Oct 7, 2025 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/ntfs3: fix uninitialized memory in ni_create_attr_list()

KMSAN reported an "uninit-value" warning in attr_set_size(), which occurs when the NTFS attribute list buffer contains uninitialized trailing bytes.

In ni_create_attr_list(q), kmalloc() is used to allocate a buffer of size al_aligned(rs). However, the amount of data actually written into this buffer can be smaller than the allocated size, leaving the remaining bytes uninitialized. If those bytes are later accessed, KMSAN reports a read of uninitialized memory.

Replace kmalloc() with kzalloc() to ensure the entire buffer is zero-initialized, preventing future uninitialized memory accesses.

This issue was reproduced and verified using the syzkaller-provided reproducer. The patch was tested by:
- Building the kernel to ensure the change does not affect the build process.
- Running the provided repro to confirm that the uninit-value warning no longer appears.

Based on commit: 9b0d551bcc05

---
 fs/ntfs3/frecord.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/frecord.c +1 -1
index 8f9fe1d7a690..4fe8da7fc034 100644
@@ -767,7 +767,7 @@ int ni_create_attr_list(struct ntfs_inode *ni)
 	 * Skip estimating exact memory requirement.
 	 * Looks like one record_size is always enough.
 	 */
-	le = kmalloc(al_aligned(rs), GFP_NOFS);
+	le = kzalloc(al_aligned(rs), GFP_NOFS);
 	if (!le)
 		return -ENOMEM;
 
Signature · 1 line
2.51.0