linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: allow to kill a task which waits net_mutex in copy_new_ns
@ 2016-10-21  2:45 Andrei Vagin
  2016-10-23 21:34 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Andrei Vagin @ 2016-10-21  2:45 UTC (permalink / raw)
  To: David S. Miller
  Cc: Eric W . Biederman, containers, linux-kernel, netdev, Andrey Vagin

From: Andrey Vagin <avagin@openvz.org>

net_mutex can be locked for a long time. It may be because many
namespaces are being destroyed or many processes decide to create
a network namespace.

Both these operations are heavy, so it is better to have an ability to
kill a process which is waiting net_mutex.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Andrei Vagin <avagin@openvz.org>
---
 net/core/net_namespace.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 989434f..b9243b1 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -379,7 +379,14 @@ struct net *copy_net_ns(unsigned long flags,
 
 	get_user_ns(user_ns);
 
-	mutex_lock(&net_mutex);
+	rv = mutex_lock_killable(&net_mutex);
+	if (rv < 0) {
+		net_free(net);
+		dec_net_namespaces(ucounts);
+		put_user_ns(user_ns);
+		return ERR_PTR(rv);
+	}
+
 	net->ucounts = ucounts;
 	rv = setup_net(net, user_ns);
 	if (rv == 0) {
-- 
2.7.4

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

* Re: [PATCH net-next] net: allow to kill a task which waits net_mutex in copy_new_ns
  2016-10-21  2:45 [PATCH net-next] net: allow to kill a task which waits net_mutex in copy_new_ns Andrei Vagin
@ 2016-10-23 21:34 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-10-23 21:34 UTC (permalink / raw)
  To: avagin; +Cc: ebiederm, containers, linux-kernel, netdev

From: Andrei Vagin <avagin@openvz.org>
Date: Thu, 20 Oct 2016 19:45:43 -0700

> From: Andrey Vagin <avagin@openvz.org>
> 
> net_mutex can be locked for a long time. It may be because many
> namespaces are being destroyed or many processes decide to create
> a network namespace.
> 
> Both these operations are heavy, so it is better to have an ability to
> kill a process which is waiting net_mutex.
> 
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric W. Biederman <ebiederm@xmission.com>
> Signed-off-by: Andrei Vagin <avagin@openvz.org>

Applied, thanks.

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

end of thread, other threads:[~2016-10-23 21:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21  2:45 [PATCH net-next] net: allow to kill a task which waits net_mutex in copy_new_ns Andrei Vagin
2016-10-23 21:34 ` David Miller

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).