All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipv6: release rt6->rt6i_idev properly during ifdown
@ 2017-08-14 17:44 Wei Wang
  2017-08-14 19:05 ` David Ahern
  2017-08-15  5:19 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Wang @ 2017-08-14 17:44 UTC (permalink / raw)
  To: David Miller, netdev; +Cc: Martin KaFai Lau, David Ahern, Wei Wang

From: Wei Wang <weiwan@google.com>

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()")
Reported-by: John Stultz <john.stultz@linaro.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Tested-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Wei Wang <weiwan@google.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
 net/ipv6/route.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4d30c96a819d..8d53abd96181 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -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);
 		}
 	}
 }
-- 
2.14.0.434.g98096fd7a8-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] ipv6: release rt6->rt6i_idev properly during ifdown
  2017-08-14 17:44 [PATCH net] ipv6: release rt6->rt6i_idev properly during ifdown Wei Wang
@ 2017-08-14 19:05 ` David Ahern
  2017-08-15  5:19 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2017-08-14 19:05 UTC (permalink / raw)
  To: Wei Wang, David Miller, netdev; +Cc: Martin KaFai Lau

On 8/14/17 11:44 AM, Wei Wang wrote:
> From: Wei Wang <weiwan@google.com>
> 
> 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()")
> Reported-by: John Stultz <john.stultz@linaro.org>
> Tested-by: John Stultz <john.stultz@linaro.org>
> Tested-by: Martin KaFai Lau <kafai@fb.com>
> Signed-off-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
>  net/ipv6/route.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)

Acked-by: David Ahern <dsahern@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] ipv6: release rt6->rt6i_idev properly during ifdown
  2017-08-14 17:44 [PATCH net] ipv6: release rt6->rt6i_idev properly during ifdown Wei Wang
  2017-08-14 19:05 ` David Ahern
@ 2017-08-15  5:19 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-08-15  5:19 UTC (permalink / raw)
  To: weiwan; +Cc: netdev, kafai, dsahern

From: Wei Wang <weiwan@google.com>
Date: Mon, 14 Aug 2017 10:44:59 -0700

> From: Wei Wang <weiwan@google.com>
> 
> 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()")
> Reported-by: John Stultz <john.stultz@linaro.org>
> Tested-by: John Stultz <john.stultz@linaro.org>
> Tested-by: Martin KaFai Lau <kafai@fb.com>
> Signed-off-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-15  5:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-14 17:44 [PATCH net] ipv6: release rt6->rt6i_idev properly during ifdown Wei Wang
2017-08-14 19:05 ` David Ahern
2017-08-15  5:19 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.