Skip to contentSkip to conversation

ipv6: release rt6->rt6i_idev properly during ifdown

PATCH Applied Wei Wang 3 participants 3 messages Aug 14, 2017 – Aug 15, 2017

Subsystems (3)
lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH 1/1 ipv6: release rt6->rt6i_idev properly during ifdown

From: Wei Wang <[email protected]>

When a dst is created by addrconf_dst_alloc() for a host route or an anycast route, dst->dev points to loopback dev while rt6->rt6i_idev points to a real device.
When the real device goes down, the current cleanup code only checks for dst->dev and assumes rt6->rt6i_idev->dev is the same. This causes the refcount leak on the real device in the above situation. This patch makes sure to always release the refcount taken on rt6->rt6i_idev during dst_dev_put().

Fixes 587fea741134 ("ipv6: mark DST_NOGC and remove the operation of

dst_free()")

---
 net/ipv6/route.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
net/ipv6/route.c +5 -8
index 4d30c96a819d..8d53abd96181 100644
@@ -417,14 +417,11 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
 	struct net_device *loopback_dev =
 		dev_net(dev)->loopback_dev;
 
-	if (dev != loopback_dev) {
-		if (idev && idev->dev == dev) {
-			struct inet6_dev *loopback_idev =
-				in6_dev_get(loopback_dev);
-			if (loopback_idev) {
-				rt->rt6i_idev = loopback_idev;
-				in6_dev_put(idev);
-			}
+	if (idev && idev->dev != loopback_dev) {
+		struct inet6_dev *loopback_idev = in6_dev_get(loopback_dev);
+		if (loopback_idev) {
+			rt->rt6i_idev = loopback_idev;
+			in6_dev_put(idev);
 		}
 	}
 }
Signature · 1 line
2.14.0.434.g98096fd7a8-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Wei Wang

From: Wei Wang <[email protected]>

When a dst is created by addrconf_dst_alloc() for a host route or an anycast route, dst->dev points to loopback dev while rt6->rt6i_idev points to a real device.
When the real device goes down, the current cleanup code only checks for dst->dev and assumes rt6->rt6i_idev->dev is the same. This causes the refcount leak on the real device in the above situation. This patch makes sure to always release the refcount taken on rt6->rt6i_idev during dst_dev_put().

Fixes 587fea741134 ("ipv6: mark DST_NOGC and remove the operation of

dst_free()")

Quoted 8 lines
---
 net/ipv6/route.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
maintainer Applied
#2 lore raw
In reply to Wei Wang

From: Wei Wang <[email protected]>
Date: Mon, 14 Aug 2017 10:44:59 -0700

Quoted 11 lines

From: Wei Wang <[email protected]>

When a dst is created by addrconf_dst_alloc() for a host route or an anycast route, dst->dev points to loopback dev while rt6->rt6i_idev points to a real device.
When the real device goes down, the current cleanup code only checks for dst->dev and assumes rt6->rt6i_idev->dev is the same. This causes the refcount leak on the real device in the above situation. This patch makes sure to always release the refcount taken on rt6->rt6i_idev during dst_dev_put().

Quoted 7 lines
Fixes 587fea741134 ("ipv6: mark DST_NOGC and remove the operation of

dst_free()")

Applied, thank you.