bridge: netfilter: orphan skb before invoking ip netfilter hooks
Subsystems (3)
Florian Westphal
maintainerPATCH 1/1 bridge: netfilter: orphan skb before invoking ip netfilter hooks
Pekka Pietikäinen reports xt_socket behavioural change after commit 00028aa37098o (netfilter: xt_socket: use IP early demux).
Reason is xt_socket now no longer does an unconditional sk lookup - it re-uses existing skb->sk if possible, assuming ->sk was set by tcp early demux.
However, when netfilter is invoked via bridge, this can cause 'bogus' sockets to be examined by the match, e.g. a 'tun' device socket.
bridge netfilter should orphan the skb just like the routing path before invoking ipv4/ipv6 netfilter hooks to avoid this.
---
net/bridge/br_netfilter.c +2 -0
@@ -559,6 +559,8 @@ static struct net_device *setup_pre_routing(struct sk_buff *skb)else if (skb->protocol ==htons (ETH_P_PPP_SES )) nf_bridge->mask |= BRNF_PPPoE; +/* Must drop socket now because of tproxy. */ +skb_orphan (skb);return skb->dev; }
Signature · 6 lines
1.8.1.5 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Florian Westphal
Pekka Pietikäinen reports
xt_socketbehavioural change after commit
behavioral maybe ? ;)
Quoted 5 lines
00028aa37098o (netfilter:
xt_socket: use IP early demux).Reason is
xt_socketnow no longer does an unconditional sk lookup - it re-uses existingskb->skif possible, assuming ->sk was set by tcp early demux.
s/tcp/ip/ since it also can work for UDP sockets in net-next
Quoted 15 lines
However, when netfilter is invoked via bridge, this can cause 'bogus' sockets to be examined by the match, e.g. a 'tun' device socket.
bridge netfilter should orphan the skb just like the routing path before invoking ipv4/ipv6 netfilter hooks to avoid this.
Reported-and-tested-by Pekka Pietikäinen <[email protected]>Signed-off-by Florian Westphal <[email protected]>---
net/bridge/br_netfilter.c +0
-0
net/bridge/br_netfilter.c static struct net_device *setup_pre_routing(struct sk_buff *skb) · line 566
Quoted 8 lines
net/bridge/br_netfilter.c +2
-0@@ -559,6 +559,8 @@ static struct net_device *setup_pre_routing(struct sk_buff *skb)else if (skb->protocol ==htons (ETH_P_PPP_SES )) nf_bridge->mask |= BRNF_PPPoE; +/* Must drop socket now because of tproxy. */ +skb_orphan (skb);return skb->dev; }
This was a nice one, thanks Florian !
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Florian Westphal
maintainerQuoted 4 lines · Eric Dumazet
Quoted 1 line · Florian Westphal
Pekka Pietikäinen reports
xt_socketbehavioural change after commitbehavioral maybe ? ;)
AE vs. BE i guess. I grep'd /usr/share/dict/* before, i swear ;)
Quoted 7 lines
Quoted 5 lines
00028aa37098o (netfilter:
xt_socket: use IP early demux).Reason is
xt_socketnow no longer does an unconditional sk lookup - it re-uses existingskb->skif possible, assuming ->sk was set by tcp early demux.s/tcp/ip/ since it also can work for UDP sockets in net-next
True. Pablo, could you amend this bit if you decide to apply this to -next tree (i guess -next is fine)?
Thanks for reviewing this Eric!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso
maintainerQuoted 1 line · Florian Westphal
Eric Dumazet <[email protected]> wrote:
[...]
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
it re-uses existing
skb->skif possible, assuming ->sk was set by tcp early demux.s/tcp/ip/ since it also can work for UDP sockets in net-next
True. Pablo, could you amend this bit if you decide to apply this to -next tree (i guess -next is fine)?
Amended and applied, thanks Florian!