netfilter: br_netfilter: disable sabotage_in hook after first suppression
authorFlorian Westphal <fw@strlen.de>
Mon, 30 Jan 2023 10:39:29 +0000 (11:39 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 31 Jan 2023 12:59:36 +0000 (13:59 +0100)
commit2b272bb558f1d3a5aa95ed8a82253786fd1a48ba
treef49376012f5f88520ab73f0415fa8bee1f4d759d
parent9b3fc325c2a7e9e17e22b008357cb0ceb810d9b2
netfilter: br_netfilter: disable sabotage_in hook after first suppression

When using a xfrm interface in a bridged setup (the outgoing device is
bridged), the incoming packets in the xfrm interface are only tracked
in the outgoing direction.

$ brctl show
bridge name     interfaces
br_eth1         eth1

$ conntrack -L
tcp 115 SYN_SENT src=192... dst=192... [UNREPLIED] ...

If br_netfilter is enabled, the first (encrypted) packet is received onR
eth1, conntrack hooks are called from br_netfilter emulation which
allocates nf_bridge info for this skb.

If the packet is for local machine, skb gets passed up the ip stack.
The skb passes through ip prerouting a second time. br_netfilter
ip_sabotage_in supresses the re-invocation of the hooks.

After this, skb gets decrypted in xfrm layer and appears in
network stack a second time (after decryption).

Then, ip_sabotage_in is called again and suppresses netfilter
hook invocation, even though the bridge layer never called them
for the plaintext incarnation of the packet.

Free the bridge info after the first suppression to avoid this.

I was unable to figure out where the regression comes from, as far as i
can see br_netfilter always had this problem; i did not expect that skb
is looped again with different headers.

Fixes: c4b0e771f906 ("netfilter: avoid using skb->nf_bridge directly")
Reported-and-tested-by: Wolfgang Nothdurft <wolfgang@linogate.de>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/bridge/br_netfilter_hooks.c