Skip to content

Commit f772805

Browse files
Bartekkubikgregkh
authored andcommitted
fs/ntfs3: Initialize allocated memory before use
[ Upstream commit a8a3ca2 ] 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> Signed-off-by: Li hongliang <1468888505@139.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 541959b commit f772805

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
@@ -1301,7 +1301,7 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
13011301
fa |= FILE_ATTRIBUTE_READONLY;
13021302

13031303
/* Allocate PATH_MAX bytes. */
1304-
new_de = __getname();
1304+
new_de = kmem_cache_zalloc(names_cachep, GFP_KERNEL);
13051305
if (!new_de) {
13061306
err = -ENOMEM;
13071307
goto out1;
@@ -1734,10 +1734,9 @@ int ntfs_link_inode(struct inode *inode, struct dentry *dentry)
17341734
struct NTFS_DE *de;
17351735

17361736
/* Allocate PATH_MAX bytes. */
1737-
de = __getname();
1737+
de = kmem_cache_zalloc(names_cachep, GFP_KERNEL);
17381738
if (!de)
17391739
return -ENOMEM;
1740-
memset(de, 0, PATH_MAX);
17411740

17421741
/* Mark rw ntfs as dirty. It will be cleared at umount. */
17431742
ntfs_set_state(sbi, NTFS_DIRTY_DIRTY);
@@ -1773,7 +1772,7 @@ int ntfs_unlink_inode(struct inode *dir, const struct dentry *dentry)
17731772
return -EINVAL;
17741773

17751774
/* Allocate PATH_MAX bytes. */
1776-
de = __getname();
1775+
de = kmem_cache_zalloc(names_cachep, GFP_KERNEL);
17771776
if (!de)
17781777
return -ENOMEM;
17791778

0 commit comments

Comments
 (0)