Commit 4208c398 authored by Colin Ian King's avatar Colin Ian King Committed by Dave Kleikamp

fs/jfs: fix potential integer overflow on shift of a int

The left shift of int 32 bit integer constant 1 is evaluated using 32 bit
arithmetic and then assigned to a signed 64 bit integer. In the case where
l2nb is 32 or more this can lead to an overflow.  Avoid this by shifting
the value 1LL instead.

Addresses-Coverity: ("Uninitentional integer overflow")
Fixes: b40c2e66 ("fs/jfs: TRIM support for JFS Filesystem")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
parent 093e0687
...@@ -1656,7 +1656,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen) ...@@ -1656,7 +1656,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
} else if (rc == -ENOSPC) { } else if (rc == -ENOSPC) {
/* search for next smaller log2 block */ /* search for next smaller log2 block */
l2nb = BLKSTOL2(nblocks) - 1; l2nb = BLKSTOL2(nblocks) - 1;
nblocks = 1 << l2nb; nblocks = 1LL << l2nb;
} else { } else {
/* Trim any already allocated blocks */ /* Trim any already allocated blocks */
jfs_error(bmp->db_ipbmap->i_sb, "-EIO\n"); jfs_error(bmp->db_ipbmap->i_sb, "-EIO\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment