]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netfilter: physdev: relax br_netfilter dependency
authorFlorian Westphal <fw@strlen.de>
Fri, 11 Jan 2019 13:46:15 +0000 (14:46 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 27 Apr 2019 07:33:53 +0000 (09:33 +0200)
[ Upstream commit 8e2f311a68494a6677c1724bdcb10bada21af37c ]

Following command:
  iptables -D FORWARD -m physdev ...
causes connectivity loss in some setups.

Reason is that iptables userspace will probe kernel for the module revision
of the physdev patch, and physdev has an artificial dependency on
br_netfilter (xt_physdev use makes no sense unless a br_netfilter module
is loaded).

This causes the "phydev" module to be loaded, which in turn enables the
"call-iptables" infrastructure.

bridged packets might then get dropped by the iptables ruleset.

The better fix would be to change the "call-iptables" defaults to 0 and
enforce explicit setting to 1, but that breaks backwards compatibility.

This does the next best thing: add a request_module call to checkentry.
This was a stray '-D ... -m physdev' won't activate br_netfilter
anymore.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/netfilter/br_netfilter.h
net/bridge/br_netfilter_hooks.c
net/netfilter/xt_physdev.c

index e8d1448425a717facd1a6cfb71d72a9dfacc3ed7..b1d0d46344e2f34fcf9ca185273904ac8bd37033 100644 (file)
@@ -42,7 +42,6 @@ static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)
 }
 
 struct net_device *setup_pre_routing(struct sk_buff *skb);
-void br_netfilter_enable(void);
 
 #if IS_ENABLED(CONFIG_IPV6)
 int br_validate_ipv6(struct net *net, struct sk_buff *skb);
index 6def85d75b1d55a935a21761a9bdb78a3555c486..93b5525bcccf9e9e1f07b2df3ccf6e6e15007e97 100644 (file)
@@ -873,11 +873,6 @@ static const struct nf_br_ops br_ops = {
        .br_dev_xmit_hook =     br_nf_dev_xmit,
 };
 
-void br_netfilter_enable(void)
-{
-}
-EXPORT_SYMBOL_GPL(br_netfilter_enable);
-
 /* For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because
  * br_dev_queue_push_xmit is called afterwards */
 static struct nf_hook_ops br_nf_ops[] __read_mostly = {
index 1caaccbc306c7751f717aa1e223cf2ef30f00bec..7e40636219606e2204762b1f891d31247b09b3c6 100644 (file)
@@ -96,8 +96,7 @@ match_outdev:
 static int physdev_mt_check(const struct xt_mtchk_param *par)
 {
        const struct xt_physdev_info *info = par->matchinfo;
-
-       br_netfilter_enable();
+       static bool brnf_probed __read_mostly;
 
        if (!(info->bitmask & XT_PHYSDEV_OP_MASK) ||
            info->bitmask & ~XT_PHYSDEV_OP_MASK)
@@ -113,6 +112,12 @@ static int physdev_mt_check(const struct xt_mtchk_param *par)
                if (par->hook_mask & (1 << NF_INET_LOCAL_OUT))
                        return -EINVAL;
        }
+
+       if (!brnf_probed) {
+               brnf_probed = true;
+               request_module("br_netfilter");
+       }
+
        return 0;
 }