diff options
author | Andrey Vagin <avagin@openvz.org> | 2016-10-20 19:45:43 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-10-23 17:33:39 -0400 |
commit | 7281a66590cbc284272e18cb4acbfb88ddaa4cd8 (patch) | |
tree | 868b3edae32487a1fc7d9662dc5d52768160a693 /net/core/net_namespace.c | |
parent | d65f2fa680d6f91438461df54c83a331b3a631c9 (diff) | |
download | linux-stable-7281a66590cbc284272e18cb4acbfb88ddaa4cd8.tar.gz linux-stable-7281a66590cbc284272e18cb4acbfb88ddaa4cd8.tar.bz2 linux-stable-7281a66590cbc284272e18cb4acbfb88ddaa4cd8.zip |
net: allow to kill a task which waits net_mutex in copy_new_ns
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/net_namespace.c')
-rw-r--r-- | net/core/net_namespace.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 989434f36f96..b9243b14af17 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) { |