Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2720931imj; Mon, 11 Feb 2019 07:29:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IYSaovYqYWc5hQfk2KtqiCikWcgJZkzxWAta4008PPGsD3ADZQk1+1pneZ6LY//75X82XtY X-Received: by 2002:a63:cc41:: with SMTP id q1mr18847261pgi.323.1549898988754; Mon, 11 Feb 2019 07:29:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549898988; cv=none; d=google.com; s=arc-20160816; b=f0NwrQ0uZJzgifUrKscWPBRQPO52trcUfJFbg0RMB6p3JpxPelk+TAAk8OEW/eC+eP XRW7GNPsukC5adAGsb9urvqPBBpfjMqPigRG2YRKwOy08gc9WHBx4T1zphXSZzCh+rBu V/Il2m+G6/QYxB8MSJdBKvOw5WtmAdT+UibC9bX4DDK53Lk12w7sudGVN+y9mMo2rmqi xOVlIhaw0MVN5dxVFlyJfpdYUfNhqEoHoQiZfIJgP2PDOOKTnTdL5dadMQ6qqLYd6qRk +FF+GkIi/ANOCS63Gtn5eauZifXfE631M0gJng9Na4aTKneycVOEYdE1K/v/Y1Vav+4I Rntw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m8MY8z1o4pJO8eXPtLkykCariaBmnZt73oJFHukYGtc=; b=b1ksr4YxV8LGYi9Oj1eXsJjPE122DXzVNy4P9ZKQGIEYkjxcx/KW1NS3vZhDKy087Q 209hwCt0DUom9Iny5r+mD+kwtYj+fRnYRWzOnDQB/tF+tNByABPzzHDuOEw7eXF8LaAy yArT7CsRYZRxDziOsZaaGT0P3Ch1F86I2nbDlrtO+BR/7B/lJcncVyVbMJNJ7TKs6LYR Tjmp3H02ReJfAVadj8QFO8yViAyfX1QdENvjk6anQmGyVbGgn0UfUxs+9MHTmwoSeKwa tuBRHEoxJDJs1GjfbEpZlMyvZKojj/D0cE7mxsws5l/G+Uuz608RR17a8CaEAxShJusd z5Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GfFiaSBr; 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 k69si7749769pga.176.2019.02.11.07.29.32; Mon, 11 Feb 2019 07:29:48 -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=GfFiaSBr; 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 S2389781AbfBKO7W (ORCPT + 99 others); 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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