Skip to content

Commit 7281a66

Browse files
avagindavem330
authored andcommitted
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" <[email protected]> Cc: Eric W. Biederman <[email protected]> Signed-off-by: Andrei Vagin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d65f2fa commit 7281a66

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

net/core/net_namespace.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,14 @@ struct net *copy_net_ns(unsigned long flags,
379379

380380
get_user_ns(user_ns);
381381

382-
mutex_lock(&net_mutex);
382+
rv = mutex_lock_killable(&net_mutex);
383+
if (rv < 0) {
384+
net_free(net);
385+
dec_net_namespaces(ucounts);
386+
put_user_ns(user_ns);
387+
return ERR_PTR(rv);
388+
}
389+
383390
net->ucounts = ucounts;
384391
rv = setup_net(net, user_ns);
385392
if (rv == 0) {

0 commit comments

Comments
 (0)