aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda
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/irda
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/irda')
-rw-r--r--net/irda/af_irda.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index c80949a71923..0328ae2654f4 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -60,7 +60,7 @@
60 60
61#include <net/irda/af_irda.h> 61#include <net/irda/af_irda.h>
62 62
63static int irda_create(struct socket *sock, int protocol); 63static int irda_create(struct net *net, struct socket *sock, int protocol);
64 64
65static const struct proto_ops irda_stream_ops; 65static const struct proto_ops irda_stream_ops;
66static const struct proto_ops irda_seqpacket_ops; 66static const struct proto_ops irda_seqpacket_ops;
@@ -831,7 +831,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
831 831
832 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 832 IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
833 833
834 err = irda_create(newsock, sk->sk_protocol); 834 err = irda_create(sk->sk_net, newsock, sk->sk_protocol);
835 if (err) 835 if (err)
836 return err; 836 return err;
837 837
@@ -1057,13 +1057,16 @@ static struct proto irda_proto = {
1057 * Create IrDA socket 1057 * Create IrDA socket
1058 * 1058 *
1059 */ 1059 */
1060static int irda_create(struct socket *sock, int protocol) 1060static int irda_create(struct net *net, struct socket *sock, int protocol)
1061{ 1061{
1062 struct sock *sk; 1062 struct sock *sk;
1063 struct irda_sock *self; 1063 struct irda_sock *self;
1064 1064
1065 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 1065 IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
1066 1066
1067 if (net != &init_net)
1068 return -EAFNOSUPPORT;
1069
1067 /* Check for valid socket type */ 1070 /* Check for valid socket type */
1068 switch (sock->type) { 1071 switch (sock->type) {
1069 case SOCK_STREAM: /* For TTP connections with SAR disabled */ 1072 case SOCK_STREAM: /* For TTP connections with SAR disabled */
@@ -1075,7 +1078,7 @@ static int irda_create(struct socket *sock, int protocol)
1075 } 1078 }
1076 1079
1077 /* Allocate networking socket */ 1080 /* Allocate networking socket */
1078 sk = sk_alloc(PF_IRDA, GFP_ATOMIC, &irda_proto, 1); 1081 sk = sk_alloc(net, PF_IRDA, GFP_ATOMIC, &irda_proto, 1);
1079 if (sk == NULL) 1082 if (sk == NULL)
1080 return -ENOMEM; 1083 return -ENOMEM;
1081 1084