Skip to content

Commit a8a3ca2

Browse files
Bartekkubikaalexandrovich
authored andcommitted
fs/ntfs3: Initialize allocated memory before use
KMSAN reports: Multiple uninitialized values detected: - KMSAN: uninit-value in ntfs_read_hdr (3) - KMSAN: uninit-value in bcmp (3) Memory is allocated by __getname(), which is a wrapper for kmem_cache_alloc(). This memory is used before being properly cleared. Change kmem_cache_alloc() to kmem_cache_zalloc() to properly allocate and clear memory before use. Fixes: 82cae26 ("fs/ntfs3: Add initialization of super block") Fixes: 78ab59f ("fs/ntfs3: Rework file operations") Tested-by: syzbot+332bd4e9d148f11a87dc@syzkaller.appspotmail.com Reported-by: syzbot+332bd4e9d148f11a87dc@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=332bd4e9d148f11a87dc Fixes: 82cae26 ("fs/ntfs3: Add initialization of super block") Fixes: 78ab59f ("fs/ntfs3: Rework file operations") Tested-by: syzbot+0399100e525dd9696764@syzkaller.appspotmail.com Reported-by: syzbot+0399100e525dd9696764@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=0399100e525dd9696764 Reviewed-by: Khalid Aziz <khalid@kernel.org> Signed-off-by: Bartlomiej Kubik <kubik.bartlomiej@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent f35590e commit a8a3ca2

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

fs/ntfs3/inode.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
12811281
fa |= FILE_ATTRIBUTE_READONLY;
12821282

12831283
/* Allocate PATH_MAX bytes. */
1284-
new_de = __getname();
1284+
new_de = kmem_cache_zalloc(names_cachep, GFP_KERNEL);
12851285
if (!new_de) {
12861286
err = -ENOMEM;
12871287
goto out1;
@@ -1723,10 +1723,9 @@ int ntfs_link_inode(struct inode *inode, struct dentry *dentry)
17231723
struct NTFS_DE *de;
17241724

17251725
/* Allocate PATH_MAX bytes. */
1726-
de = __getname();
1726+
de = kmem_cache_zalloc(names_cachep, GFP_KERNEL);
17271727
if (!de)
17281728
return -ENOMEM;
1729-
memset(de, 0, PATH_MAX);
17301729

17311730
/* Mark rw ntfs as dirty. It will be cleared at umount. */
17321731
ntfs_set_state(sbi, NTFS_DIRTY_DIRTY);
@@ -1762,7 +1761,7 @@ int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry)
17621761
return -EINVAL;
17631762

17641763
/* Allocate PATH_MAX bytes. */
1765-
de = __getname();
1764+
de = kmem_cache_zalloc(names_cachep, GFP_KERNEL);
17661765
if (!de)
17671766
return -ENOMEM;
17681767

0 commit comments

Comments
 (0)