[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251007134008.144590-1-swarajgaikwad1925@gmail.com>
Date: Tue, 7 Oct 2025 13:40:07 +0000
From: Swaraj Gaikwad <swarajgaikwad1925@...il.com>
To: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>,
ntfs3@...ts.linux.dev (open list:NTFS3 FILESYSTEM),
linux-kernel@...r.kernel.org (open list)
Cc: skhan@...uxfoundation.org,
david.hunter.linux@...il.com,
Swaraj Gaikwad <swarajgaikwad1925@...il.com>,
syzbot+83c9dd5c0dcf6184fdbf@...kaller.appspotmail.com
Subject: [PATCH] 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
Reported-by: syzbot+83c9dd5c0dcf6184fdbf@...kaller.appspotmail.com
Tested-by: Swaraj Gaikwad <swarajgaikwad1925@...il.com>
Signed-off-by: Swaraj Gaikwad <swarajgaikwad1925@...il.com>
---
fs/ntfs3/frecord.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 8f9fe1d7a690..4fe8da7fc034 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -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;
--
2.51.0
Powered by blists - more mailing lists