diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-10-09 02:24:22 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:49:07 -0400 |
commit | 1b8d7ae42d02e483ad94035cca851e4f7fbecb40 (patch) | |
tree | 81f8cc0ee49ef99cc67dfed3dc7b7ecb510abf8b /net/atm | |
parent | 457c4cbc5a3dde259d2a1f15d5f9785290397267 (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/atm')
-rw-r--r-- | net/atm/common.c | 4 | ||||
-rw-r--r-- | net/atm/common.h | 2 | ||||
-rw-r--r-- | net/atm/pvc.c | 7 | ||||
-rw-r--r-- | net/atm/svc.c | 11 |
4 files changed, 15 insertions, 9 deletions
diff --git a/net/atm/common.c b/net/atm/common.c index 299ec1eb872a..e166d9e0ffd9 100644 --- a/net/atm/common.c +++ b/net/atm/common.c | |||
@@ -125,7 +125,7 @@ static struct proto vcc_proto = { | |||
125 | .obj_size = sizeof(struct atm_vcc), | 125 | .obj_size = sizeof(struct atm_vcc), |
126 | }; | 126 | }; |
127 | 127 | ||
128 | int vcc_create(struct socket *sock, int protocol, int family) | 128 | int vcc_create(struct net *net, struct socket *sock, int protocol, int family) |
129 | { | 129 | { |
130 | struct sock *sk; | 130 | struct sock *sk; |
131 | struct atm_vcc *vcc; | 131 | struct atm_vcc *vcc; |
@@ -133,7 +133,7 @@ int vcc_create(struct socket *sock, int protocol, int family) | |||
133 | sock->sk = NULL; | 133 | sock->sk = NULL; |
134 | if (sock->type == SOCK_STREAM) | 134 | if (sock->type == SOCK_STREAM) |
135 | return -EINVAL; | 135 | return -EINVAL; |
136 | sk = sk_alloc(family, GFP_KERNEL, &vcc_proto, 1); | 136 | sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto, 1); |
137 | if (!sk) | 137 | if (!sk) |
138 | return -ENOMEM; | 138 | return -ENOMEM; |
139 | sock_init_data(sock, sk); | 139 | sock_init_data(sock, sk); |
diff --git a/net/atm/common.h b/net/atm/common.h index ad78c9e1117d..16f32c1fa1c9 100644 --- a/net/atm/common.h +++ b/net/atm/common.h | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/poll.h> /* for poll_table */ | 10 | #include <linux/poll.h> /* for poll_table */ |
11 | 11 | ||
12 | 12 | ||
13 | int vcc_create(struct socket *sock, int protocol, int family); | 13 | int vcc_create(struct net *net, struct socket *sock, int protocol, int family); |
14 | int vcc_release(struct socket *sock); | 14 | int vcc_release(struct socket *sock); |
15 | int vcc_connect(struct socket *sock, int itf, short vpi, int vci); | 15 | int vcc_connect(struct socket *sock, int itf, short vpi, int vci); |
16 | int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, | 16 | int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, |
diff --git a/net/atm/pvc.c b/net/atm/pvc.c index 848e6e191cc7..43e8bf5ed001 100644 --- a/net/atm/pvc.c +++ b/net/atm/pvc.c | |||
@@ -124,10 +124,13 @@ static const struct proto_ops pvc_proto_ops = { | |||
124 | }; | 124 | }; |
125 | 125 | ||
126 | 126 | ||
127 | static int pvc_create(struct socket *sock,int protocol) | 127 | static int pvc_create(struct net *net, struct socket *sock,int protocol) |
128 | { | 128 | { |
129 | if (net != &init_net) | ||
130 | return -EAFNOSUPPORT; | ||
131 | |||
129 | sock->ops = &pvc_proto_ops; | 132 | sock->ops = &pvc_proto_ops; |
130 | return vcc_create(sock, protocol, PF_ATMPVC); | 133 | return vcc_create(net, sock, protocol, PF_ATMPVC); |
131 | } | 134 | } |
132 | 135 | ||
133 | 136 | ||
diff --git a/net/atm/svc.c b/net/atm/svc.c index 53d04c7992cf..daf9a48a7db0 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "signaling.h" | 25 | #include "signaling.h" |
26 | #include "addr.h" | 26 | #include "addr.h" |
27 | 27 | ||
28 | static int svc_create(struct socket *sock,int protocol); | 28 | static int svc_create(struct net *net, struct socket *sock,int protocol); |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * Note: since all this is still nicely synchronized with the signaling demon, | 31 | * Note: since all this is still nicely synchronized with the signaling demon, |
@@ -326,7 +326,7 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags) | |||
326 | 326 | ||
327 | lock_sock(sk); | 327 | lock_sock(sk); |
328 | 328 | ||
329 | error = svc_create(newsock,0); | 329 | error = svc_create(sk->sk_net, newsock,0); |
330 | if (error) | 330 | if (error) |
331 | goto out; | 331 | goto out; |
332 | 332 | ||
@@ -627,12 +627,15 @@ static const struct proto_ops svc_proto_ops = { | |||
627 | }; | 627 | }; |
628 | 628 | ||
629 | 629 | ||
630 | static int svc_create(struct socket *sock,int protocol) | 630 | static int svc_create(struct net *net, struct socket *sock,int protocol) |
631 | { | 631 | { |
632 | int error; | 632 | int error; |
633 | 633 | ||
634 | if (net != &init_net) | ||
635 | return -EAFNOSUPPORT; | ||
636 | |||
634 | sock->ops = &svc_proto_ops; | 637 | sock->ops = &svc_proto_ops; |
635 | error = vcc_create(sock, protocol, AF_ATMSVC); | 638 | error = vcc_create(net, sock, protocol, AF_ATMSVC); |
636 | if (error) return error; | 639 | if (error) return error; |
637 | ATM_SD(sock)->local.sas_family = AF_ATMSVC; | 640 | ATM_SD(sock)->local.sas_family = AF_ATMSVC; |
638 | ATM_SD(sock)->remote.sas_family = AF_ATMSVC; | 641 | ATM_SD(sock)->remote.sas_family = AF_ATMSVC; |