Skip to contentSkip to conversation

ipvs: fix ipv6 route unreach panic

PATCH In review Alex Gartrell 4 participants 6 messages Jun 26, 2015 – Jul 15, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipvs: fix ipv6 route unreach panic

Previously there was a trivial panic

unshare -n /bin/bash <<EOF
ip addr add dev lo face::1/128
ipvsadm -A -t [face::1]:15213
ipvsadm -a -t [face::1]:15213 -r b00c::1
echo boom | nc face::1 15213
EOF

This patch allows us to replicate the net logic above and simply capture the skb_dst(skb)->dev and use that for the purpose of the invocation.

---
 net/netfilter/ipvs/ip_vs_xmit.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/netfilter/ipvs/ip_vs_xmit.c +7 -0
index bf66a86..b99d806 100644
@@ -505,6 +505,13 @@ err_put:
 	return -1;
 
 err_unreach:
+	/* The ip6_link_failure function requires the dev field to be set
+	 * in order to get the net (further for the sake of fwmark
+	 * reflection).
+	 */
+	if (!skb->dev)
+		skb->dev = skb_dst(skb)->dev;
+
 	dst_link_failure(skb);
 	return -1;
 }
Signature · 1 line
Alex Gartrell <[email protected]>
maintainer Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 9 lines · Alex Gartrell

Previously there was a trivial panic

unshare -n /bin/bash <<EOF
ip addr add dev lo face::1/128
ipvsadm -A -t [face::1]:15213
ipvsadm -a -t [face::1]:15213 -r b00c::1
echo boom | nc face::1 15213
EOF

Quoted 4 lines

This patch allows us to replicate the net logic above and simply capture the skb_dst(skb)->dev and use that for the purpose of the invocation.

Looks good to me, thanks! Simon, patch looks suitable
for ipvs (net) tree.

Quoted 24 lines
---
 net/netfilter/ipvs/ip_vs_xmit.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/netfilter/ipvs/ip_vs_xmit.c +7 -0
index bf66a86..b99d806 100644
@@ -505,6 +505,13 @@ err_put:
 	return -1;
 
 err_unreach:
+	/* The ip6_link_failure function requires the dev field to be set
+	 * in order to get the net (further for the sake of fwmark
+	 * reflection).
+	 */
+	if (!skb->dev)
+		skb->dev = skb_dst(skb)->dev;
+
 	dst_link_failure(skb);
 	return -1;
 }
Signature · 1 line
Alex Gartrell <[email protected]>

Regards

--
Julian Anastasov <[email protected]>

maintainer
#2 lore raw
Quoted 17 lines · Julian Anastasov

Hello,

Quoted 12 lines · Alex Gartrell

Previously there was a trivial panic

unshare -n /bin/bash <<EOF
ip addr add dev lo face::1/128
ipvsadm -A -t [face::1]:15213
ipvsadm -a -t [face::1]:15213 -r b00c::1
echo boom | nc face::1 15213
EOF

This patch allows us to replicate the net logic above and simply capture the skb_dst(skb)->dev and use that for the purpose of the invocation.

Quoted 6 lines
Quoted 1 line

Looks good to me, thanks! Simon, patch looks suitable
for ipvs (net) tree.

Thanks, I have applied this to to the ipvs tree.

maintainer
#3 lore raw
In reply to Alex Gartrell

[Cc Hannes]

Quoted 25 lines · Alex Gartrell

Previously there was a trivial panic

unshare -n /bin/bash <<EOF
ip addr add dev lo face::1/128
ipvsadm -A -t [face::1]:15213
ipvsadm -a -t [face::1]:15213 -r b00c::1
echo boom | nc face::1 15213
EOF

This patch allows us to replicate the net logic above and simply capture the skb_dst(skb)->dev and use that for the purpose of the invocation.

---
 net/netfilter/ipvs/ip_vs_xmit.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/netfilter/ipvs/ip_vs_xmit.c +0 -0
index bf66a86..b99d806 100644
@@ -505,6 +505,13 @@ err_put:
 	return -1;
 
 err_unreach:

net/netfilter/ipvs/ip_vs_xmit.c err_put: · line 517

Quoted 10 lines
net/netfilter/ipvs/ip_vs_xmit.c +7 -0
+	/* The ip6_link_failure function requires the dev field to be set
+	 * in order to get the net (further for the sake of fwmark
+	 * reflection).
+	 */
+	if (!skb->dev)
+		skb->dev = skb_dst(skb)->dev;
+
 	dst_link_failure(skb);
 	return -1;
 }

My reading of this is that the above:

Fixes 1eb4f7582868 ("ipv6: in case of link failure remove route directly instead of letting it expire")

As it seems to me that it is that patch that causes ip6_link_failure to require the dev field to be set.

Does that seem sane?

#4 lore raw
Quoted 46 lines · Simon Horman

[Cc Hannes]

Quoted 30 lines · Alex Gartrell

Previously there was a trivial panic

unshare -n /bin/bash <<EOF
ip addr add dev lo face::1/128 ipvsadm -A -t [face::1]:15213 ipvsadm -a -t [face::1]:15213 -r b00c::1 echo boom | nc face::1 15213
EOF

This patch allows us to replicate the net logic above and simply capture
the skb_dst(skb)->dev and use that for the purpose of the invocation.

---
 net/netfilter/ipvs/ip_vs_xmit.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/netfilter/ipvs/ip_vs_xmit.c +1 -0
index bf66a86..b99d806 100644
@@ -505,6 +505,13 @@ err_put:
 	return -1;
 
 err_unreach:
+	/* The ip6_link_failure function requires the dev field to 

be set

net/netfilter/ipvs/ip_vs_xmit.c err_put: · line 517

Quoted 9 lines
net/netfilter/ipvs/ip_vs_xmit.c +6 -0
+	 * in order to get the net (further for the sake of fwmark
+	 * reflection).
+	 */
+	if (!skb->dev)
+		skb->dev = skb_dst(skb)->dev;
+
 	dst_link_failure(skb);
 	return -1;
 }

My reading of this is that the above:

Quoted 8 lines
Fixes 1eb4f7582868 ("ipv6: in case of link failure remove route

directly instead of letting it expire")

As it seems to me that it is that patch that causes ip6_link_failure to
require the dev field to be set.

Does that seem sane?

From what dst_link_failure -> ip6_link_failure expects the patch does make sense.

But the Fixes tag is wrong, because the panic should be triggered during dereferencing dev_net(skb->dev) in icmp6_send. This part was not touched by my patch.

Bye,
Hannes

maintainer
#5 lore raw
Quoted 54 lines · Hannes Frederic Sowa
Quoted 53 lines · Simon Horman

[Cc Hannes]

Quoted 30 lines · Alex Gartrell

Previously there was a trivial panic

unshare -n /bin/bash <<EOF
ip addr add dev lo face::1/128 ipvsadm -A -t [face::1]:15213 ipvsadm -a -t [face::1]:15213 -r b00c::1 echo boom | nc face::1 15213
EOF

This patch allows us to replicate the net logic above and simply capture
the skb_dst(skb)->dev and use that for the purpose of the invocation.

---
 net/netfilter/ipvs/ip_vs_xmit.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/netfilter/ipvs/ip_vs_xmit.c +1 -0
index bf66a86..b99d806 100644
@@ -505,6 +505,13 @@ err_put:
 	return -1;
 
 err_unreach:
+	/* The ip6_link_failure function requires the dev field to 

be set

net/netfilter/ipvs/ip_vs_xmit.c err_put: · line 517

Quoted 9 lines
net/netfilter/ipvs/ip_vs_xmit.c +6 -0
+	 * in order to get the net (further for the sake of fwmark
+	 * reflection).
+	 */
+	if (!skb->dev)
+		skb->dev = skb_dst(skb)->dev;
+
 	dst_link_failure(skb);
 	return -1;
 }

My reading of this is that the above:

Fixes 1eb4f7582868 ("ipv6: in case of link failure remove route

directly instead of letting it expire")

As it seems to me that it is that patch that causes ip6_link_failure to
require the dev field to be set.

Quoted 8 lines
Quoted 3 lines

Does that seem sane?

From what dst_link_failure -> ip6_link_failure expects the patch does

make sense.

But the Fixes tag is wrong, because the panic should be triggered during dereferencing dev_net(skb->dev) in icmp6_send. This part was not touched by my patch.

Thanks, of course you are correct.

I now wonder if this bug may not have been present ever since IPv6 support was added to IPv6 in v2.6.28 and thus this patch fixes b3cdd2a73867 ("IPVS: Add and bind IPv6 xmit functions") which originally added the call to dst_link_failure for IPv6.