Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2443306pxu; Mon, 7 Dec 2020 06:50:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJydM/2NEe5wHG+pYKiDPqlvZDB9ov9XMEi5MnkbhGJdEerXqxBL+Xid62bMEh7ZP8pZ8rwd X-Received: by 2002:a05:6402:b57:: with SMTP id bx23mr19992806edb.191.1607352621248; Mon, 07 Dec 2020 06:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607352621; cv=none; d=google.com; s=arc-20160816; b=Dtm6LNFIbysDgc4E4xI+qk5CUFqLTx1W3TOwGiwYFLxVAcs9SHEBLwbf/lIuSrYH25 pg9OnBSjhOpmiLrnJJBFngUXhW3E7rJm7UhPooszbZbdrF2otgU4338VjYbztqIHnNeY VnKBN3kYQBye1mZXKWVk1xEjBBLncwsdaxf8VKCUd5jgX0Bty65yLJAbDBL+kvwcVm6f MrG9mUyOxSuAB9pW1+QQVBpaof9DBgSSL3TE7jdGgNxrFKBEsheKCbHP5uPiwwbnRvPo TTUpfHLeiIAypglMggpgfaAxSwMWmS0Hjo3gJbY6OI63pIYm0g/g1Gb2wVq3GSv7lYBd cmaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=g6Cpwt/wmIU4I9BwH5sghzhjB0OaEqtt/xe5CRhlkuE=; b=FgxV6Oh5eD+vtaabm1lOcyvY7+sKXSZFgj68Y013ajfPbA0pxf+Fwt+S7P23IP0+lS 72Q3GxvW5xGWENrQJHF0ULgU7CHeNkkZnOYVzgKvzauFu8M2Gv9cULpId6gX4wX+V5mN cb0v7qRcl1VV1+jZprFeYliMu2RkaXEE2io5shjlPe3x7eQVH+b1KVZLT8jvXs3kT60r lnMyDVkm3NvGfq/kDcoKm9wypp0RX/bQW0uOjnWt+hW7YQUELsY9BJ6q9P3wJ5XItrA1 lTTINT3banoNIgQ/5WCAW3ZbqUfBDbBoSs1as/KgCoTGIYEKo711DxzDsa2LZ/7wuTcy O8ng== 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 y1si8029425edm.279.2020.12.07.06.49.56; Mon, 07 Dec 2020 06:50:21 -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 S1726402AbgLGOqG (ORCPT + 99 others); Mon, 7 Dec 2020 09:46:06 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:37219 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgLGOqG (ORCPT ); Mon, 7 Dec 2020 09:46:06 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kmHl9-0004iu-HP; Mon, 07 Dec 2020 14:45:03 +0000 From: Colin King To: "David S . Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Jakub Kicinski , Andrea Mayer , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] seg6: fix unintentional integer overflow on left shift Date: Mon, 7 Dec 2020 14:45:03 +0000 Message-Id: <20201207144503.169679-1-colin.king@canonical.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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