[NET]: Make socket creation namespace safe.
[deliverable/linux.git] / net / irda / af_irda.c
index c80949a719239255061075e158bc70dd43e015ab..0328ae2654f43333fc09980368dec290641d24fb 100644 (file)
@@ -60,7 +60,7 @@
 
 #include <net/irda/af_irda.h>
 
-static int irda_create(struct socket *sock, int protocol);
+static int irda_create(struct net *net, struct socket *sock, int protocol);
 
 static const struct proto_ops irda_stream_ops;
 static const struct proto_ops irda_seqpacket_ops;
@@ -831,7 +831,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
-       err = irda_create(newsock, sk->sk_protocol);
+       err = irda_create(sk->sk_net, newsock, sk->sk_protocol);
        if (err)
                return err;
 
@@ -1057,13 +1057,16 @@ static struct proto irda_proto = {
  *    Create IrDA socket
  *
  */
-static int irda_create(struct socket *sock, int protocol)
+static int irda_create(struct net *net, struct socket *sock, int protocol)
 {
        struct sock *sk;
        struct irda_sock *self;
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
+       if (net != &init_net)
+               return -EAFNOSUPPORT;
+
        /* Check for valid socket type */
        switch (sock->type) {
        case SOCK_STREAM:     /* For TTP connections with SAR disabled */
@@ -1075,7 +1078,7 @@ static int irda_create(struct socket *sock, int protocol)
        }
 
        /* Allocate networking socket */
-       sk = sk_alloc(PF_IRDA, GFP_ATOMIC, &irda_proto, 1);
+       sk = sk_alloc(net, PF_IRDA, GFP_ATOMIC, &irda_proto, 1);
        if (sk == NULL)
                return -ENOMEM;
 
This page took 0.025608 seconds and 5 git commands to generate.