linux-stable/net/bridge
Florian Westphal 85b9029d0d netfilter: br_netfilter: do not skip all hooks with 0 priority
[ Upstream commit c2577862ee ]

When br_netfilter module is loaded, skbs may be diverted to the
ipv4/ipv6 hooks, just like as if we were routing.

Unfortunately, bridge filter hooks with priority 0 may be skipped
in this case.

Example:
1. an nftables bridge ruleset is loaded, with a prerouting
   hook that has priority 0.
2. interface is added to the bridge.
3. no tcp packet is ever seen by the bridge prerouting hook.
4. flush the ruleset
5. load the bridge ruleset again.
6. tcp packets are processed as expected.

After 1) the only registered hook is the bridge prerouting hook, but its
not called yet because the bridge hasn't been brought up yet.

After 2), hook order is:
   0 br_nf_pre_routing // br_netfilter internal hook
   0 chain bridge f prerouting // nftables bridge ruleset

The packet is diverted to br_nf_pre_routing.
If call-iptables is off, the nftables bridge ruleset is called as expected.

But if its enabled, br_nf_hook_thresh() will skip it because it assumes
that all 0-priority hooks had been called previously in bridge context.

To avoid this, check for the br_nf_pre_routing hook itself, we need to
resume directly after it, even if this hook has a priority of 0.

Unfortunately, this still results in different packet flow.
With this fix, the eval order after in 3) is:
1. br_nf_pre_routing
2. ip(6)tables (if enabled)
3. nftables bridge

but after 5 its the much saner:
1. nftables bridge
2. br_nf_pre_routing
3. ip(6)tables (if enabled)

Unfortunately I don't see a solution here:
It would be possible to move br_nf_pre_routing to a higher priority
so that it will be called later in the pipeline, but this also impacts
ebtables evaluation order, and would still result in this very ordering
problem for all nftables-bridge hooks with the same priority as the
br_nf_pre_routing one.

Searching back through the git history I don't think this has
ever behaved in any other way, hence, no fixes-tag.

Reported-by: Radim Hrazdil <rhrazdil@redhat.com>
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>
2022-07-21 20:42:46 +02:00
..
netfilter netfilter: nft_reject_bridge: enable reject with bridge vlan 2020-06-03 08:18:08 +02:00
br.c net: bridge: Receive notification about successful FDB offload 2017-06-08 14:16:25 -04:00
br_device.c net: bridge: add missing counters to ndo_get_stats64 callback 2020-11-24 13:05:38 +01:00
br_fdb.c bridge: add tracepoint in br_fdb_update 2017-08-31 11:42:41 -07:00
br_forward.c net: bridge: Fix ethernet header pointer before check skb forwardable 2019-01-31 08:13:41 +01:00
br_if.c net: bridge: fix memleak in br_add_if() 2021-08-26 08:37:02 -04:00
br_input.c net: bridge: Clear offload_fwd_mark when passing frame up bridge interface. 2022-05-25 08:41:20 +02:00
br_ioctl.c bridge: move to workqueue gc 2017-02-06 22:53:13 -05:00
br_mdb.c bridge/mdb: remove wrong use of NLM_F_MULTI 2019-09-19 09:07:59 +02:00
br_multicast.c net: bridge: multicast: fix PIM hello router port marking race 2021-07-20 16:17:55 +02:00
br_netfilter_hooks.c netfilter: br_netfilter: do not skip all hooks with 0 priority 2022-07-21 20:42:46 +02:00
br_netfilter_ipv6.c netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING 2019-05-04 09:15:18 +02:00
br_netlink.c net: bridge: use nla_total_size_64bit() in br_get_linkxstats_size() 2021-10-17 10:08:33 +02:00
br_netlink_tunnel.c netlink: pass extended ACK struct to parsing functions 2017-04-13 13:58:22 -04:00
br_nf_core.c net: add bool confirm_neigh parameter for dst_ops.update_pmtu 2020-01-04 14:00:14 +01:00
br_private.h net: bridge: fix vlan tunnel dst null pointer dereference 2021-06-30 08:48:54 -04:00
br_private_stp.h
br_private_tunnel.h bridge: vlan dst_metadata hooks in ingress and egress paths 2017-02-03 15:21:22 -05:00
br_stp.c bridge: move to workqueue gc 2017-02-06 22:53:13 -05:00
br_stp_bpdu.c net: bridge: stp: don't cache eth dest pointer before skb pull 2019-07-31 07:28:46 +02:00
br_stp_if.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-06-06 22:20:08 -04:00
br_stp_timer.c bridge: start hello_timer when enabling KERNEL_STP in br_stp_start 2017-05-21 13:33:28 -04:00
br_switchdev.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
br_sysfs_br.c net: bridge: constify attribute_group structures. 2017-06-29 15:48:52 -04:00
br_sysfs_if.c net: bridge: use switchdev for port flags set through sysfs too 2021-03-07 11:27:43 +01:00
br_vlan.c net: bridge: vlan: fix error return code in __vlan_add() 2020-12-29 13:46:45 +01:00
br_vlan_tunnel.c net: bridge: fix vlan tunnel dst refcnt when egressing 2021-06-30 08:48:54 -04:00
Kconfig
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00