xfrm6: call kfree_skb when skb is toobig
Subsystems (4)
PATCH 1/2 xfrm6: call kfree_skb when skb is toobig
After commit d6990976af7c5d8f55903bfb4289b6fb030bf754 ("vti6: fix PMTU caching and reporting on xmit"), some too big skbs might be potentially passed down to __xfrm6_output, causing it to fail to transmit but not free the skb, causing a leak of skb, and consequentially a leak of dst references.
After running pmtu.sh, that shows as failure to unregister devices in a namespace:
[ 311.397671] unregister_netdevice: waiting for veth_b to become free. Usage count = 1
The fix is to call kfree_skb in case of transmit failures.
--- net/ipv6/xfrm6_output.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/xfrm6_output.c +2 -0
@@ -170,9 +170,11 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)if (toobig &&xfrm6_local_dontfrag (skb)) {xfrm6_local_rxpmtu (skb, mtu); +kfree_skb (skb);return -EMSGSIZE ; }else if (!skb->ignore_df && toobig && skb->sk) {xfrm_local_error (skb, mtu); +kfree_skb (skb);return -EMSGSIZE ; }
Signature · 1 line
2.17.1
PATCH 2/2 vti6: do not check for ignore_df in order to update pmtu
Before commit d6990976af7c5d8f55903bfb4289b6fb030bf754 ("vti6: fix PMTU caching and reporting on xmit"), skb was scrubbed before checking for ignore_df. The scrubbing meant ignore_df was false, making the check irrelevant. Now that the scrubbing happens after that, some packets might fail the checking and dst will not have its pmtu updated.
Not only that, but too big skb will be potentially passed down to __xfrm6_output, causing it to fail to transmit but not free the skb, causing a leak of skb, and consequentially a leak of dst references.
After running pmtu.sh, that shows as failure to unregister devices in a namespace:
[ 311.397671] unregister_netdevice: waiting for veth_b to become free. Usage count = 1
--- net/ipv6/ip6_vti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_vti.c +1 -1
@@ -481,7 +481,7 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl) } mtu =dst_mtu (dst); -if (!skb->ignore_df && skb->len > mtu) { +if (skb->len > mtu) {skb_dst_update_pmtu (skb, mtu);if (skb->protocol ==htons (ETH_P_IPV6 )) {
Signature · 1 line
2.17.1
Quoted 5 lines · Thadeu Lima de Souza Cascardo
After commit
d6990976af7c5d8f55903bfb4289b6fb030bf754("vti6: fix PMTU caching and reporting on xmit"), some too big skbs might be potentially passed down to__xfrm6_output, causing it to fail to transmit but not free the skb, causing a leak of skb, and consequentially a leak of dst references.
Quoted 7 lines
After running
pmtu.sh, that shows as failure to unregister devices in a namespace:[ 311.397671] unregister_netdevice: waiting for veth_b to become free. Usage count = 1The fix is to call
kfree_skbin case of transmit failures.Signed-off-by Thadeu Lima de Souza Cascardo <[email protected]>
I was about to post the same patch. Arguably, the commit introducing this bug is the one that added those "return -EMSGSIZE" to __xfrm6_output without freeing.
Either way, it's missing a Fixes: tag, which should be one of those, or both:
Signature · 1 line
Sabrina
Steffen Klassert
maintainerRe: [PATCH 2/2] vti6: do not check for ignore_df in order to update pmtu
In reply to Thadeu Lima de Souza CascardoQuoted 24 lines · Thadeu Lima de Souza Cascardo
Before commit
d6990976af7c5d8f55903bfb4289b6fb030bf754("vti6: fix PMTU caching and reporting on xmit"), skb was scrubbed before checking forignore_df. The scrubbing meantignore_dfwas false, making the check irrelevant. Now that the scrubbing happens after that, some packets might fail the checking and dst will not have its pmtu updated.Not only that, but too big skb will be potentially passed down to
__xfrm6_output, causing it to fail to transmit but not free the skb, causing a leak of skb, and consequentially a leak of dst references.After running
pmtu.sh, that shows as failure to unregister devices in a namespace:[ 311.397671] unregister_netdevice: waiting for veth_b to become free. Usage count = 1Signed-off-by Thadeu Lima de Souza Cascardo <[email protected]>--- net/ipv6/ip6_vti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv6/ip6_vti.c +0
-0
net/ipv6/ip6_vti.c vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl) · line 485
Quoted 6 lines
net/ipv6/ip6_vti.c +1
-1@@ -481,7 +481,7 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl) } mtu =dst_mtu (dst); -if (!skb->ignore_df && skb->len > mtu) { +if (skb->len > mtu) {skb_dst_update_pmtu (skb, mtu);
The very same patch went already to the net tree two day ago:
commit 9f2895461439fda2801a7906fb4c5fb3dbb37a0a
vti6: remove !skb->ignore_df check from vti6_xmit()
Steffen Klassert
maintainerQuoted 6 lines · Sabrina Dubroca
Quoted 5 lines · Thadeu Lima de Souza Cascardo
After commit
d6990976af7c5d8f55903bfb4289b6fb030bf754("vti6: fix PMTU caching and reporting on xmit"), some too big skbs might be potentially passed down to__xfrm6_output, causing it to fail to transmit but not free the skb, causing a leak of skb, and consequentially a leak of dst references.
Quoted 7 lines
Quoted 7 lines
After running
pmtu.sh, that shows as failure to unregister devices in a namespace:[ 311.397671] unregister_netdevice: waiting for veth_b to become free. Usage count = 1The fix is to call
kfree_skbin case of transmit failures.Signed-off-by Thadeu Lima de Souza Cascardo <[email protected]>
Good catch!
Quoted 11 lines
Reviewed-by Sabrina Dubroca <[email protected]>I was about to post the same patch. Arguably, the commit introducing this bug is the one that added those "return
-EMSGSIZE" to__xfrm6_outputwithout freeing.Either way, it's missing a Fixes: tag, which should be one of those, or both:
Fixes d6990976af7c ("vti6: fix PMTU caching and reporting on xmit")Fixes dd767856a36e ("xfrm6: Don't call icmpv6_send on local error")
This bug can be triggered even without vti6, so the correct Fixes tag would be the latter.
Thadeu, please resend this one with the Fixes tag.
Thanks!
PATCH v2 1/1 xfrm6: call kfree_skb when skb is toobig
In reply to Thadeu Lima de Souza CascardoAfter commit d6990976af7c5d8f55903bfb4289b6fb030bf754 ("vti6: fix PMTU caching and reporting on xmit"), some too big skbs might be potentially passed down to __xfrm6_output, causing it to fail to transmit but not free the skb, causing a leak of skb, and consequentially a leak of dst references.
After running pmtu.sh, that shows as failure to unregister devices in a namespace:
[ 311.397671] unregister_netdevice: waiting for veth_b to become free. Usage count = 1
The fix is to call kfree_skb in case of transmit failures.
--- net/ipv6/xfrm6_output.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv6/xfrm6_output.c +2 -0
@@ -170,9 +170,11 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)if (toobig &&xfrm6_local_dontfrag (skb)) {xfrm6_local_rxpmtu (skb, mtu); +kfree_skb (skb);return -EMSGSIZE ; }else if (!skb->ignore_df && toobig && skb->sk) {xfrm_local_error (skb, mtu); +kfree_skb (skb);return -EMSGSIZE ; }
Signature · 1 line
2.17.1
Quoted 7 lines · Thadeu Lima de Souza Cascardo
After commit
d6990976af7c5d8f55903bfb4289b6fb030bf754("vti6: fix PMTU caching and reporting on xmit"), some too big skbs might be potentially passed down to__xfrm6_output, causing it to fail to transmit but not free the skb, causing a leak of skb, and consequentially a leak of dst references.After running
pmtu.sh, that shows as failure to unregister devices in a namespace:
Quoted 7 lines
[ 311.397671] unregister_netdevice: waiting for veth_b to become free. Usage count = 1The fix is to call
kfree_skbin case of transmit failures.Signed-off-by Thadeu Lima de Souza Cascardo <[email protected]>Reviewed-by Sabrina Dubroca <[email protected]>Fixes dd767856a36e ("xfrm6: Don't call icmpv6_send on local error")
Applied, thanks a lot!