Skip to content

Commit 94623f5

Browse files
Florian Westphalummakynes
authored andcommitted
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]>
1 parent 24e3fce commit 94623f5

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
@@ -294,6 +294,7 @@ struct nf_bridge_info {
294294
u8 pkt_otherhost:1;
295295
u8 in_prerouting:1;
296296
u8 bridged_dnat:1;
297+
u8 sabotage_in_done:1;
297298
__u16 frag_max_size;
298299
struct net_device *physindev;
299300

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)