]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netrom/af_netrom.c
[NET]: Make socket creation namespace safe.
[linux-2.6-omap-h63xx.git] / net / netrom / af_netrom.c
index 15c8a92bd7193bc6d19d386fadeb6a23815f2c51..e969d1bc765c1d673d5c1eba1c1f23b9bed976c4 100644 (file)
@@ -409,15 +409,18 @@ static struct proto nr_proto = {
        .obj_size = sizeof(struct nr_sock),
 };
 
-static int nr_create(struct socket *sock, int protocol)
+static int nr_create(struct net *net, struct socket *sock, int protocol)
 {
        struct sock *sk;
        struct nr_sock *nr;
 
+       if (net != &init_net)
+               return -EAFNOSUPPORT;
+
        if (sock->type != SOCK_SEQPACKET || protocol != 0)
                return -ESOCKTNOSUPPORT;
 
-       if ((sk = sk_alloc(PF_NETROM, GFP_ATOMIC, &nr_proto, 1)) == NULL)
+       if ((sk = sk_alloc(net, PF_NETROM, GFP_ATOMIC, &nr_proto, 1)) == NULL)
                return -ENOMEM;
 
        nr = nr_sk(sk);
@@ -459,7 +462,7 @@ static struct sock *nr_make_new(struct sock *osk)
        if (osk->sk_type != SOCK_SEQPACKET)
                return NULL;
 
-       if ((sk = sk_alloc(PF_NETROM, GFP_ATOMIC, osk->sk_prot, 1)) == NULL)
+       if ((sk = sk_alloc(osk->sk_net, PF_NETROM, GFP_ATOMIC, osk->sk_prot, 1)) == NULL)
                return NULL;
 
        nr = nr_sk(sk);