ip_forward: Drop frames with attached skb->sk
Subsystems (3)
PATCH 1/1 ip_forward: Drop frames with attached skb->sk
Initial discussion was:
[FYI] xfrm: Don't lookup sk_policy for timewait sockets
Forwarded frames should not have a socket attached. Especially tw sockets will lead to panics later-on in the stack.
This was observed with TPROXY assigning a tw socket and broken policy routing (misconfigured). As a result frame enters forwarding path instead of input. We cannot solve this in TPROXY as it cannot know that policy routing is broken.
---
net/ipv4/ip_forward.c +4 -1
@@ -82,6 +82,10 @@ int ip_forward(struct sk_buff *skb)if (skb->pkt_type !=PACKET_HOST ) goto drop; +/* this should happen neither */ +if (unlikely (skb->sk)) + goto drop; +if (skb_warn_if_lro (skb)) goto drop; --
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 88
Quoted 5 lines · On Tue, 14 Apr 2015 07:52:04 +0200 Sebastian Poehn <[email protected]>…
net/ipv4/ip_forward.c +4
-0+/* this should happen neither */ +if (unlikely (skb->sk)) + goto drop; +
With gcc, all goto's are already treated as unlikely().
Quoted 10 lines · Stephen Hemminger
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 88
Quoted 5 lines · On Tue, 14 Apr 2015 07:52:04 +0200 Sebastian Poehn <[email protected]>…
net/ipv4/ip_forward.c +4
-0+/* this should happen neither */ +if (unlikely (skb->sk)) + goto drop; +With gcc, all goto's are already treated as
unlikely().
Thanks for that recommendation. But before I re-cook: What about Clang and ICC?
David Miller
maintainerFrom: Sebastian Poehn <[email protected]>
Date: Tue, 14 Apr 2015 08:18:40 +0200
Quoted 12 lines · Stephen Hemminger
Quoted 10 lines
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 88
Quoted 5 lines · On Tue, 14 Apr 2015 07:52:04 +0200 Sebastian Poehn <[email protected]>…
net/ipv4/ip_forward.c +4
-0+/* this should happen neither */ +if (unlikely (skb->sk)) + goto drop; +With gcc, all goto's are already treated as
unlikely().
Quoted 2 lines
Thanks for that recommendation. But before I re-cook: What about Clang and ICC?
I think even if this is the case with gcc, it's good documentation.
Quoted 18 lines · Sebastian Poehn
Initial discussion was:
[FYI] xfrm: Don't lookupsk_policyfor timewait socketsForwarded frames should not have a socket attached. Especially tw sockets will lead to panics later-on in the stack.
This was observed with TPROXY assigning a tw socket and broken policy routing (misconfigured). As a result frame enters forwarding path instead of input. We cannot solve this in TPROXY as it cannot know that policy routing is broken.
Signed-off-by Sebastian Poehn <[email protected]>---
net/ipv4/ip_forward.c +0
-0
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 85
Quoted 4 lines
net/ipv4/ip_forward.c +1
-0@@ -82,6 +82,10 @@ int ip_forward(struct sk_buff *skb)if (skb->pkt_type !=PACKET_HOST ) goto drop; +/* this should happen neither */
Sorry. "neither" should be "either"?
Zhu Yanjun
Quoted 13 lines
net/ipv4/ip_forward.c +3
-2+if (unlikely (skb->sk)) + goto drop; +if (skb_warn_if_lro (skb)) goto drop; -- --To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 22 lines · On Tue, 2015-04-14 at 14:33 +0800, yzhu1 wrote:
Quoted 21 lines · Sebastian Poehn
Initial discussion was:
[FYI] xfrm: Don't lookupsk_policyfor timewait socketsForwarded frames should not have a socket attached. Especially tw sockets will lead to panics later-on in the stack.
This was observed with TPROXY assigning a tw socket and broken policy routing (misconfigured). As a result frame enters forwarding path instead of input. We cannot solve this in TPROXY as it cannot know that policy routing is broken.
Signed-off-by Sebastian Poehn <[email protected]>---
net/ipv4/ip_forward.c +0
-0@@ -82,6 +82,10 @@ int ip_forward(struct sk_buff *skb)if (skb->pkt_type !=PACKET_HOST ) goto drop;
Quoted 2 lines
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 85
Quoted 1 line
net/ipv4/ip_forward.c +1
-0+/* this should happen neither */ Sorry. "neither" should be "either"?
/* that should never happen */
if (skb->pkt_type != PACKET_HOST)
goto drop;
/* this should happen neither */
if (unlikely(skb->sk))
goto drop;Both of them should never happen.
Quoted 16 lines
Zhu Yanjun
Quoted 13 lines
net/ipv4/ip_forward.c +3
-2+if (unlikely (skb->sk)) + goto drop; +if (skb_warn_if_lro (skb)) goto drop; -- --To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 34 lines · Sebastian Poehn
Quoted 22 lines · On Tue, 2015-04-14 at 14:33 +0800, yzhu1 wrote:
Quoted 21 lines · Sebastian Poehn
Initial discussion was:
[FYI] xfrm: Don't lookupsk_policyfor timewait socketsForwarded frames should not have a socket attached. Especially tw sockets will lead to panics later-on in the stack.
This was observed with TPROXY assigning a tw socket and broken policy routing (misconfigured). As a result frame enters forwarding path instead of input. We cannot solve this in TPROXY as it cannot know that policy routing is broken.
Signed-off-by Sebastian Poehn <[email protected]>---
net/ipv4/ip_forward.c +0
-0@@ -82,6 +82,10 @@ int ip_forward(struct sk_buff *skb)if (skb->pkt_type !=PACKET_HOST ) goto drop;Quoted 2 lines
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 85
Quoted 1 line
net/ipv4/ip_forward.c +1
-0+/* this should happen neither */ Sorry. "neither" should be "either"?
/* that should never happen */ if (skb->pkt_type != PACKET_HOST) goto drop; /* this should happen neither */ if (unlikely(skb->sk)) goto drop;
Quoted 1 line
Both of them should never happen.
I do not feel the comment is useful in this form.
I would prefer explicit TPROXY reference, maybe using this :
#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TPROXY) if (skb->sk) goto drop;
#endif
changelog will precisely describes the problem for the curious readers.
Thanks !
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Tue, 14 Apr 2015 04:54:47 -0700
Quoted 39 lines · Sebastian Poehn
Quoted 34 lines · On Tue, 2015-04-14 at 14:33 +0800, yzhu1 wrote:
Quoted 22 lines · Sebastian Poehn
Quoted 21 lines
Initial discussion was:
[FYI] xfrm: Don't lookupsk_policyfor timewait socketsForwarded frames should not have a socket attached. Especially tw sockets will lead to panics later-on in the stack.
This was observed with TPROXY assigning a tw socket and broken policy routing (misconfigured). As a result frame enters forwarding path instead of input. We cannot solve this in TPROXY as it cannot know that policy routing is broken.
Signed-off-by Sebastian Poehn <[email protected]>---
net/ipv4/ip_forward.c +0
-0@@ -82,6 +82,10 @@ int ip_forward(struct sk_buff *skb)if (skb->pkt_type !=PACKET_HOST ) goto drop;Quoted 2 lines
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 85
Quoted 1 line
net/ipv4/ip_forward.c +1
-0+/* this should happen neither */ Sorry. "neither" should be "either"?
/* that should never happen */ if (skb->pkt_type != PACKET_HOST) goto drop; /* this should happen neither */ if (unlikely(skb->sk)) goto drop;Quoted 1 line
Both of them should never happen.
I do not feel the comment is useful in this form.
Quoted 8 lines
I would prefer explicit TPROXY reference, maybe using this :
#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TPROXY) if (skb->sk) goto drop;#endif
changelog will precisely describes the problem for the curious readers.
I suspect we really want this test unconditionally, because we are not able to safely operate past this point if skb->sk is NULL regardless of what made it that way.
At least, I'll sleep more soundly at night :)
Quoted 49 lines · David Miller
From: Eric Dumazet <[email protected]>
Date: Tue, 14 Apr 2015 04:54:47 -0700Quoted 46 lines · Sebastian Poehn
Quoted 34 lines · On Tue, 2015-04-14 at 14:33 +0800, yzhu1 wrote:
Quoted 22 lines · Sebastian Poehn
Quoted 21 lines
Initial discussion was:
[FYI] xfrm: Don't lookupsk_policyfor timewait socketsForwarded frames should not have a socket attached. Especially tw sockets will lead to panics later-on in the stack.
This was observed with TPROXY assigning a tw socket and broken policy routing (misconfigured). As a result frame enters forwarding path instead of input. We cannot solve this in TPROXY as it cannot know that policy routing is broken.
Signed-off-by Sebastian Poehn <[email protected]>---
net/ipv4/ip_forward.c +0
-0@@ -82,6 +82,10 @@ int ip_forward(struct sk_buff *skb)if (skb->pkt_type !=PACKET_HOST ) goto drop;Quoted 2 lines
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 85
Quoted 1 line
net/ipv4/ip_forward.c +1
-0+/* this should happen neither */ Sorry. "neither" should be "either"?
/* that should never happen */ if (skb->pkt_type != PACKET_HOST) goto drop; /* this should happen neither */ if (unlikely(skb->sk)) goto drop;Quoted 1 line
Both of them should never happen.
I do not feel the comment is useful in this form.
I would prefer explicit TPROXY reference, maybe using this :
#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TPROXY) if (skb->sk) goto drop;#endif
Quoted 7 lines
Quoted 1 line
changelog will precisely describes the problem for the curious readers.
I suspect we really want this test unconditionally, because we are not able to safely operate past this point if
skb->skis NULL regardless of what made it that way.At least, I'll sleep more soundly at night :)
I will send out a v2 patch like that when merge window has closed.
---
goto drop;
+ if (unlikely(skb->sk))
+ goto drop;
+
if (skb_warn_if_lro(skb))
goto drop;
---