]> git.itanic.dy.fi Git - linux-stable/commitdiff
fs/ntfs3: Fix an NULL dereference bug
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 17 Oct 2023 14:04:39 +0000 (17:04 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 29 Jan 2024 09:05:08 +0000 (12:05 +0300)
The issue here is when this is called from ntfs_load_attr_list().  The
"size" comes from le32_to_cpu(attr->res.data_size) so it can't overflow
on a 64bit systems but on 32bit systems the "+ 1023" can overflow and
the result is zero.  This means that the kmalloc will succeed by
returning the ZERO_SIZE_PTR and then the memcpy() will crash with an
Oops on the next line.

Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/ntfs_fs.h

index 81f7563428ee02cb627bb052bbeea7b7bdfa141a..627419bd6f7782e66375281f467a60b7f51e65f6 100644 (file)
@@ -475,7 +475,7 @@ bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
 int al_update(struct ntfs_inode *ni, int sync);
 static inline size_t al_aligned(size_t size)
 {
-       return (size + 1023) & ~(size_t)1023;
+       return size_add(size, 1023) & ~(size_t)1023;
 }
 
 /* Globals from bitfunc.c */