Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4232711ybb; Tue, 7 Apr 2020 03:29:42 -0700 (PDT) X-Google-Smtp-Source: APiQypIidbzuKD861SQaT5g37LjrcAQZ8uNXp4nTw6tvjhsV5per0PYcK0dgXG6GJmrLkyb4p3Dg X-Received: by 2002:aca:bac1:: with SMTP id k184mr1103272oif.157.1586255382463; Tue, 07 Apr 2020 03:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586255382; cv=none; d=google.com; s=arc-20160816; b=LwcD62LSe4nd7BqWS8RgwunJrQASw7o6menL/nnC2SUo7C/KLBCv6Ur6vO7kHxgf0c ILGxwabv/+nQBABGX3OTaLGvS20UT/HWDVDpFLER9qodqbr3Shk+pU7C+prohVGayZ7/ 7cHjfkd/D1Nx7+FQNjvDzXboPcgtCzMMUJJ6/sH20KDbBbozQG4AWRwtbl7+fX1DylKI kqPjLgvFXRMl5jD2ZzPra6m8ceLKyfeAoLoP8rOPpF7h2SRDpGqWQqcocQ7TIDyvUNlC bq0YA+OYRehG6X99PemJ3oSWASBFfof3qYlaXUGWak6Hc+ZgPro7k0/0REGMGzbALCYT CTVA== 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=3DCcMmOxQ8bxO2sVypGjR+bz00UEZzibPxWFwxzhYtM=; b=IhNmJ18X+5PyaUEkrgTQFScYj9b7cy7XnW9maCDgfcuJdiLu+3okeWC8jUsxKyOEI4 K1P3hkbA7i3xM1QVzsLeco+Kt+LkEFhfy9NwXAMiNzIg59NP/6qHLUj/+t0ZX5gpqEc7 vCCI4mjd4/XagBdL/kweblcjw1H6tDJYZZ8E1J69WqmFzBjb0Uv+m+mImE64473+05ib WzV9cOJlwt2PouGnSIT/OHTyv3GMniJRXNYuxME7OcFeTc2UbqcioNMSaEzNuQ1VfcIy 6K2eMa4747PKqCFfsrGeKfmE77dQASKm4I6fevdVYl2tRhAvtMCOurfUA4vgGyMgf4xe 3G8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uMG3VH7S; 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 l19si1003836otp.119.2020.04.07.03.29.30; Tue, 07 Apr 2020 03:29:42 -0700 (PDT) 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=uMG3VH7S; 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 S1728834AbgDGKY5 (ORCPT + 99 others); Tue, 7 Apr 2020 06:24:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728829AbgDGKY4 (ORCPT ); Tue, 7 Apr 2020 06:24:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 8BA4220644; Tue, 7 Apr 2020 10:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586255095; bh=+9/waoq6urivDfNZvIaeIMosuJ6pHCmjRRVUUlB8Uig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uMG3VH7ScGv6b/gxvFtk1sCnJhMJ2BD+vZKMQmi0YuMCQhbVZgiio42W3oEeWNGhP yRg8lnVLycIxMODYDvub/c8+Z0BJBUZsLTx252fe/gLfpjjGh0holGH6xfrveKtbaR HXF9DIe5GC7Ta3Ro7tvBFNRfFT2Vn2a6Hq2LEsoU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, William Dauchy , Nicolas Dichtel , "David S. Miller" Subject: [PATCH 5.5 03/46] net, ip_tunnel: fix interface lookup with no key Date: Tue, 7 Apr 2020 12:21:34 +0200 Message-Id: <20200407101459.875071972@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200407101459.502593074@linuxfoundation.org> References: <20200407101459.502593074@linuxfoundation.org> User-Agent: quilt/0.66 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 From: William Dauchy [ Upstream commit 25629fdaff2ff509dd0b3f5ff93d70a75e79e0a1 ] when creating a new ipip interface with no local/remote configuration, the lookup is done with TUNNEL_NO_KEY flag, making it impossible to match the new interface (only possible match being fallback or metada case interface); e.g: `ip link add tunl1 type ipip dev eth0` To fix this case, adding a flag check before the key comparison so we permit to match an interface with no local/remote config; it also avoids breaking possible userland tools relying on TUNNEL_NO_KEY flag and uninitialised key. context being on my side, I'm creating an extra ipip interface attached to the physical one, and moving it to a dedicated namespace. Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.") Signed-off-by: William Dauchy Signed-off-by: Nicolas Dichtel Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_tunnel.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -142,11 +142,8 @@ struct ip_tunnel *ip_tunnel_lookup(struc cand = t; } - if (flags & TUNNEL_NO_KEY) - goto skip_key_lookup; - hlist_for_each_entry_rcu(t, head, hash_node) { - if (t->parms.i_key != key || + if ((!(flags & TUNNEL_NO_KEY) && t->parms.i_key != key) || t->parms.iph.saddr != 0 || t->parms.iph.daddr != 0 || !(t->dev->flags & IFF_UP)) @@ -158,7 +155,6 @@ struct ip_tunnel *ip_tunnel_lookup(struc cand = t; } -skip_key_lookup: if (cand) return cand;