From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C529C282CE for ; Mon, 11 Feb 2019 14:47:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0267206BA for ; Mon, 11 Feb 2019 14:47:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896429; bh=cj8MZOZJr4HEICSi2dIFnqHM8iW4A96UFIcgEqaT3xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fMsjCAMHE6ZXAZsCYn4BMbM7nSQqcLioDG8gLf7A/7Hq7rqxD+FwFMCS0G1qlVAR3 aTkfdz1jULCBAQ2DV8o+HICxye4BSPcVwKzIRMWOhVyoZdhAEKM4THIj+9ydn+9h4z 6OioRiI7/n/sKF8p71im/Y0wgt1lqOYyIxdmDGxI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387469AbfBKOrH (ORCPT ); Mon, 11 Feb 2019 09:47:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:60320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732327AbfBKOrF (ORCPT ); Mon, 11 Feb 2019 09:47:05 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 075FC206BA; Mon, 11 Feb 2019 14:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896424; bh=cj8MZOZJr4HEICSi2dIFnqHM8iW4A96UFIcgEqaT3xw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E2ZJDMOlVneLS4ckXiZJepMBYMBZPGrli0Uba302hzNNKtJ6l+0+2DMD9ZqwXYMyx 5BJzugkkFo6s4yFyz0yLObro/zcAO3xps7tHwMrQo8XWVgc5iWRd6isxjZ8V6NStid 8zrQPA01z1Oiu0KlbQWBIxASYAXzTqXtFIAKMC8E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YueHaibing , Steffen Klassert , Sasha Levin Subject: [PATCH 4.19 179/313] xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi Date: Mon, 11 Feb 2019 15:17:39 +0100 Message-Id: <20190211141905.290165563@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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