Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3632630imu; Mon, 28 Jan 2019 08:09:30 -0800 (PST) X-Google-Smtp-Source: ALg8bN5m+niPtCb2DUrzJpTHzY7oB9CeKH5rxMh7VrXYpsBXZDQa1X+aNnRTc86HclA1oLzHmVsH X-Received: by 2002:a63:e655:: with SMTP id p21mr20139606pgj.70.1548691770203; Mon, 28 Jan 2019 08:09:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691770; cv=none; d=google.com; s=arc-20160816; b=a1Q+A5BphMNrggX/fP/bIfehhcPi7zbVNSbFs3FywHPIwPnPGvVhbXkTx+EmPufAFt jV2lytswsI5mMWK1OlhuAHAvwQ4Q79WxMrvPn0XotX43QsHl5t53JKePXZS6T+GCQ/Pb 8YLQoT0Nu4zfZvcnNeXizf5Lqc5/F65d2NiiiGnrz4Jazk+uaWNyy/8wJ9p6CRMvl1B1 gXhpH11Nj9yVGZQQLNtusOpPS5kjY47N0dWtWH5ZsyIZGZfG+7hy1ZloTc9XryczFQlC 6Yt5Yub2wOn6n+i4ZvTVKM7w7hEO5vwBibaARiOZnq/WvK9C+ZkUcWtC3Rh96Zk3dVMo 8vcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J+bo+/DWJ2W49bjugHV/30wqC2AVAmWAJf+oRWWEb9k=; b=O9tAfJIC1SrWGeIRRvdMG2lOpHnX6qElnpgN2zp5tKlfFgsV928P/J1QEKCh3Q5fmL o2aQsxZVOQyTb68EbrIiqY3ZoUSDEBfUN1msNnortU3pptyVjC0HMF94Wlge3QXF5y0P lCHSPFVkJvKV1BM1Ooa5+2Adqgh3CA0RfIxW+6QYsjcSE8dB/lEkUEo0Ec78/Nlq4VS0 XV+jbSyzT5OYmzNwfoRxBTFher8q5Wfx7HwYuAr1QHpUy7SJ/ekR2YcebMos7phaI6pO rljT1Kmv+49z5t0ET7xVB87CEWTE810SbKZLtaXNZUElncS0XSATYEN7BnLK6Zop9nXM UnDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v8dGxHtw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c65si934825pfe.202.2019.01.28.08.09.14; Mon, 28 Jan 2019 08:09:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v8dGxHtw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732368AbfA1QIT (ORCPT + 99 others); Mon, 28 Jan 2019 11:08:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:59912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731657AbfA1QIR (ORCPT ); Mon, 28 Jan 2019 11:08:17 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61E082147A; Mon, 28 Jan 2019 16:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691696; bh=ykK6lt5DzOxm1hmRB2Hc0Scf09320B413nuDFoqo9AA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v8dGxHtwmZdemjzL4py/yiNw2Ct97mkaxtTbTT6VWp/bbZQBL5jediC1nkiDPt/gu T0aqsTab147wjVxdQ+Vuh9fmCCAeazOY5jqHvZ8R7KjQQXVvg/kI6Ct8CQjvOV087z lpjBqwia8y9mJ0hjAphAfKhido04pEH6fE5R7oFk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: YueHaibing , Steffen Klassert , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 188/258] xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi Date: Mon, 28 Jan 2019 10:58:14 -0500 Message-Id: <20190128155924.51521-188-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: YueHaibing [ Upstream commit fa89a4593b927b3f59c3b69379f31d3b22272e4e ] gcc warn this: net/ipv6/xfrm6_tunnel.c:143 __xfrm6_tunnel_alloc_spi() warn: always true condition '(spi <= 4294967295) => (0-u32max <= u32max)' 'spi' is u32, which always not greater than XFRM6_TUNNEL_SPI_MAX because of wrap around. So the second forloop will never reach. Signed-off-by: YueHaibing Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/ipv6/xfrm6_tunnel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c index 4a46df8441c9..f5b4febeaa25 100644 --- a/net/ipv6/xfrm6_tunnel.c +++ b/net/ipv6/xfrm6_tunnel.c @@ -144,6 +144,9 @@ static u32 __xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr) index = __xfrm6_tunnel_spi_check(net, spi); if (index >= 0) goto alloc_spi; + + if (spi == XFRM6_TUNNEL_SPI_MAX) + break; } for (spi = XFRM6_TUNNEL_SPI_MIN; spi < xfrm6_tn->spi; spi++) { index = __xfrm6_tunnel_spi_check(net, spi); -- 2.19.1