linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Mayer <andrea.mayer@uniroma2.it>
To: Colin King <colin.king@canonical.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Stefano Salsano <stefano.salsano@uniroma2.it>,
	Paolo Lungaroni <paolo.lungaroni@cnit.it>,
	Ahmed Abdelsalam <ahabdels.dev@gmail.com>,
	Andrea Mayer <andrea.mayer@uniroma2.it>
Subject: Re: [PATCH][next] seg6: fix unintentional integer overflow on left shift
Date: Mon, 7 Dec 2020 20:59:26 +0100	[thread overview]
Message-ID: <20201207205926.6222eca38744c43632248a41@uniroma2.it> (raw)
In-Reply-To: <20201207144503.169679-1-colin.king@canonical.com>

On Mon,  7 Dec 2020 14:45:03 +0000
Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Shifting the integer value 1 is evaluated using 32-bit arithmetic
> and then used in an expression that expects a unsigned long value
> leads to a potential integer overflow. Fix this by using the BIT
> macro to perform the shift to avoid the overflow.
> 
> Addresses-Coverity: ("Uninitentional integer overflow")
> Fixes: 964adce526a4 ("seg6: improve management of behavior attributes")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  net/ipv6/seg6_local.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index b07f7c1c82a4..d68de8cd1207 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -1366,7 +1366,7 @@ static void __destroy_attrs(unsigned long parsed_attrs, int max_parsed,
>  	 * attribute; otherwise, we call the destroy() callback.
>  	 */
>  	for (i = 0; i < max_parsed; ++i) {
> -		if (!(parsed_attrs & (1 << i)))
> +		if (!(parsed_attrs & BIT(i)))
>  			continue;
>  
>  		param = &seg6_action_params[i];
> -- 
> 2.29.2
>

Hi Colin,
thanks for the fix. I've just given a look a the whole seg6_local.c code and I
found that such issues is present in other parts of the code.

If we agree, I can make a fix which explicitly eliminates the several (1 << i)
in favor of BIT(i).

Andrea

  reply	other threads:[~2020-12-07 20:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 14:45 [PATCH][next] seg6: fix unintentional integer overflow on left shift Colin King
2020-12-07 19:59 ` Andrea Mayer [this message]
2020-12-07 20:44   ` Colin Ian King

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=20201207205926.6222eca38744c43632248a41@uniroma2.it \
    --to=andrea.mayer@uniroma2.it \
    --cc=ahabdels.dev@gmail.com \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paolo.lungaroni@cnit.it \
    --cc=stefano.salsano@uniroma2.it \
    --cc=yoshfuji@linux-ipv6.org \
    /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;
as well as URLs for NNTP newsgroup(s).