Skip to content

Commit aefe207

Browse files
Colin Ian Kinggregkh
authored andcommitted
fs/ufs: avoid potential u32 multiplication overflow
[ Upstream commit 88b2e9b ] The 64 bit ino is being compared to the product of two u32 values, however, the multiplication is being performed using a 32 bit multiply so there is a potential of an overflow. To be fully safe, cast uspi->s_ncg to a u64 to ensure a 64 bit multiplication occurs to avoid any chance of overflow. Fixes: f3e2a52 ("ufs: NFS support") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Evgeniy Dushistov <dushistov@mail.ru> Cc: Alexey Dobriyan <adobriyan@gmail.com> Link: http://lkml.kernel.org/r/20200715170355.1081713-1-colin.king@canonical.com Addresses-Coverity: ("Unintentional integer overflow") Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9f3fb90 commit aefe207

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/ufs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gene
100100
struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
101101
struct inode *inode;
102102

103-
if (ino < UFS_ROOTINO || ino > uspi->s_ncg * uspi->s_ipg)
103+
if (ino < UFS_ROOTINO || ino > (u64)uspi->s_ncg * uspi->s_ipg)
104104
return ERR_PTR(-ESTALE);
105105

106106
inode = ufs_iget(sb, ino);

0 commit comments

Comments
 (0)