Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1517911ybb; Sat, 11 Apr 2020 05:28:41 -0700 (PDT) X-Google-Smtp-Source: APiQypJ5dD8fDW8hygXzXOKQTf47mgrcn+KTgBSNg7O3c2Xb/pIlyNjtkV6IIXjFD3nFlntqAoLu X-Received: by 2002:ac8:38f1:: with SMTP id g46mr3054733qtc.212.1586608121499; Sat, 11 Apr 2020 05:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586608121; cv=none; d=google.com; s=arc-20160816; b=bSGNYJHeUE9K0DpCAQwhKEMYjpR76MyIB26JlSZD8vvVXoak2iOPK00QNxmf/7niZa CvQacFmXR3xlQnNttY4jcQ4UFgqd6Fu8Vlw8HS00gJWBd14zFgevlT4HmKszme+/x7+D PhsDuSPY61MknFJG8gwwFEPHYHJP+3q5ZR+r26348Whe66r//mTq2J7J5M536PS0z1r5 njkBo5IayYCGsV4wuVOZiplRq6c4Riw3n4F6KWw2U/tVZ8Svwic9UOWpHgkbQMf5n/yY rvINy4+yuA/k9s2GyXXCCyIpEJcw9FauJQlQ8hYO2Npc4XBIDwt5MVKyCXPLtIILbqIo CWCQ== 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=91E/bood5S6HE8Du9j0NDRd7CzZ/Azy0BkJFcNOhIGc=; b=CtVscDFLhTkRHOyPXjT1LyR6cSATsdt7ppG5cFQreMQpolv5/pMhHPmihHVndoti8x iid6R1uWQNY8pPae596wZEhAQrEoT7gGzH6AJjoQyLjrZEfuhG3FCaqrJwSKF8od2Gsa /uBC76Sl/EWWce8RQCu5FzEnkS+MlP3TZ6z3aGFE1MlAi907xbvThOfVV5uiV5KA6tQ4 MiJfq9RBazNXCHVlzCqxdHAQeuvbx+UyHDQHDI5A6G7WyqFY+mAok2mwNflEpbTt6RFm 68je02BC3yX9t3UDoE+QVTPwANmtaK9lDJ4PMFf3RykRMyTCFnCBsPxETk4oUMDYQGhl CZ3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1BWoeEP1; 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 z184si2925066qka.136.2020.04.11.05.28.27; Sat, 11 Apr 2020 05:28:41 -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=1BWoeEP1; 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 S1727321AbgDKMO5 (ORCPT + 99 others); Sat, 11 Apr 2020 08:14:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbgDKMO4 (ORCPT ); Sat, 11 Apr 2020 08:14: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 948FB20692; Sat, 11 Apr 2020 12:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607296; bh=8b6+SjPVlptKlpHpNs5BryqjkHoJs5ngMdVdKcZM1GY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1BWoeEP1xOygfCK05mERky7PtEt+B3iRqVlmQjcg09/6O5YXajAmLjR+VXF1+Z/3l BM68wl4gb7DeU+pITjnXdMskZ+jNcqqPoPMZl2vnLE0j0WFN4h11+UvB5lWqHUqKTw y0yGQxyjkHoxdJFIqFVN8Lv0eq/UB++o+PjXMpwk= 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 4.19 02/54] net, ip_tunnel: fix interface lookup with no key Date: Sat, 11 Apr 2020 14:08:44 +0200 Message-Id: <20200411115508.488143371@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411115508.284500414@linuxfoundation.org> References: <20200411115508.284500414@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 @@ -155,11 +155,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)) @@ -171,7 +168,6 @@ struct ip_tunnel *ip_tunnel_lookup(struc cand = t; } -skip_key_lookup: if (cand) return cand;