Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe41ad8b authored by Dongliang Mu's avatar Dongliang Mu Committed by Greg Kroah-Hartman
Browse files

ntfs: add sanity check on allocation size

[ Upstream commit 714fbf2647b1a33d914edd695d4da92029c7e7c0 ]

ntfs_read_inode_mount invokes ntfs_malloc_nofs with zero allocation
size.  It triggers one BUG in the __ntfs_malloc function.

Fix this by adding sanity check on ni->attr_list_size.

Link: https://lkml.kernel.org/r/20220120094914.47736-1-dzm91@hust.edu.cn


Reported-by: default avatar <syzbot+3c765c5248797356edaa@syzkaller.appspotmail.com>
Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
Acked-by: default avatarAnton Altaparmakov <anton@tuxera.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5a016c05
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1881,6 +1881,10 @@ int ntfs_read_inode_mount(struct inode *vi)
		}
		/* Now allocate memory for the attribute list. */
		ni->attr_list_size = (u32)ntfs_attr_size(a);
		if (!ni->attr_list_size) {
			ntfs_error(sb, "Attr_list_size is zero");
			goto put_err_out;
		}
		ni->attr_list = ntfs_malloc_nofs(ni->attr_list_size);
		if (!ni->attr_list) {
			ntfs_error(sb, "Not enough memory to allocate buffer "