From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Colin King <colin.king@canonical.com>,
Tino Reichardt <milky-kernel@mcmilk.de>,
jfs-discussion@lists.sourceforge.net
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/jfs: fix potential integer overflow on shift of a int
Date: Tue, 9 Feb 2021 10:52:32 -0600 [thread overview]
Message-ID: <044b0372-8612-6fb9-23c5-9c4e6ab79114@oracle.com> (raw)
In-Reply-To: <20210205171137.208121-1-colin.king@canonical.com>
On 2/5/21 11:11 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.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@canonical.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);
I'm not sure I like the use of this macro here. It seems to imply a bit
flag of some sort. I think it would be clearer to use
nblocks = 1ULL << l2nb;
Maybe 1LL rather than 1ULL since nblocks is s64.
> } else {
> /* Trim any already allocated blocks */
> jfs_error(bmp->db_ipbmap->i_sb, "-EIO\n");
>
prev parent reply other threads:[~2021-02-09 16:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-05 17:11 Colin King
2021-02-09 16:52 ` Dave Kleikamp [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=044b0372-8612-6fb9-23c5-9c4e6ab79114@oracle.com \
--to=dave.kleikamp@oracle.com \
--cc=colin.king@canonical.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=milky-kernel@mcmilk.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®