[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210205171137.208121-1-colin.king@canonical.com>
Date: Fri, 5 Feb 2021 17:11:37 +0000
From: Colin King <colin.king@...onical.com>
To: Dave Kleikamp <shaggy@...nel.org>,
Tino Reichardt <milky-kernel@...ilk.de>,
jfs-discussion@...ts.sourceforge.net
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] fs/jfs: fix potential integer overflow on shift of a int
From: Colin Ian King <colin.king@...onical.com>
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
using the BIT_ULL macro instead.
Addresses-Coverity: ("Uninitentional integer overflow")
Fixes: b40c2e665cd5 ("fs/jfs: TRIM support for JFS Filesystem")
Signed-off-by: Colin Ian King <colin.king@...onical.com>
---
fs/jfs/jfs_dmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index 94b7c1cb5ceb..47dbca7e52e0 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -1656,7 +1656,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
} else if (rc == -ENOSPC) {
/* search for next smaller log2 block */
l2nb = BLKSTOL2(nblocks) - 1;
- nblocks = 1 << l2nb;
+ nblocks = BIT_ULL(l2nb);
} else {
/* Trim any already allocated blocks */
jfs_error(bmp->db_ipbmap->i_sb, "-EIO\n");
--
2.29.2
Powered by blists - more mailing lists