diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2007-10-12 21:27:47 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2007-10-12 21:27:47 -0400 |
commit | b981d8b3f5e008ff10d993be633ad00564fc22cd (patch) | |
tree | e292dc07b22308912cf6a58354a608b9e5e8e1fd /net/socket.c | |
parent | b11d2127c4893a7315d1e16273bc8560049fa3ca (diff) | |
parent | 2b9e0aae1d50e880c58d46788e5e3ebd89d75d62 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
drivers/macintosh/adbhid.c
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/net/socket.c b/net/socket.c index b71114250046..379b3a390755 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -84,6 +84,7 @@ | |||
84 | #include <linux/kmod.h> | 84 | #include <linux/kmod.h> |
85 | #include <linux/audit.h> | 85 | #include <linux/audit.h> |
86 | #include <linux/wireless.h> | 86 | #include <linux/wireless.h> |
87 | #include <linux/nsproxy.h> | ||
87 | 88 | ||
88 | #include <asm/uaccess.h> | 89 | #include <asm/uaccess.h> |
89 | #include <asm/unistd.h> | 90 | #include <asm/unistd.h> |
@@ -272,8 +273,7 @@ static int init_inodecache(void) | |||
272 | (SLAB_HWCACHE_ALIGN | | 273 | (SLAB_HWCACHE_ALIGN | |
273 | SLAB_RECLAIM_ACCOUNT | | 274 | SLAB_RECLAIM_ACCOUNT | |
274 | SLAB_MEM_SPREAD), | 275 | SLAB_MEM_SPREAD), |
275 | init_once, | 276 | init_once); |
276 | NULL); | ||
277 | if (sock_inode_cachep == NULL) | 277 | if (sock_inode_cachep == NULL) |
278 | return -ENOMEM; | 278 | return -ENOMEM; |
279 | return 0; | 279 | return 0; |
@@ -778,9 +778,6 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
778 | if (pos != 0) | 778 | if (pos != 0) |
779 | return -ESPIPE; | 779 | return -ESPIPE; |
780 | 780 | ||
781 | if (iocb->ki_left == 0) /* Match SYS5 behaviour */ | ||
782 | return 0; | ||
783 | |||
784 | x = alloc_sock_iocb(iocb, &siocb); | 781 | x = alloc_sock_iocb(iocb, &siocb); |
785 | if (!x) | 782 | if (!x) |
786 | return -ENOMEM; | 783 | return -ENOMEM; |
@@ -794,9 +791,9 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
794 | */ | 791 | */ |
795 | 792 | ||
796 | static DEFINE_MUTEX(br_ioctl_mutex); | 793 | static DEFINE_MUTEX(br_ioctl_mutex); |
797 | static int (*br_ioctl_hook) (unsigned int cmd, void __user *arg) = NULL; | 794 | static int (*br_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg) = NULL; |
798 | 795 | ||
799 | void brioctl_set(int (*hook) (unsigned int, void __user *)) | 796 | void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *)) |
800 | { | 797 | { |
801 | mutex_lock(&br_ioctl_mutex); | 798 | mutex_lock(&br_ioctl_mutex); |
802 | br_ioctl_hook = hook; | 799 | br_ioctl_hook = hook; |
@@ -806,9 +803,9 @@ void brioctl_set(int (*hook) (unsigned int, void __user *)) | |||
806 | EXPORT_SYMBOL(brioctl_set); | 803 | EXPORT_SYMBOL(brioctl_set); |
807 | 804 | ||
808 | static DEFINE_MUTEX(vlan_ioctl_mutex); | 805 | static DEFINE_MUTEX(vlan_ioctl_mutex); |
809 | static int (*vlan_ioctl_hook) (void __user *arg); | 806 | static int (*vlan_ioctl_hook) (struct net *, void __user *arg); |
810 | 807 | ||
811 | void vlan_ioctl_set(int (*hook) (void __user *)) | 808 | void vlan_ioctl_set(int (*hook) (struct net *, void __user *)) |
812 | { | 809 | { |
813 | mutex_lock(&vlan_ioctl_mutex); | 810 | mutex_lock(&vlan_ioctl_mutex); |
814 | vlan_ioctl_hook = hook; | 811 | vlan_ioctl_hook = hook; |
@@ -837,16 +834,20 @@ EXPORT_SYMBOL(dlci_ioctl_set); | |||
837 | static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | 834 | static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) |
838 | { | 835 | { |
839 | struct socket *sock; | 836 | struct socket *sock; |
837 | struct sock *sk; | ||
840 | void __user *argp = (void __user *)arg; | 838 | void __user *argp = (void __user *)arg; |
841 | int pid, err; | 839 | int pid, err; |
840 | struct net *net; | ||
842 | 841 | ||
843 | sock = file->private_data; | 842 | sock = file->private_data; |
843 | sk = sock->sk; | ||
844 | net = sk->sk_net; | ||
844 | if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) { | 845 | if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) { |
845 | err = dev_ioctl(cmd, argp); | 846 | err = dev_ioctl(net, cmd, argp); |
846 | } else | 847 | } else |
847 | #ifdef CONFIG_WIRELESS_EXT | 848 | #ifdef CONFIG_WIRELESS_EXT |
848 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) { | 849 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) { |
849 | err = dev_ioctl(cmd, argp); | 850 | err = dev_ioctl(net, cmd, argp); |
850 | } else | 851 | } else |
851 | #endif /* CONFIG_WIRELESS_EXT */ | 852 | #endif /* CONFIG_WIRELESS_EXT */ |
852 | switch (cmd) { | 853 | switch (cmd) { |
@@ -872,7 +873,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
872 | 873 | ||
873 | mutex_lock(&br_ioctl_mutex); | 874 | mutex_lock(&br_ioctl_mutex); |
874 | if (br_ioctl_hook) | 875 | if (br_ioctl_hook) |
875 | err = br_ioctl_hook(cmd, argp); | 876 | err = br_ioctl_hook(net, cmd, argp); |
876 | mutex_unlock(&br_ioctl_mutex); | 877 | mutex_unlock(&br_ioctl_mutex); |
877 | break; | 878 | break; |
878 | case SIOCGIFVLAN: | 879 | case SIOCGIFVLAN: |
@@ -883,7 +884,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
883 | 884 | ||
884 | mutex_lock(&vlan_ioctl_mutex); | 885 | mutex_lock(&vlan_ioctl_mutex); |
885 | if (vlan_ioctl_hook) | 886 | if (vlan_ioctl_hook) |
886 | err = vlan_ioctl_hook(argp); | 887 | err = vlan_ioctl_hook(net, argp); |
887 | mutex_unlock(&vlan_ioctl_mutex); | 888 | mutex_unlock(&vlan_ioctl_mutex); |
888 | break; | 889 | break; |
889 | case SIOCADDDLCI: | 890 | case SIOCADDDLCI: |
@@ -906,7 +907,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
906 | * to the NIC driver. | 907 | * to the NIC driver. |
907 | */ | 908 | */ |
908 | if (err == -ENOIOCTLCMD) | 909 | if (err == -ENOIOCTLCMD) |
909 | err = dev_ioctl(cmd, argp); | 910 | err = dev_ioctl(net, cmd, argp); |
910 | break; | 911 | break; |
911 | } | 912 | } |
912 | return err; | 913 | return err; |
@@ -1075,7 +1076,7 @@ call_kill: | |||
1075 | return 0; | 1076 | return 0; |
1076 | } | 1077 | } |
1077 | 1078 | ||
1078 | static int __sock_create(int family, int type, int protocol, | 1079 | static int __sock_create(struct net *net, int family, int type, int protocol, |
1079 | struct socket **res, int kern) | 1080 | struct socket **res, int kern) |
1080 | { | 1081 | { |
1081 | int err; | 1082 | int err; |
@@ -1151,7 +1152,7 @@ static int __sock_create(int family, int type, int protocol, | |||
1151 | /* Now protected by module ref count */ | 1152 | /* Now protected by module ref count */ |
1152 | rcu_read_unlock(); | 1153 | rcu_read_unlock(); |
1153 | 1154 | ||
1154 | err = pf->create(sock, protocol); | 1155 | err = pf->create(net, sock, protocol); |
1155 | if (err < 0) | 1156 | if (err < 0) |
1156 | goto out_module_put; | 1157 | goto out_module_put; |
1157 | 1158 | ||
@@ -1169,7 +1170,7 @@ static int __sock_create(int family, int type, int protocol, | |||
1169 | module_put(pf->owner); | 1170 | module_put(pf->owner); |
1170 | err = security_socket_post_create(sock, family, type, protocol, kern); | 1171 | err = security_socket_post_create(sock, family, type, protocol, kern); |
1171 | if (err) | 1172 | if (err) |
1172 | goto out_release; | 1173 | goto out_sock_release; |
1173 | *res = sock; | 1174 | *res = sock; |
1174 | 1175 | ||
1175 | return 0; | 1176 | return 0; |
@@ -1190,12 +1191,12 @@ out_release: | |||
1190 | 1191 | ||
1191 | int sock_create(int family, int type, int protocol, struct socket **res) | 1192 | int sock_create(int family, int type, int protocol, struct socket **res) |
1192 | { | 1193 | { |
1193 | return __sock_create(family, type, protocol, res, 0); | 1194 | return __sock_create(current->nsproxy->net_ns, family, type, protocol, res, 0); |
1194 | } | 1195 | } |
1195 | 1196 | ||
1196 | int sock_create_kern(int family, int type, int protocol, struct socket **res) | 1197 | int sock_create_kern(int family, int type, int protocol, struct socket **res) |
1197 | { | 1198 | { |
1198 | return __sock_create(family, type, protocol, res, 1); | 1199 | return __sock_create(&init_net, family, type, protocol, res, 1); |
1199 | } | 1200 | } |
1200 | 1201 | ||
1201 | asmlinkage long sys_socket(int family, int type, int protocol) | 1202 | asmlinkage long sys_socket(int family, int type, int protocol) |
@@ -1928,7 +1929,7 @@ asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg, | |||
1928 | * kernel msghdr to use the kernel address space) | 1929 | * kernel msghdr to use the kernel address space) |
1929 | */ | 1930 | */ |
1930 | 1931 | ||
1931 | uaddr = (void __user *)msg_sys.msg_name; | 1932 | uaddr = (__force void __user *)msg_sys.msg_name; |
1932 | uaddr_len = COMPAT_NAMELEN(msg); | 1933 | uaddr_len = COMPAT_NAMELEN(msg); |
1933 | if (MSG_CMSG_COMPAT & flags) { | 1934 | if (MSG_CMSG_COMPAT & flags) { |
1934 | err = verify_compat_iovec(&msg_sys, iov, addr, VERIFY_WRITE); | 1935 | err = verify_compat_iovec(&msg_sys, iov, addr, VERIFY_WRITE); |
@@ -2234,6 +2235,7 @@ int kernel_accept(struct socket *sock, struct socket **newsock, int flags) | |||
2234 | err = sock->ops->accept(sock, *newsock, flags); | 2235 | err = sock->ops->accept(sock, *newsock, flags); |
2235 | if (err < 0) { | 2236 | if (err < 0) { |
2236 | sock_release(*newsock); | 2237 | sock_release(*newsock); |
2238 | *newsock = NULL; | ||
2237 | goto done; | 2239 | goto done; |
2238 | } | 2240 | } |
2239 | 2241 | ||