netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net_namespace: fixed net_device reference leak
@ 2016-09-08  1:55 Jojy Varghese
  2016-09-08 19:08 ` Jojy Varghese
  0 siblings, 1 reply; 16+ messages in thread
From: Jojy Varghese @ 2016-09-08  1:55 UTC (permalink / raw)
  To: netdev; +Cc: davem

During namespace cleanup, if ‘dst’ subsystem is holding
a reference to the loopback interface in the namespace, it does not get
released. This is because in the case where the net_device held by 'dst'
is same as the namespace's loopback net_device, current code first
does a ’dev_hold’ on the same device followed by a ‘dev_put’ on the
same device resulting in a no-op.

This change fixes this leak by assigning the initial namespace’s loopback
device to the ‘dst’’ before releasing the reference to the network device
being unregistered.

Additional reference: https://github.com/docker/docker/issues/5618

Signed-off-by: Jojy G Varghese <jojy.varghese@gmail.com>
---
 net/core/dst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dst.c b/net/core/dst.c
index a1656e3..a18e8ea 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -433,7 +433,7 @@ static void dst_ifdown(struct dst_entry *dst,
struct net_device *dev,
                dst->input = dst_discard;
                dst->output = dst_discard_out;
        } else {
-               dst->dev = dev_net(dst->dev)->loopback_dev;
+               dst->dev = init_net.loopback_dev;
                dev_hold(dst->dev);
                dev_put(dev);
        }
-- 
1.8.3.1

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

end of thread, other threads:[~2016-09-10 16:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-08  1:55 [PATCH] net_namespace: fixed net_device reference leak Jojy Varghese
2016-09-08 19:08 ` Jojy Varghese
2016-09-08 19:32   ` Lance Richardson
2016-09-08 21:00   ` Eric Dumazet
2016-09-08 21:05     ` Eric Dumazet
2016-09-08 22:12       ` Jojy Varghese
2016-09-08 22:16         ` Eric Dumazet
2016-09-08 23:16           ` Jojy Varghese
2016-09-08 23:33             ` Jojy Varghese
2016-09-08 23:51               ` Eric Dumazet
2016-09-09  0:04               ` David Miller
2016-09-09  0:35                 ` Jojy Varghese
2016-09-09  0:39                   ` David Miller
2016-09-09  2:35                   ` Eric Dumazet
2016-09-10 16:12                   ` David Ahern
2016-09-08 23:37             ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).