diff options
| author | Colin Ian King <colin.king@canonical.com> | 2020-08-11 18:35:53 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-08-21 13:07:42 +0200 |
| commit | f1162563717a5e5ee71b2114f3bb0c4d6b02c69a (patch) | |
| tree | 7fca0555bbd9cbaa080ff40ff3d7d1083f2e652c | |
| parent | 3a1af802a4fcf172e10580cd60faf3b7d257d80f (diff) | |
| download | linux-f1162563717a5e5ee71b2114f3bb0c4d6b02c69a.tar.gz linux-f1162563717a5e5ee71b2114f3bb0c4d6b02c69a.tar.bz2 linux-f1162563717a5e5ee71b2114f3bb0c4d6b02c69a.zip | |
fs/ufs: avoid potential u32 multiplication overflow
[ Upstream commit 88b2e9b06381551b707d980627ad0591191f7a2d ]
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: f3e2a520f5fb ("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>
| -rw-r--r-- | fs/ufs/super.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 1da0be667409..e3b69fb280e8 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -101,7 +101,7 @@ static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gene struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; struct inode *inode; - if (ino < UFS_ROOTINO || ino > uspi->s_ncg * uspi->s_ipg) + if (ino < UFS_ROOTINO || ino > (u64)uspi->s_ncg * uspi->s_ipg) return ERR_PTR(-ESTALE); inode = ufs_iget(sb, ino); |
