Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/ntfs3: fix KMSAN uninit-value in ni_create_attr_list

The call to kmalloc() to allocate the attribute list buffer is given a
size of al_aligned(rs). This size can be larger than the data
subsequently copied into the buffer, leaving trailing bytes uninitialized.

This can trigger a KMSAN "uninit-value" warning if that memory is
later accessed.

Fix this by using kzalloc() instead, which ensures the entire
allocated buffer is zero-initialized, preventing the warning.

Reported-by: syzbot+83c9dd5c0dcf6184fdbf@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=83c9dd5c0dcf6184fdbf
Signed-off-by: Nirbhay Sharma <nirbhay.lkd@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>

authored by

Nirbhay Sharma and committed by
Konstantin Komarov
5f33da04 be99c62a

+1 -1
+1 -1
fs/ntfs3/frecord.c
··· 767 767 * Skip estimating exact memory requirement. 768 768 * Looks like one record_size is always enough. 769 769 */ 770 - le = kmalloc(al_aligned(rs), GFP_NOFS); 770 + le = kzalloc(al_aligned(rs), GFP_NOFS); 771 771 if (!le) 772 772 return -ENOMEM; 773 773