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=unavailable 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 2C02FC169C4 for ; Mon, 11 Feb 2019 15:27:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4FFA222A4 for ; Mon, 11 Feb 2019 15:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549898853; bh=jXsmAAI+28roK7WVB7kXClj5NsZLFZ0jmljTxhx0kfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jTSc7rjeiqcE1EGRWKWoF+Q/UZX6G0HW3pJE5PJ0dIcYzZXA+EkXCKJ4Pwvg35kfl sItEFJNVV7zz/szx2oQUlTa+DXXtrlfCXV2bwI+uKbhHpdVE3wNIjU0jbeSMa0qRxD S05nn8Rw1HvPLvXGRXbS2vCBVKsy+5WFJlIanqKA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729869AbfBKO7W (ORCPT ); Mon, 11 Feb 2019 09:59:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:47088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389299AbfBKO7V (ORCPT ); Mon, 11 Feb 2019 09:59:21 -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 36B00206BA; Mon, 11 Feb 2019 14:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897160; bh=jXsmAAI+28roK7WVB7kXClj5NsZLFZ0jmljTxhx0kfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GfFiaSBrRDHdNCvdEqi+pNhxKImbqszMWFqcqT3yMedftTSTSgl/nuZoB58bmljjW o7RfX5wA874sEyytxBDubKSaH2RQ84oXr2WEF2lZARKQET/Fu6cDehGoTXn27HVZRt yWnWXinE45oKMfji68X07p8GDCctpv6S5GHT5Q6w= 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.14 110/205] xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi Date: Mon, 11 Feb 2019 15:18:28 +0100 Message-Id: <20190211141835.715169794@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.14-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 4e438bc7ee87..c28e3eaad7c2 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