Skip to content

Commit 637c557

Browse files
committed
netfilter: br_netfilter: fix recent physdev match breakage
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2189550 Upstream Status: commit 94623f5 commit 94623f5 Author: Florian Westphal <[email protected]> Date: Mon Apr 3 13:54:37 2023 +0200 netfilter: br_netfilter: fix recent physdev match breakage Recent attempt to ensure PREROUTING hook is executed again when a decrypted ipsec packet received on a bridge passes through the network stack a second time broke the physdev match in INPUT hook. We can't discard the nf_bridge info strct from sabotage_in hook, as this is needed by the physdev match. Keep the struct around and handle this with another conditional instead. Fixes: 2b272bb ("netfilter: br_netfilter: disable sabotage_in hook after first suppression") Reported-and-tested-by: Farid BENAMROUCHE <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: Florian Westphal <[email protected]>
1 parent 52691f7 commit 637c557

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

include/linux/skbuff.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ struct nf_bridge_info {
261261
u8 pkt_otherhost:1;
262262
u8 in_prerouting:1;
263263
u8 bridged_dnat:1;
264+
u8 sabotage_in_done:1;
264265
__u16 frag_max_size;
265266
struct net_device *physindev;
266267

net/bridge/br_netfilter_hooks.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -868,12 +868,17 @@ static unsigned int ip_sabotage_in(void *priv,
868868
{
869869
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
870870

871-
if (nf_bridge && !nf_bridge->in_prerouting &&
872-
!netif_is_l3_master(skb->dev) &&
873-
!netif_is_l3_slave(skb->dev)) {
874-
nf_bridge_info_free(skb);
875-
state->okfn(state->net, state->sk, skb);
876-
return NF_STOLEN;
871+
if (nf_bridge) {
872+
if (nf_bridge->sabotage_in_done)
873+
return NF_ACCEPT;
874+
875+
if (!nf_bridge->in_prerouting &&
876+
!netif_is_l3_master(skb->dev) &&
877+
!netif_is_l3_slave(skb->dev)) {
878+
nf_bridge->sabotage_in_done = 1;
879+
state->okfn(state->net, state->sk, skb);
880+
return NF_STOLEN;
881+
}
877882
}
878883

879884
return NF_ACCEPT;

0 commit comments

Comments
 (0)