diff mbox

[net-next] net: kernel socket should be released in init_net namespace

Message ID 1426501152-24764-1-git-send-email-ying.xue@windriver.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Ying Xue March 16, 2015, 10:19 a.m. UTC
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>
---
 net/core/sock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller March 16, 2015, 8:25 p.m. UTC | #1
From: Ying Xue <ying.xue@windriver.com>
Date: Mon, 16 Mar 2015 18:19:12 +0800

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

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/sock.c b/net/core/sock.c
index 4bc42ef..11e144e 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -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);