]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/rose/af_rose.c
[NET]: Make socket creation namespace safe.
[mirror_ubuntu-artful-kernel.git] / net / rose / af_rose.c
index 48319f7991ac644ce04f87f9ad8d672f9a162ac0..67e06ab7f85458e356a567030669f6a5c6d3c9a7 100644 (file)
@@ -499,15 +499,18 @@ static struct proto rose_proto = {
        .obj_size = sizeof(struct rose_sock),
 };
 
-static int rose_create(struct socket *sock, int protocol)
+static int rose_create(struct net *net, struct socket *sock, int protocol)
 {
        struct sock *sk;
        struct rose_sock *rose;
 
+       if (net != &init_net)
+               return -EAFNOSUPPORT;
+
        if (sock->type != SOCK_SEQPACKET || protocol != 0)
                return -ESOCKTNOSUPPORT;
 
-       if ((sk = sk_alloc(PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL)
+       if ((sk = sk_alloc(net, PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL)
                return -ENOMEM;
 
        rose = rose_sk(sk);
@@ -545,7 +548,7 @@ static struct sock *rose_make_new(struct sock *osk)
        if (osk->sk_type != SOCK_SEQPACKET)
                return NULL;
 
-       if ((sk = sk_alloc(PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL)
+       if ((sk = sk_alloc(osk->sk_net, PF_ROSE, GFP_ATOMIC, &rose_proto, 1)) == NULL)
                return NULL;
 
        rose = rose_sk(sk);