Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4767500imu; Tue, 18 Dec 2018 23:13:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/V8sVP6wwdMWjLZmLMqguuzM+p4ncw9R3E/ErxDm6W6B3Qi8fYMAndy1HZ9QLJbqARze/hg X-Received: by 2002:a17:902:8641:: with SMTP id y1mr19220528plt.159.1545203612745; Tue, 18 Dec 2018 23:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545203612; cv=none; d=google.com; s=arc-20160816; b=gnvQ8XLd9Kp4GR9kcKsLLTnWmmVpvciHFjzrOLzEE8N60li1MeaojGvwW6fHfxRZ2O kdEoGGPed6zVCLZqrt5JUF8n0MP5wDnj+Cox/BJvEJsWJ3lo89dT7ie0PIT0+PqUIFna g2+B4xzBgS840ziQdKj3Bor78jlCa/eM8qkli5w43OBo5m3gBoJAe7ccgiAnGxzES9C1 JPyKpOilbZSYbpFKgDCEXDuZ9tKgfDiu/dMrYQLndVp/RdCGBkONHfmqpqx3B+cPxMWQ 8CkYD073XDzKdNOdSywO14CUh29KFdt8bTFuW1tfVuo14c5K6yNwe08OdEZ7ZFE5NbdP yyOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=wC5sFlNK5s+znGFmfu36cZnmUealzBYP3ail7Kg6IrE=; b=bJwpPGuviPr0olj+mXEK6UnDn6FQTzJZy1J4qXCzQM5v9RnBsl8CPyrYoDGVXwzND+ 7iI2PjLl6SQS94A30iUDE+IJNJwN7PXkSPPcqsHDXOzJ6cK9jbmwAoTxXZ3vL9mWkHoM Y0EoukDh4Ms8ISuCnYCYC70+XQw7YsiPXZHz/Suf+5Tt5GHY1puNyLjhhYxB9bp6JCDE 9wQVHhf57lUSuDjH4NL0/7XNIY4dES3MQZ/cpiFphWzPIYOt3C51vJVjQk5iSlstpSS1 xImYBwi+e3R1V0Sgiv2ES7VwyueMqsyWXd6MhZ8bV/SfktfucMTcfTWs8WO7OoNX5NSt UXwA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si14963907pgg.592.2018.12.18.23.13.16; Tue, 18 Dec 2018 23:13:32 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727958AbeLSGse (ORCPT + 99 others); Wed, 19 Dec 2018 01:48:34 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:34291 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727345AbeLSGse (ORCPT ); Wed, 19 Dec 2018 01:48:34 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6756EC1422DD8; Wed, 19 Dec 2018 14:48:31 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.408.0; Wed, 19 Dec 2018 14:48:22 +0800 From: YueHaibing To: , , , , CC: , , YueHaibing Subject: [PATCH net-next] xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi Date: Wed, 19 Dec 2018 14:45:09 +0800 Message-ID: <20181219064509.9804-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 4a46df8..f5b4feb 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.7.0