Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2686010pxu; Mon, 7 Dec 2020 12:49:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlPdSRVSOipQI0I//zRvc36K3DRA3JJVyDEbmzGb0txXmZolS7Dp8yAhgQ5egxJ6wQjDS1 X-Received: by 2002:a17:906:e24f:: with SMTP id gq15mr19218591ejb.256.1607374145239; Mon, 07 Dec 2020 12:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607374145; cv=none; d=google.com; s=arc-20160816; b=MefkvJqJSgY8Y1A9Z5i4NWh1vvSbXF4VKgwrzeUKtVLFfKQsUx07bu0dFXtiV7boh5 csAVOzifPvzWl40w2BVwSEVf1ZHCoCChgfF6NlwR+G990isHOWvm22o/lI5w84CkdeUy C7GRtG7U3qPHraQj+VTdolkIRfhh4zQ1Apa5hQH49aFgdzcVhAqAO5tgOHsWh2Dzwvut ANbYTkeXWb0d94I6mDGSLxj7Wu/KslMS/vVyiLz9ZGc+tiNyoFSnyYeGCBieDHZLFjK1 FSORpN33FZ4D3Y7ltnAPg0UQG+k/sUS5O6lg04Z57bEyLJIXg86qgQq7CxLrCJApFslt EiaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=OSfZgZaiiQrpWzvjZ0LVUSjTYBixCvpIQkWIv3hNfqE=; b=BaX7dXjj4mpQemShyq8fgnxrpSIfiSphSLCeCKO1v1PfRHSJhyu/LIv1D6PO3020iX PE4khMQXavRvkVf0RU3IRMX6n0b1IIckFQnVRpAHsRS0mk04sKHw17AyS6bM9l5UUAkn lhHwaRXD8ExP4BlyanUb5Km8XKcmZM2k5JnyGLSI/ouCjmT8o7md7oDGgu7tAPHAWTO4 pKWHlQlESM8/NtNPbAPeA5ghRS6udhXjs3z/IjeAHycaOCA7f6NKfclbW7TF2PTrwDGR B0Jlsdv7b+OO7VPPcvbL0/zAhTmUjEYzQol9B5cdv+jTwIF2Za3LcdhQWWX1eW+7KQaO nbDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 1si8972267edv.426.2020.12.07.12.48.33; Mon, 07 Dec 2020 12:49:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbgLGUo4 (ORCPT + 99 others); Mon, 7 Dec 2020 15:44:56 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:47437 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgLGUoz (ORCPT ); Mon, 7 Dec 2020 15:44:55 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kmNMg-0004h9-5f; Mon, 07 Dec 2020 20:44:10 +0000 Subject: Re: [PATCH][next] seg6: fix unintentional integer overflow on left shift To: Andrea Mayer Cc: "David S . Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Jakub Kicinski , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Stefano Salsano , Paolo Lungaroni , Ahmed Abdelsalam References: <20201207144503.169679-1-colin.king@canonical.com> <20201207205926.6222eca38744c43632248a41@uniroma2.it> From: Colin Ian King Message-ID: Date: Mon, 7 Dec 2020 20:44:09 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201207205926.6222eca38744c43632248a41@uniroma2.it> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/12/2020 19:59, Andrea Mayer wrote: > On Mon, 7 Dec 2020 14:45:03 +0000 > Colin King wrote: > >> From: Colin Ian King >> >> 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 >> --- >> 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). Sounds good to me. Colin > > Andrea >