Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2453388imd; Fri, 2 Nov 2018 11:39:52 -0700 (PDT) X-Google-Smtp-Source: AJdET5cKaglDYKPQagyeXvO5o04T7JAU7VXcSX1K4ZPkPZsgMXVHE3/SfAqgkEeFthryR+9dbwRj X-Received: by 2002:a17:902:a9c5:: with SMTP id b5-v6mr12696409plr.340.1541183991983; Fri, 02 Nov 2018 11:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541183991; cv=none; d=google.com; s=arc-20160816; b=QnhSYNY6yMc1+ayD03/RJNBjxB0NtZfxSORw43rUyKD4brYbEU66TlKjKr5X0yd7Ch GnGIpFeGyPfVOtW767WFrpqAEN/t/OQuf7GMBOoarbTxo4SLhpo+cNiWpwIoMk6XNVOD /KC5t6e190yWcDd8syuwi/Syxf/s/0mVoMXkQxJqG8bXR6EVe7QNatUesjswhYfHOvvu yW7/lyBrnk4MRyoRdPJtmJ57YrxVZwX5IXpAxngYYqf3B48So9+g7xE3BpgZXerwRkAr EukQcEDtMOWanSqZz2qBFAzXsrEDklmS5Jijem41zR7akcK6N5pHTaFhf/ilsFQ5JxSP lyeA== 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=5cfINNcC43jJZM7VHcdW/cmJHT8HGhx3hBCGa7NZN1E=; b=ZuatrQqjbi9+OzhxU1L9pjMbQP94vp384fcuuI/tQ5xKZKJ97w4rWa7QuUnZul6Ya0 pZB9h0uY+zXTRAaCRs2zC+ePMrCejghVJV3ouszpTAf/pG0E0NtwRhWPt//HQMRzvM53 6GCNz39CzgDw8ISDaaoxnDRP7PbtBudpSGAQDLtB1typ9XYtBe2jP+4H8eIScIkJbYUo Ta7rEPJR6fJAk29S89yl9gWS5GM/42+3mE9JbwfHLmVXTHk+5pavQayMCuAROaSS/xyV H83+AdPzlrCdxP2gmAo46fCy8DjE4RWJHBVzhNYQlWvkJAjLVHbwH/kmV4BZg1Z13FVq rmFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gR1DWZLt; 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 31-v6si7217057plk.397.2018.11.02.11.39.37; Fri, 02 Nov 2018 11:39:51 -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=gR1DWZLt; 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 S1728855AbeKCDqh (ORCPT + 99 others); Fri, 2 Nov 2018 23:46:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:40426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727556AbeKCDqg (ORCPT ); Fri, 2 Nov 2018 23:46:36 -0400 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 0F9472082D; Fri, 2 Nov 2018 18:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541183905; bh=Gj7LeaDeP4mc4fsVtRPU+x+J2Pr1WIzt4wFF/e8c/UE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gR1DWZLt7RXHPkciAf9dBMPx9l0C9iSTjvpGz5D4aE5bWxWAo4nTYs/11Z673R11n nAcmoz6lnHrfGZvomnTecvyc0GqYxiCvMMRiyFAgysmXNL6V7jliWOhczEfkGnzYLY oVVnvLXtLTr9ekIRl+TFny51tyeev4p1b3AtAHsI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "DSouza, Nelson" , David Ahern , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.18 016/150] netfilter: bridge: Dont sabotage nf_hook calls from an l3mdev Date: Fri, 2 Nov 2018 19:32:58 +0100 Message-Id: <20181102182903.967057218@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit a173f066c7cfc031acb8f541708041e009fc9812 ] For starters, the bridge netfilter code registers operations that are invoked any time nh_hook is called. Specifically, ip_sabotage_in watches for nested calls for NF_INET_PRE_ROUTING when a bridge is in the stack. Packet wise, the bridge netfilter hook runs first. br_nf_pre_routing allocates nf_bridge, sets in_prerouting to 1 and calls NF_HOOK for NF_INET_PRE_ROUTING. It's finish function, br_nf_pre_routing_finish, then resets in_prerouting flag to 0 and the packet continues up the stack. The packet eventually makes it to the VRF driver and it invokes nf_hook for NF_INET_PRE_ROUTING in case any rules have been added against the vrf device. Because of the registered operations the call to nf_hook causes ip_sabotage_in to be invoked. That function sees the nf_bridge on the skb and that in_prerouting is not set. Thinking it is an invalid nested call it steals (drops) the packet. Update ip_sabotage_in to recognize that the bridge or one of its upper devices (e.g., vlan) can be enslaved to a VRF (L3 master device) and allow the packet to go through the nf_hook a second time. Fixes: 73e20b761acf ("net: vrf: Add support for PREROUTING rules on vrf device") Reported-by: D'Souza, Nelson Signed-off-by: David Ahern Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/bridge/br_netfilter_hooks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c index 9b16eaf33819..58240cc185e7 100644 --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c @@ -834,7 +834,8 @@ static unsigned int ip_sabotage_in(void *priv, struct sk_buff *skb, const struct nf_hook_state *state) { - if (skb->nf_bridge && !skb->nf_bridge->in_prerouting) { + if (skb->nf_bridge && !skb->nf_bridge->in_prerouting && + !netif_is_l3_master(skb->dev)) { state->okfn(state->net, state->sk, skb); return NF_STOLEN; } -- 2.17.1