Skip to content

Commit

Permalink
fs/ntfs3: Harden against integer overflows
Browse files Browse the repository at this point in the history
[ Upstream commit e001e60 ]

Smatch complains that the "add_bytes" is not to be trusted.  Use
size_add() to prevent an integer overflow.

Fixes: be71b5c ("fs/ntfs3: Add attrib operations")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Dec 31, 2022
1 parent 95afb46 commit b259e31
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ntfs3/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
return -EFBIG;

/* Allocate memory for packed Ea. */
ea_p = kmalloc(size + add_bytes, GFP_NOFS);
ea_p = kmalloc(size_add(size, add_bytes), GFP_NOFS);
if (!ea_p)
return -ENOMEM;

Expand Down

0 comments on commit b259e31

Please sign in to comment.