aboutsummaryrefslogtreecommitdiffstats
path: root/net/x25
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-10-09 02:24:22 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:49:07 -0400
commit1b8d7ae42d02e483ad94035cca851e4f7fbecb40 (patch)
tree81f8cc0ee49ef99cc67dfed3dc7b7ecb510abf8b /net/x25
parent457c4cbc5a3dde259d2a1f15d5f9785290397267 (diff)
[NET]: Make socket creation namespace safe.
This patch passes in the namespace a new socket should be created in and has the socket code do the appropriate reference counting. By virtue of this all socket create methods are touched. In addition the socket create methods are modified so that they will fail if you attempt to create a socket in a non-default network namespace. Failing if we attempt to create a socket outside of the default network namespace ensures that as we incrementally make the network stack network namespace aware we will not export functionality that someone has not audited and made certain is network namespace safe. Allowing us to partially enable network namespaces before all of the exotic protocols are supported. Any protocol layers I have missed will fail to compile because I now pass an extra parameter into the socket creation code. [ Integrated AF_IUCV build fixes from Andrew Morton... -DaveM ] Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/x25')
-rw-r--r--net/x25/af_x25.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 479927cb45ca..2e9931571a4d 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -466,10 +466,10 @@ static struct proto x25_proto = {
466 .obj_size = sizeof(struct x25_sock), 466 .obj_size = sizeof(struct x25_sock),
467}; 467};
468 468
469static struct sock *x25_alloc_socket(void) 469static struct sock *x25_alloc_socket(struct net *net)
470{ 470{
471 struct x25_sock *x25; 471 struct x25_sock *x25;
472 struct sock *sk = sk_alloc(AF_X25, GFP_ATOMIC, &x25_proto, 1); 472 struct sock *sk = sk_alloc(net, AF_X25, GFP_ATOMIC, &x25_proto, 1);
473 473
474 if (!sk) 474 if (!sk)
475 goto out; 475 goto out;
@@ -485,17 +485,20 @@ out:
485 return sk; 485 return sk;
486} 486}
487 487
488static int x25_create(struct socket *sock, int protocol) 488static int x25_create(struct net *net, struct socket *sock, int protocol)
489{ 489{
490 struct sock *sk; 490 struct sock *sk;
491 struct x25_sock *x25; 491 struct x25_sock *x25;
492 int rc = -ESOCKTNOSUPPORT; 492 int rc = -ESOCKTNOSUPPORT;
493 493
494 if (net != &init_net)
495 return -EAFNOSUPPORT;
496
494 if (sock->type != SOCK_SEQPACKET || protocol) 497 if (sock->type != SOCK_SEQPACKET || protocol)
495 goto out; 498 goto out;
496 499
497 rc = -ENOMEM; 500 rc = -ENOMEM;
498 if ((sk = x25_alloc_socket()) == NULL) 501 if ((sk = x25_alloc_socket(net)) == NULL)
499 goto out; 502 goto out;
500 503
501 x25 = x25_sk(sk); 504 x25 = x25_sk(sk);
@@ -543,7 +546,7 @@ static struct sock *x25_make_new(struct sock *osk)
543 if (osk->sk_type != SOCK_SEQPACKET) 546 if (osk->sk_type != SOCK_SEQPACKET)
544 goto out; 547 goto out;
545 548
546 if ((sk = x25_alloc_socket()) == NULL) 549 if ((sk = x25_alloc_socket(osk->sk_net)) == NULL)
547 goto out; 550 goto out;
548 551
549 x25 = x25_sk(sk); 552 x25 = x25_sk(sk);