aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index a05c34260e70..2b57eaf66abc 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -103,6 +103,7 @@
103#include <asm/uaccess.h> 103#include <asm/uaccess.h>
104#include <linux/skbuff.h> 104#include <linux/skbuff.h>
105#include <linux/netdevice.h> 105#include <linux/netdevice.h>
106#include <net/net_namespace.h>
106#include <net/sock.h> 107#include <net/sock.h>
107#include <net/tcp_states.h> 108#include <net/tcp_states.h>
108#include <net/af_unix.h> 109#include <net/af_unix.h>
@@ -593,7 +594,7 @@ static struct proto unix_proto = {
593 */ 594 */
594static struct lock_class_key af_unix_sk_receive_queue_lock_key; 595static struct lock_class_key af_unix_sk_receive_queue_lock_key;
595 596
596static struct sock * unix_create1(struct socket *sock) 597static struct sock * unix_create1(struct net *net, struct socket *sock)
597{ 598{
598 struct sock *sk = NULL; 599 struct sock *sk = NULL;
599 struct unix_sock *u; 600 struct unix_sock *u;
@@ -601,7 +602,7 @@ static struct sock * unix_create1(struct socket *sock)
601 if (atomic_read(&unix_nr_socks) >= 2*get_max_files()) 602 if (atomic_read(&unix_nr_socks) >= 2*get_max_files())
602 goto out; 603 goto out;
603 604
604 sk = sk_alloc(PF_UNIX, GFP_KERNEL, &unix_proto, 1); 605 sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto, 1);
605 if (!sk) 606 if (!sk)
606 goto out; 607 goto out;
607 608
@@ -627,8 +628,11 @@ out:
627 return sk; 628 return sk;
628} 629}
629 630
630static int unix_create(struct socket *sock, int protocol) 631static int unix_create(struct net *net, struct socket *sock, int protocol)
631{ 632{
633 if (net != &init_net)
634 return -EAFNOSUPPORT;
635
632 if (protocol && protocol != PF_UNIX) 636 if (protocol && protocol != PF_UNIX)
633 return -EPROTONOSUPPORT; 637 return -EPROTONOSUPPORT;
634 638
@@ -654,7 +658,7 @@ static int unix_create(struct socket *sock, int protocol)
654 return -ESOCKTNOSUPPORT; 658 return -ESOCKTNOSUPPORT;
655 } 659 }
656 660
657 return unix_create1(sock) ? 0 : -ENOMEM; 661 return unix_create1(net, sock) ? 0 : -ENOMEM;
658} 662}
659 663
660static int unix_release(struct socket *sock) 664static int unix_release(struct socket *sock)
@@ -1038,7 +1042,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
1038 err = -ENOMEM; 1042 err = -ENOMEM;
1039 1043
1040 /* create new sock for complete connection */ 1044 /* create new sock for complete connection */
1041 newsk = unix_create1(NULL); 1045 newsk = unix_create1(sk->sk_net, NULL);
1042 if (newsk == NULL) 1046 if (newsk == NULL)
1043 goto out; 1047 goto out;
1044 1048
@@ -2082,25 +2086,7 @@ static const struct seq_operations unix_seq_ops = {
2082 2086
2083static int unix_seq_open(struct inode *inode, struct file *file) 2087static int unix_seq_open(struct inode *inode, struct file *file)
2084{ 2088{
2085 struct seq_file *seq; 2089 return seq_open_private(file, &unix_seq_ops, sizeof(int));
2086 int rc = -ENOMEM;
2087 int *iter = kmalloc(sizeof(int), GFP_KERNEL);
2088
2089 if (!iter)
2090 goto out;
2091
2092 rc = seq_open(file, &unix_seq_ops);
2093 if (rc)
2094 goto out_kfree;
2095
2096 seq = file->private_data;
2097 seq->private = iter;
2098 *iter = 0;
2099out:
2100 return rc;
2101out_kfree:
2102 kfree(iter);
2103 goto out;
2104} 2090}
2105 2091
2106static const struct file_operations unix_seq_fops = { 2092static const struct file_operations unix_seq_fops = {
@@ -2135,7 +2121,7 @@ static int __init af_unix_init(void)
2135 2121
2136 sock_register(&unix_family_ops); 2122 sock_register(&unix_family_ops);
2137#ifdef CONFIG_PROC_FS 2123#ifdef CONFIG_PROC_FS
2138 proc_net_fops_create("unix", 0, &unix_seq_fops); 2124 proc_net_fops_create(&init_net, "unix", 0, &unix_seq_fops);
2139#endif 2125#endif
2140 unix_sysctl_register(); 2126 unix_sysctl_register();
2141out: 2127out:
@@ -2146,7 +2132,7 @@ static void __exit af_unix_exit(void)
2146{ 2132{
2147 sock_unregister(PF_UNIX); 2133 sock_unregister(PF_UNIX);
2148 unix_sysctl_unregister(); 2134 unix_sysctl_unregister();
2149 proc_net_remove("unix"); 2135 proc_net_remove(&init_net, "unix");
2150 proto_unregister(&unix_proto); 2136 proto_unregister(&unix_proto);
2151} 2137}
2152 2138