Skip to content

Commit

Permalink
net: allow to kill a task which waits net_mutex in copy_new_ns
Browse files Browse the repository at this point in the history
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" <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Signed-off-by: Andrei Vagin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
avagin authored and davem330 committed Oct 23, 2016
1 parent d65f2fa commit 7281a66
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7281a66

Please sign in to comment.