Skip to content

Commit

Permalink
net: kernel socket should be released in init_net namespace
Browse files Browse the repository at this point in the history
Creating a kernel socket with sock_create_kern() happens in "init_net"
namespace, however, releasing it with sk_release_kernel() occurs in
the current namespace which may be different with "init_net" namespace.
Therefore, we should guarantee that the namespace in which a kernel
socket is created is same as the socket is created.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ying Xue authored and David S. Miller committed Mar 16, 2015
1 parent db4374f commit c243d7e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,8 @@ void sk_release_kernel(struct sock *sk)
return;

sock_hold(sk);
sock_release(sk->sk_socket);
sock_net_set(sk, get_net(&init_net));
sock_release(sk->sk_socket);
sock_put(sk);
}
EXPORT_SYMBOL(sk_release_kernel);
Expand Down

0 comments on commit c243d7e

Please sign in to comment.