diff options
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 186 |
1 files changed, 92 insertions, 94 deletions
diff --git a/net/socket.c b/net/socket.c index f9f7d0872cac..2270b941bcc7 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -94,6 +94,7 @@ | |||
94 | 94 | ||
95 | #include <net/compat.h> | 95 | #include <net/compat.h> |
96 | #include <net/wext.h> | 96 | #include <net/wext.h> |
97 | #include <net/cls_cgroup.h> | ||
97 | 98 | ||
98 | #include <net/sock.h> | 99 | #include <net/sock.h> |
99 | #include <linux/netfilter.h> | 100 | #include <linux/netfilter.h> |
@@ -123,7 +124,7 @@ static int sock_fasync(int fd, struct file *filp, int on); | |||
123 | static ssize_t sock_sendpage(struct file *file, struct page *page, | 124 | static ssize_t sock_sendpage(struct file *file, struct page *page, |
124 | int offset, size_t size, loff_t *ppos, int more); | 125 | int offset, size_t size, loff_t *ppos, int more); |
125 | static ssize_t sock_splice_read(struct file *file, loff_t *ppos, | 126 | static ssize_t sock_splice_read(struct file *file, loff_t *ppos, |
126 | struct pipe_inode_info *pipe, size_t len, | 127 | struct pipe_inode_info *pipe, size_t len, |
127 | unsigned int flags); | 128 | unsigned int flags); |
128 | 129 | ||
129 | /* | 130 | /* |
@@ -161,7 +162,7 @@ static const struct net_proto_family *net_families[NPROTO] __read_mostly; | |||
161 | * Statistics counters of the socket lists | 162 | * Statistics counters of the socket lists |
162 | */ | 163 | */ |
163 | 164 | ||
164 | static DEFINE_PER_CPU(int, sockets_in_use) = 0; | 165 | static DEFINE_PER_CPU(int, sockets_in_use); |
165 | 166 | ||
166 | /* | 167 | /* |
167 | * Support routines. | 168 | * Support routines. |
@@ -169,15 +170,6 @@ static DEFINE_PER_CPU(int, sockets_in_use) = 0; | |||
169 | * divide and look after the messy bits. | 170 | * divide and look after the messy bits. |
170 | */ | 171 | */ |
171 | 172 | ||
172 | #define MAX_SOCK_ADDR 128 /* 108 for Unix domain - | ||
173 | 16 for IP, 16 for IPX, | ||
174 | 24 for IPv6, | ||
175 | about 80 for AX.25 | ||
176 | must be at least one bigger than | ||
177 | the AF_UNIX size (see net/unix/af_unix.c | ||
178 | :unix_mkname()). | ||
179 | */ | ||
180 | |||
181 | /** | 173 | /** |
182 | * move_addr_to_kernel - copy a socket address into kernel space | 174 | * move_addr_to_kernel - copy a socket address into kernel space |
183 | * @uaddr: Address in user space | 175 | * @uaddr: Address in user space |
@@ -308,9 +300,9 @@ static int init_inodecache(void) | |||
308 | } | 300 | } |
309 | 301 | ||
310 | static const struct super_operations sockfs_ops = { | 302 | static const struct super_operations sockfs_ops = { |
311 | .alloc_inode = sock_alloc_inode, | 303 | .alloc_inode = sock_alloc_inode, |
312 | .destroy_inode =sock_destroy_inode, | 304 | .destroy_inode = sock_destroy_inode, |
313 | .statfs = simple_statfs, | 305 | .statfs = simple_statfs, |
314 | }; | 306 | }; |
315 | 307 | ||
316 | static int sockfs_get_sb(struct file_system_type *fs_type, | 308 | static int sockfs_get_sb(struct file_system_type *fs_type, |
@@ -410,6 +402,7 @@ int sock_map_fd(struct socket *sock, int flags) | |||
410 | 402 | ||
411 | return fd; | 403 | return fd; |
412 | } | 404 | } |
405 | EXPORT_SYMBOL(sock_map_fd); | ||
413 | 406 | ||
414 | static struct socket *sock_from_file(struct file *file, int *err) | 407 | static struct socket *sock_from_file(struct file *file, int *err) |
415 | { | 408 | { |
@@ -421,7 +414,7 @@ static struct socket *sock_from_file(struct file *file, int *err) | |||
421 | } | 414 | } |
422 | 415 | ||
423 | /** | 416 | /** |
424 | * sockfd_lookup - Go from a file number to its socket slot | 417 | * sockfd_lookup - Go from a file number to its socket slot |
425 | * @fd: file handle | 418 | * @fd: file handle |
426 | * @err: pointer to an error code return | 419 | * @err: pointer to an error code return |
427 | * | 420 | * |
@@ -449,6 +442,7 @@ struct socket *sockfd_lookup(int fd, int *err) | |||
449 | fput(file); | 442 | fput(file); |
450 | return sock; | 443 | return sock; |
451 | } | 444 | } |
445 | EXPORT_SYMBOL(sockfd_lookup); | ||
452 | 446 | ||
453 | static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed) | 447 | static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed) |
454 | { | 448 | { |
@@ -539,6 +533,7 @@ void sock_release(struct socket *sock) | |||
539 | } | 533 | } |
540 | sock->file = NULL; | 534 | sock->file = NULL; |
541 | } | 535 | } |
536 | EXPORT_SYMBOL(sock_release); | ||
542 | 537 | ||
543 | int sock_tx_timestamp(struct msghdr *msg, struct sock *sk, | 538 | int sock_tx_timestamp(struct msghdr *msg, struct sock *sk, |
544 | union skb_shared_tx *shtx) | 539 | union skb_shared_tx *shtx) |
@@ -558,6 +553,8 @@ static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
558 | struct sock_iocb *si = kiocb_to_siocb(iocb); | 553 | struct sock_iocb *si = kiocb_to_siocb(iocb); |
559 | int err; | 554 | int err; |
560 | 555 | ||
556 | sock_update_classid(sock->sk); | ||
557 | |||
561 | si->sock = sock; | 558 | si->sock = sock; |
562 | si->scm = NULL; | 559 | si->scm = NULL; |
563 | si->msg = msg; | 560 | si->msg = msg; |
@@ -583,6 +580,7 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) | |||
583 | ret = wait_on_sync_kiocb(&iocb); | 580 | ret = wait_on_sync_kiocb(&iocb); |
584 | return ret; | 581 | return ret; |
585 | } | 582 | } |
583 | EXPORT_SYMBOL(sock_sendmsg); | ||
586 | 584 | ||
587 | int kernel_sendmsg(struct socket *sock, struct msghdr *msg, | 585 | int kernel_sendmsg(struct socket *sock, struct msghdr *msg, |
588 | struct kvec *vec, size_t num, size_t size) | 586 | struct kvec *vec, size_t num, size_t size) |
@@ -601,6 +599,7 @@ int kernel_sendmsg(struct socket *sock, struct msghdr *msg, | |||
601 | set_fs(oldfs); | 599 | set_fs(oldfs); |
602 | return result; | 600 | return result; |
603 | } | 601 | } |
602 | EXPORT_SYMBOL(kernel_sendmsg); | ||
604 | 603 | ||
605 | static int ktime2ts(ktime_t kt, struct timespec *ts) | 604 | static int ktime2ts(ktime_t kt, struct timespec *ts) |
606 | { | 605 | { |
@@ -661,7 +660,6 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, | |||
661 | put_cmsg(msg, SOL_SOCKET, | 660 | put_cmsg(msg, SOL_SOCKET, |
662 | SCM_TIMESTAMPING, sizeof(ts), &ts); | 661 | SCM_TIMESTAMPING, sizeof(ts), &ts); |
663 | } | 662 | } |
664 | |||
665 | EXPORT_SYMBOL_GPL(__sock_recv_timestamp); | 663 | EXPORT_SYMBOL_GPL(__sock_recv_timestamp); |
666 | 664 | ||
667 | inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) | 665 | inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) |
@@ -684,6 +682,8 @@ static inline int __sock_recvmsg_nosec(struct kiocb *iocb, struct socket *sock, | |||
684 | { | 682 | { |
685 | struct sock_iocb *si = kiocb_to_siocb(iocb); | 683 | struct sock_iocb *si = kiocb_to_siocb(iocb); |
686 | 684 | ||
685 | sock_update_classid(sock->sk); | ||
686 | |||
687 | si->sock = sock; | 687 | si->sock = sock; |
688 | si->scm = NULL; | 688 | si->scm = NULL; |
689 | si->msg = msg; | 689 | si->msg = msg; |
@@ -715,6 +715,7 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg, | |||
715 | ret = wait_on_sync_kiocb(&iocb); | 715 | ret = wait_on_sync_kiocb(&iocb); |
716 | return ret; | 716 | return ret; |
717 | } | 717 | } |
718 | EXPORT_SYMBOL(sock_recvmsg); | ||
718 | 719 | ||
719 | static int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, | 720 | static int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, |
720 | size_t size, int flags) | 721 | size_t size, int flags) |
@@ -747,6 +748,7 @@ int kernel_recvmsg(struct socket *sock, struct msghdr *msg, | |||
747 | set_fs(oldfs); | 748 | set_fs(oldfs); |
748 | return result; | 749 | return result; |
749 | } | 750 | } |
751 | EXPORT_SYMBOL(kernel_recvmsg); | ||
750 | 752 | ||
751 | static void sock_aio_dtor(struct kiocb *iocb) | 753 | static void sock_aio_dtor(struct kiocb *iocb) |
752 | { | 754 | { |
@@ -769,7 +771,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page, | |||
769 | } | 771 | } |
770 | 772 | ||
771 | static ssize_t sock_splice_read(struct file *file, loff_t *ppos, | 773 | static ssize_t sock_splice_read(struct file *file, loff_t *ppos, |
772 | struct pipe_inode_info *pipe, size_t len, | 774 | struct pipe_inode_info *pipe, size_t len, |
773 | unsigned int flags) | 775 | unsigned int flags) |
774 | { | 776 | { |
775 | struct socket *sock = file->private_data; | 777 | struct socket *sock = file->private_data; |
@@ -777,6 +779,8 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, | |||
777 | if (unlikely(!sock->ops->splice_read)) | 779 | if (unlikely(!sock->ops->splice_read)) |
778 | return -EINVAL; | 780 | return -EINVAL; |
779 | 781 | ||
782 | sock_update_classid(sock->sk); | ||
783 | |||
780 | return sock->ops->splice_read(sock, ppos, pipe, len, flags); | 784 | return sock->ops->splice_read(sock, ppos, pipe, len, flags); |
781 | } | 785 | } |
782 | 786 | ||
@@ -880,7 +884,7 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
880 | */ | 884 | */ |
881 | 885 | ||
882 | static DEFINE_MUTEX(br_ioctl_mutex); | 886 | static DEFINE_MUTEX(br_ioctl_mutex); |
883 | static int (*br_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg) = NULL; | 887 | static int (*br_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg); |
884 | 888 | ||
885 | void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *)) | 889 | void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *)) |
886 | { | 890 | { |
@@ -888,7 +892,6 @@ void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *)) | |||
888 | br_ioctl_hook = hook; | 892 | br_ioctl_hook = hook; |
889 | mutex_unlock(&br_ioctl_mutex); | 893 | mutex_unlock(&br_ioctl_mutex); |
890 | } | 894 | } |
891 | |||
892 | EXPORT_SYMBOL(brioctl_set); | 895 | EXPORT_SYMBOL(brioctl_set); |
893 | 896 | ||
894 | static DEFINE_MUTEX(vlan_ioctl_mutex); | 897 | static DEFINE_MUTEX(vlan_ioctl_mutex); |
@@ -900,7 +903,6 @@ void vlan_ioctl_set(int (*hook) (struct net *, void __user *)) | |||
900 | vlan_ioctl_hook = hook; | 903 | vlan_ioctl_hook = hook; |
901 | mutex_unlock(&vlan_ioctl_mutex); | 904 | mutex_unlock(&vlan_ioctl_mutex); |
902 | } | 905 | } |
903 | |||
904 | EXPORT_SYMBOL(vlan_ioctl_set); | 906 | EXPORT_SYMBOL(vlan_ioctl_set); |
905 | 907 | ||
906 | static DEFINE_MUTEX(dlci_ioctl_mutex); | 908 | static DEFINE_MUTEX(dlci_ioctl_mutex); |
@@ -912,7 +914,6 @@ void dlci_ioctl_set(int (*hook) (unsigned int, void __user *)) | |||
912 | dlci_ioctl_hook = hook; | 914 | dlci_ioctl_hook = hook; |
913 | mutex_unlock(&dlci_ioctl_mutex); | 915 | mutex_unlock(&dlci_ioctl_mutex); |
914 | } | 916 | } |
915 | |||
916 | EXPORT_SYMBOL(dlci_ioctl_set); | 917 | EXPORT_SYMBOL(dlci_ioctl_set); |
917 | 918 | ||
918 | static long sock_do_ioctl(struct net *net, struct socket *sock, | 919 | static long sock_do_ioctl(struct net *net, struct socket *sock, |
@@ -1040,6 +1041,7 @@ out_release: | |||
1040 | sock = NULL; | 1041 | sock = NULL; |
1041 | goto out; | 1042 | goto out; |
1042 | } | 1043 | } |
1044 | EXPORT_SYMBOL(sock_create_lite); | ||
1043 | 1045 | ||
1044 | /* No kernel lock held - perfect */ | 1046 | /* No kernel lock held - perfect */ |
1045 | static unsigned int sock_poll(struct file *file, poll_table *wait) | 1047 | static unsigned int sock_poll(struct file *file, poll_table *wait) |
@@ -1140,6 +1142,7 @@ call_kill: | |||
1140 | rcu_read_unlock(); | 1142 | rcu_read_unlock(); |
1141 | return 0; | 1143 | return 0; |
1142 | } | 1144 | } |
1145 | EXPORT_SYMBOL(sock_wake_async); | ||
1143 | 1146 | ||
1144 | static int __sock_create(struct net *net, int family, int type, int protocol, | 1147 | static int __sock_create(struct net *net, int family, int type, int protocol, |
1145 | struct socket **res, int kern) | 1148 | struct socket **res, int kern) |
@@ -1258,11 +1261,13 @@ int sock_create(int family, int type, int protocol, struct socket **res) | |||
1258 | { | 1261 | { |
1259 | return __sock_create(current->nsproxy->net_ns, family, type, protocol, res, 0); | 1262 | return __sock_create(current->nsproxy->net_ns, family, type, protocol, res, 0); |
1260 | } | 1263 | } |
1264 | EXPORT_SYMBOL(sock_create); | ||
1261 | 1265 | ||
1262 | int sock_create_kern(int family, int type, int protocol, struct socket **res) | 1266 | int sock_create_kern(int family, int type, int protocol, struct socket **res) |
1263 | { | 1267 | { |
1264 | return __sock_create(&init_net, family, type, protocol, res, 1); | 1268 | return __sock_create(&init_net, family, type, protocol, res, 1); |
1265 | } | 1269 | } |
1270 | EXPORT_SYMBOL(sock_create_kern); | ||
1266 | 1271 | ||
1267 | SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol) | 1272 | SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol) |
1268 | { | 1273 | { |
@@ -1467,7 +1472,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr, | |||
1467 | goto out; | 1472 | goto out; |
1468 | 1473 | ||
1469 | err = -ENFILE; | 1474 | err = -ENFILE; |
1470 | if (!(newsock = sock_alloc())) | 1475 | newsock = sock_alloc(); |
1476 | if (!newsock) | ||
1471 | goto out_put; | 1477 | goto out_put; |
1472 | 1478 | ||
1473 | newsock->type = sock->type; | 1479 | newsock->type = sock->type; |
@@ -1854,8 +1860,7 @@ SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned, flags) | |||
1854 | if (MSG_CMSG_COMPAT & flags) { | 1860 | if (MSG_CMSG_COMPAT & flags) { |
1855 | if (get_compat_msghdr(&msg_sys, msg_compat)) | 1861 | if (get_compat_msghdr(&msg_sys, msg_compat)) |
1856 | return -EFAULT; | 1862 | return -EFAULT; |
1857 | } | 1863 | } else if (copy_from_user(&msg_sys, msg, sizeof(struct msghdr))) |
1858 | else if (copy_from_user(&msg_sys, msg, sizeof(struct msghdr))) | ||
1859 | return -EFAULT; | 1864 | return -EFAULT; |
1860 | 1865 | ||
1861 | sock = sockfd_lookup_light(fd, &err, &fput_needed); | 1866 | sock = sockfd_lookup_light(fd, &err, &fput_needed); |
@@ -1957,8 +1962,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg, | |||
1957 | if (MSG_CMSG_COMPAT & flags) { | 1962 | if (MSG_CMSG_COMPAT & flags) { |
1958 | if (get_compat_msghdr(msg_sys, msg_compat)) | 1963 | if (get_compat_msghdr(msg_sys, msg_compat)) |
1959 | return -EFAULT; | 1964 | return -EFAULT; |
1960 | } | 1965 | } else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr))) |
1961 | else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr))) | ||
1962 | return -EFAULT; | 1966 | return -EFAULT; |
1963 | 1967 | ||
1964 | err = -EMSGSIZE; | 1968 | err = -EMSGSIZE; |
@@ -2184,10 +2188,10 @@ SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg, | |||
2184 | /* Argument list sizes for sys_socketcall */ | 2188 | /* Argument list sizes for sys_socketcall */ |
2185 | #define AL(x) ((x) * sizeof(unsigned long)) | 2189 | #define AL(x) ((x) * sizeof(unsigned long)) |
2186 | static const unsigned char nargs[20] = { | 2190 | static const unsigned char nargs[20] = { |
2187 | AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), | 2191 | AL(0), AL(3), AL(3), AL(3), AL(2), AL(3), |
2188 | AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), | 2192 | AL(3), AL(3), AL(4), AL(4), AL(4), AL(6), |
2189 | AL(6),AL(2),AL(5),AL(5),AL(3),AL(3), | 2193 | AL(6), AL(2), AL(5), AL(5), AL(3), AL(3), |
2190 | AL(4),AL(5) | 2194 | AL(4), AL(5) |
2191 | }; | 2195 | }; |
2192 | 2196 | ||
2193 | #undef AL | 2197 | #undef AL |
@@ -2333,6 +2337,7 @@ int sock_register(const struct net_proto_family *ops) | |||
2333 | printk(KERN_INFO "NET: Registered protocol family %d\n", ops->family); | 2337 | printk(KERN_INFO "NET: Registered protocol family %d\n", ops->family); |
2334 | return err; | 2338 | return err; |
2335 | } | 2339 | } |
2340 | EXPORT_SYMBOL(sock_register); | ||
2336 | 2341 | ||
2337 | /** | 2342 | /** |
2338 | * sock_unregister - remove a protocol handler | 2343 | * sock_unregister - remove a protocol handler |
@@ -2359,6 +2364,7 @@ void sock_unregister(int family) | |||
2359 | 2364 | ||
2360 | printk(KERN_INFO "NET: Unregistered protocol family %d\n", family); | 2365 | printk(KERN_INFO "NET: Unregistered protocol family %d\n", family); |
2361 | } | 2366 | } |
2367 | EXPORT_SYMBOL(sock_unregister); | ||
2362 | 2368 | ||
2363 | static int __init sock_init(void) | 2369 | static int __init sock_init(void) |
2364 | { | 2370 | { |
@@ -2388,6 +2394,10 @@ static int __init sock_init(void) | |||
2388 | netfilter_init(); | 2394 | netfilter_init(); |
2389 | #endif | 2395 | #endif |
2390 | 2396 | ||
2397 | #ifdef CONFIG_NETWORK_PHY_TIMESTAMPING | ||
2398 | skb_timestamping_init(); | ||
2399 | #endif | ||
2400 | |||
2391 | return 0; | 2401 | return 0; |
2392 | } | 2402 | } |
2393 | 2403 | ||
@@ -2483,13 +2493,13 @@ static int dev_ifconf(struct net *net, struct compat_ifconf __user *uifc32) | |||
2483 | ifc.ifc_req = NULL; | 2493 | ifc.ifc_req = NULL; |
2484 | uifc = compat_alloc_user_space(sizeof(struct ifconf)); | 2494 | uifc = compat_alloc_user_space(sizeof(struct ifconf)); |
2485 | } else { | 2495 | } else { |
2486 | size_t len =((ifc32.ifc_len / sizeof (struct compat_ifreq)) + 1) * | 2496 | size_t len = ((ifc32.ifc_len / sizeof(struct compat_ifreq)) + 1) * |
2487 | sizeof (struct ifreq); | 2497 | sizeof(struct ifreq); |
2488 | uifc = compat_alloc_user_space(sizeof(struct ifconf) + len); | 2498 | uifc = compat_alloc_user_space(sizeof(struct ifconf) + len); |
2489 | ifc.ifc_len = len; | 2499 | ifc.ifc_len = len; |
2490 | ifr = ifc.ifc_req = (void __user *)(uifc + 1); | 2500 | ifr = ifc.ifc_req = (void __user *)(uifc + 1); |
2491 | ifr32 = compat_ptr(ifc32.ifcbuf); | 2501 | ifr32 = compat_ptr(ifc32.ifcbuf); |
2492 | for (i = 0; i < ifc32.ifc_len; i += sizeof (struct compat_ifreq)) { | 2502 | for (i = 0; i < ifc32.ifc_len; i += sizeof(struct compat_ifreq)) { |
2493 | if (copy_in_user(ifr, ifr32, sizeof(struct compat_ifreq))) | 2503 | if (copy_in_user(ifr, ifr32, sizeof(struct compat_ifreq))) |
2494 | return -EFAULT; | 2504 | return -EFAULT; |
2495 | ifr++; | 2505 | ifr++; |
@@ -2509,9 +2519,9 @@ static int dev_ifconf(struct net *net, struct compat_ifconf __user *uifc32) | |||
2509 | ifr = ifc.ifc_req; | 2519 | ifr = ifc.ifc_req; |
2510 | ifr32 = compat_ptr(ifc32.ifcbuf); | 2520 | ifr32 = compat_ptr(ifc32.ifcbuf); |
2511 | for (i = 0, j = 0; | 2521 | for (i = 0, j = 0; |
2512 | i + sizeof (struct compat_ifreq) <= ifc32.ifc_len && j < ifc.ifc_len; | 2522 | i + sizeof(struct compat_ifreq) <= ifc32.ifc_len && j < ifc.ifc_len; |
2513 | i += sizeof (struct compat_ifreq), j += sizeof (struct ifreq)) { | 2523 | i += sizeof(struct compat_ifreq), j += sizeof(struct ifreq)) { |
2514 | if (copy_in_user(ifr32, ifr, sizeof (struct compat_ifreq))) | 2524 | if (copy_in_user(ifr32, ifr, sizeof(struct compat_ifreq))) |
2515 | return -EFAULT; | 2525 | return -EFAULT; |
2516 | ifr32++; | 2526 | ifr32++; |
2517 | ifr++; | 2527 | ifr++; |
@@ -2560,7 +2570,7 @@ static int compat_siocwandev(struct net *net, struct compat_ifreq __user *uifr32 | |||
2560 | compat_uptr_t uptr32; | 2570 | compat_uptr_t uptr32; |
2561 | struct ifreq __user *uifr; | 2571 | struct ifreq __user *uifr; |
2562 | 2572 | ||
2563 | uifr = compat_alloc_user_space(sizeof (*uifr)); | 2573 | uifr = compat_alloc_user_space(sizeof(*uifr)); |
2564 | if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq))) | 2574 | if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq))) |
2565 | return -EFAULT; | 2575 | return -EFAULT; |
2566 | 2576 | ||
@@ -2594,9 +2604,9 @@ static int bond_ioctl(struct net *net, unsigned int cmd, | |||
2594 | return -EFAULT; | 2604 | return -EFAULT; |
2595 | 2605 | ||
2596 | old_fs = get_fs(); | 2606 | old_fs = get_fs(); |
2597 | set_fs (KERNEL_DS); | 2607 | set_fs(KERNEL_DS); |
2598 | err = dev_ioctl(net, cmd, &kifr); | 2608 | err = dev_ioctl(net, cmd, &kifr); |
2599 | set_fs (old_fs); | 2609 | set_fs(old_fs); |
2600 | 2610 | ||
2601 | return err; | 2611 | return err; |
2602 | case SIOCBONDSLAVEINFOQUERY: | 2612 | case SIOCBONDSLAVEINFOQUERY: |
@@ -2703,9 +2713,9 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd, | |||
2703 | return -EFAULT; | 2713 | return -EFAULT; |
2704 | 2714 | ||
2705 | old_fs = get_fs(); | 2715 | old_fs = get_fs(); |
2706 | set_fs (KERNEL_DS); | 2716 | set_fs(KERNEL_DS); |
2707 | err = dev_ioctl(net, cmd, (void __user *)&ifr); | 2717 | err = dev_ioctl(net, cmd, (void __user *)&ifr); |
2708 | set_fs (old_fs); | 2718 | set_fs(old_fs); |
2709 | 2719 | ||
2710 | if (cmd == SIOCGIFMAP && !err) { | 2720 | if (cmd == SIOCGIFMAP && !err) { |
2711 | err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name)); | 2721 | err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name)); |
@@ -2727,7 +2737,7 @@ static int compat_siocshwtstamp(struct net *net, struct compat_ifreq __user *uif | |||
2727 | compat_uptr_t uptr32; | 2737 | compat_uptr_t uptr32; |
2728 | struct ifreq __user *uifr; | 2738 | struct ifreq __user *uifr; |
2729 | 2739 | ||
2730 | uifr = compat_alloc_user_space(sizeof (*uifr)); | 2740 | uifr = compat_alloc_user_space(sizeof(*uifr)); |
2731 | if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq))) | 2741 | if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq))) |
2732 | return -EFAULT; | 2742 | return -EFAULT; |
2733 | 2743 | ||
@@ -2743,20 +2753,20 @@ static int compat_siocshwtstamp(struct net *net, struct compat_ifreq __user *uif | |||
2743 | } | 2753 | } |
2744 | 2754 | ||
2745 | struct rtentry32 { | 2755 | struct rtentry32 { |
2746 | u32 rt_pad1; | 2756 | u32 rt_pad1; |
2747 | struct sockaddr rt_dst; /* target address */ | 2757 | struct sockaddr rt_dst; /* target address */ |
2748 | struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ | 2758 | struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ |
2749 | struct sockaddr rt_genmask; /* target network mask (IP) */ | 2759 | struct sockaddr rt_genmask; /* target network mask (IP) */ |
2750 | unsigned short rt_flags; | 2760 | unsigned short rt_flags; |
2751 | short rt_pad2; | 2761 | short rt_pad2; |
2752 | u32 rt_pad3; | 2762 | u32 rt_pad3; |
2753 | unsigned char rt_tos; | 2763 | unsigned char rt_tos; |
2754 | unsigned char rt_class; | 2764 | unsigned char rt_class; |
2755 | short rt_pad4; | 2765 | short rt_pad4; |
2756 | short rt_metric; /* +1 for binary compatibility! */ | 2766 | short rt_metric; /* +1 for binary compatibility! */ |
2757 | /* char * */ u32 rt_dev; /* forcing the device at add */ | 2767 | /* char * */ u32 rt_dev; /* forcing the device at add */ |
2758 | u32 rt_mtu; /* per route MTU/Window */ | 2768 | u32 rt_mtu; /* per route MTU/Window */ |
2759 | u32 rt_window; /* Window clamping */ | 2769 | u32 rt_window; /* Window clamping */ |
2760 | unsigned short rt_irtt; /* Initial RTT */ | 2770 | unsigned short rt_irtt; /* Initial RTT */ |
2761 | }; | 2771 | }; |
2762 | 2772 | ||
@@ -2786,29 +2796,29 @@ static int routing_ioctl(struct net *net, struct socket *sock, | |||
2786 | 2796 | ||
2787 | if (sock && sock->sk && sock->sk->sk_family == AF_INET6) { /* ipv6 */ | 2797 | if (sock && sock->sk && sock->sk->sk_family == AF_INET6) { /* ipv6 */ |
2788 | struct in6_rtmsg32 __user *ur6 = argp; | 2798 | struct in6_rtmsg32 __user *ur6 = argp; |
2789 | ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst), | 2799 | ret = copy_from_user(&r6.rtmsg_dst, &(ur6->rtmsg_dst), |
2790 | 3 * sizeof(struct in6_addr)); | 2800 | 3 * sizeof(struct in6_addr)); |
2791 | ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type)); | 2801 | ret |= __get_user(r6.rtmsg_type, &(ur6->rtmsg_type)); |
2792 | ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len)); | 2802 | ret |= __get_user(r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len)); |
2793 | ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len)); | 2803 | ret |= __get_user(r6.rtmsg_src_len, &(ur6->rtmsg_src_len)); |
2794 | ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric)); | 2804 | ret |= __get_user(r6.rtmsg_metric, &(ur6->rtmsg_metric)); |
2795 | ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info)); | 2805 | ret |= __get_user(r6.rtmsg_info, &(ur6->rtmsg_info)); |
2796 | ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags)); | 2806 | ret |= __get_user(r6.rtmsg_flags, &(ur6->rtmsg_flags)); |
2797 | ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex)); | 2807 | ret |= __get_user(r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex)); |
2798 | 2808 | ||
2799 | r = (void *) &r6; | 2809 | r = (void *) &r6; |
2800 | } else { /* ipv4 */ | 2810 | } else { /* ipv4 */ |
2801 | struct rtentry32 __user *ur4 = argp; | 2811 | struct rtentry32 __user *ur4 = argp; |
2802 | ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst), | 2812 | ret = copy_from_user(&r4.rt_dst, &(ur4->rt_dst), |
2803 | 3 * sizeof(struct sockaddr)); | 2813 | 3 * sizeof(struct sockaddr)); |
2804 | ret |= __get_user (r4.rt_flags, &(ur4->rt_flags)); | 2814 | ret |= __get_user(r4.rt_flags, &(ur4->rt_flags)); |
2805 | ret |= __get_user (r4.rt_metric, &(ur4->rt_metric)); | 2815 | ret |= __get_user(r4.rt_metric, &(ur4->rt_metric)); |
2806 | ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu)); | 2816 | ret |= __get_user(r4.rt_mtu, &(ur4->rt_mtu)); |
2807 | ret |= __get_user (r4.rt_window, &(ur4->rt_window)); | 2817 | ret |= __get_user(r4.rt_window, &(ur4->rt_window)); |
2808 | ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt)); | 2818 | ret |= __get_user(r4.rt_irtt, &(ur4->rt_irtt)); |
2809 | ret |= __get_user (rtdev, &(ur4->rt_dev)); | 2819 | ret |= __get_user(rtdev, &(ur4->rt_dev)); |
2810 | if (rtdev) { | 2820 | if (rtdev) { |
2811 | ret |= copy_from_user (devname, compat_ptr(rtdev), 15); | 2821 | ret |= copy_from_user(devname, compat_ptr(rtdev), 15); |
2812 | r4.rt_dev = devname; devname[15] = 0; | 2822 | r4.rt_dev = devname; devname[15] = 0; |
2813 | } else | 2823 | } else |
2814 | r4.rt_dev = NULL; | 2824 | r4.rt_dev = NULL; |
@@ -2821,9 +2831,9 @@ static int routing_ioctl(struct net *net, struct socket *sock, | |||
2821 | goto out; | 2831 | goto out; |
2822 | } | 2832 | } |
2823 | 2833 | ||
2824 | set_fs (KERNEL_DS); | 2834 | set_fs(KERNEL_DS); |
2825 | ret = sock_do_ioctl(net, sock, cmd, (unsigned long) r); | 2835 | ret = sock_do_ioctl(net, sock, cmd, (unsigned long) r); |
2826 | set_fs (old_fs); | 2836 | set_fs(old_fs); |
2827 | 2837 | ||
2828 | out: | 2838 | out: |
2829 | return ret; | 2839 | return ret; |
@@ -2986,11 +2996,13 @@ int kernel_bind(struct socket *sock, struct sockaddr *addr, int addrlen) | |||
2986 | { | 2996 | { |
2987 | return sock->ops->bind(sock, addr, addrlen); | 2997 | return sock->ops->bind(sock, addr, addrlen); |
2988 | } | 2998 | } |
2999 | EXPORT_SYMBOL(kernel_bind); | ||
2989 | 3000 | ||
2990 | int kernel_listen(struct socket *sock, int backlog) | 3001 | int kernel_listen(struct socket *sock, int backlog) |
2991 | { | 3002 | { |
2992 | return sock->ops->listen(sock, backlog); | 3003 | return sock->ops->listen(sock, backlog); |
2993 | } | 3004 | } |
3005 | EXPORT_SYMBOL(kernel_listen); | ||
2994 | 3006 | ||
2995 | int kernel_accept(struct socket *sock, struct socket **newsock, int flags) | 3007 | int kernel_accept(struct socket *sock, struct socket **newsock, int flags) |
2996 | { | 3008 | { |
@@ -3015,24 +3027,28 @@ int kernel_accept(struct socket *sock, struct socket **newsock, int flags) | |||
3015 | done: | 3027 | done: |
3016 | return err; | 3028 | return err; |
3017 | } | 3029 | } |
3030 | EXPORT_SYMBOL(kernel_accept); | ||
3018 | 3031 | ||
3019 | int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, | 3032 | int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, |
3020 | int flags) | 3033 | int flags) |
3021 | { | 3034 | { |
3022 | return sock->ops->connect(sock, addr, addrlen, flags); | 3035 | return sock->ops->connect(sock, addr, addrlen, flags); |
3023 | } | 3036 | } |
3037 | EXPORT_SYMBOL(kernel_connect); | ||
3024 | 3038 | ||
3025 | int kernel_getsockname(struct socket *sock, struct sockaddr *addr, | 3039 | int kernel_getsockname(struct socket *sock, struct sockaddr *addr, |
3026 | int *addrlen) | 3040 | int *addrlen) |
3027 | { | 3041 | { |
3028 | return sock->ops->getname(sock, addr, addrlen, 0); | 3042 | return sock->ops->getname(sock, addr, addrlen, 0); |
3029 | } | 3043 | } |
3044 | EXPORT_SYMBOL(kernel_getsockname); | ||
3030 | 3045 | ||
3031 | int kernel_getpeername(struct socket *sock, struct sockaddr *addr, | 3046 | int kernel_getpeername(struct socket *sock, struct sockaddr *addr, |
3032 | int *addrlen) | 3047 | int *addrlen) |
3033 | { | 3048 | { |
3034 | return sock->ops->getname(sock, addr, addrlen, 1); | 3049 | return sock->ops->getname(sock, addr, addrlen, 1); |
3035 | } | 3050 | } |
3051 | EXPORT_SYMBOL(kernel_getpeername); | ||
3036 | 3052 | ||
3037 | int kernel_getsockopt(struct socket *sock, int level, int optname, | 3053 | int kernel_getsockopt(struct socket *sock, int level, int optname, |
3038 | char *optval, int *optlen) | 3054 | char *optval, int *optlen) |
@@ -3049,6 +3065,7 @@ int kernel_getsockopt(struct socket *sock, int level, int optname, | |||
3049 | set_fs(oldfs); | 3065 | set_fs(oldfs); |
3050 | return err; | 3066 | return err; |
3051 | } | 3067 | } |
3068 | EXPORT_SYMBOL(kernel_getsockopt); | ||
3052 | 3069 | ||
3053 | int kernel_setsockopt(struct socket *sock, int level, int optname, | 3070 | int kernel_setsockopt(struct socket *sock, int level, int optname, |
3054 | char *optval, unsigned int optlen) | 3071 | char *optval, unsigned int optlen) |
@@ -3065,15 +3082,19 @@ int kernel_setsockopt(struct socket *sock, int level, int optname, | |||
3065 | set_fs(oldfs); | 3082 | set_fs(oldfs); |
3066 | return err; | 3083 | return err; |
3067 | } | 3084 | } |
3085 | EXPORT_SYMBOL(kernel_setsockopt); | ||
3068 | 3086 | ||
3069 | int kernel_sendpage(struct socket *sock, struct page *page, int offset, | 3087 | int kernel_sendpage(struct socket *sock, struct page *page, int offset, |
3070 | size_t size, int flags) | 3088 | size_t size, int flags) |
3071 | { | 3089 | { |
3090 | sock_update_classid(sock->sk); | ||
3091 | |||
3072 | if (sock->ops->sendpage) | 3092 | if (sock->ops->sendpage) |
3073 | return sock->ops->sendpage(sock, page, offset, size, flags); | 3093 | return sock->ops->sendpage(sock, page, offset, size, flags); |
3074 | 3094 | ||
3075 | return sock_no_sendpage(sock, page, offset, size, flags); | 3095 | return sock_no_sendpage(sock, page, offset, size, flags); |
3076 | } | 3096 | } |
3097 | EXPORT_SYMBOL(kernel_sendpage); | ||
3077 | 3098 | ||
3078 | int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg) | 3099 | int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg) |
3079 | { | 3100 | { |
@@ -3086,33 +3107,10 @@ int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg) | |||
3086 | 3107 | ||
3087 | return err; | 3108 | return err; |
3088 | } | 3109 | } |
3110 | EXPORT_SYMBOL(kernel_sock_ioctl); | ||
3089 | 3111 | ||
3090 | int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) | 3112 | int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) |
3091 | { | 3113 | { |
3092 | return sock->ops->shutdown(sock, how); | 3114 | return sock->ops->shutdown(sock, how); |
3093 | } | 3115 | } |
3094 | |||
3095 | EXPORT_SYMBOL(sock_create); | ||
3096 | EXPORT_SYMBOL(sock_create_kern); | ||
3097 | EXPORT_SYMBOL(sock_create_lite); | ||
3098 | EXPORT_SYMBOL(sock_map_fd); | ||
3099 | EXPORT_SYMBOL(sock_recvmsg); | ||
3100 | EXPORT_SYMBOL(sock_register); | ||
3101 | EXPORT_SYMBOL(sock_release); | ||
3102 | EXPORT_SYMBOL(sock_sendmsg); | ||
3103 | EXPORT_SYMBOL(sock_unregister); | ||
3104 | EXPORT_SYMBOL(sock_wake_async); | ||
3105 | EXPORT_SYMBOL(sockfd_lookup); | ||
3106 | EXPORT_SYMBOL(kernel_sendmsg); | ||
3107 | EXPORT_SYMBOL(kernel_recvmsg); | ||
3108 | EXPORT_SYMBOL(kernel_bind); | ||
3109 | EXPORT_SYMBOL(kernel_listen); | ||
3110 | EXPORT_SYMBOL(kernel_accept); | ||
3111 | EXPORT_SYMBOL(kernel_connect); | ||
3112 | EXPORT_SYMBOL(kernel_getsockname); | ||
3113 | EXPORT_SYMBOL(kernel_getpeername); | ||
3114 | EXPORT_SYMBOL(kernel_getsockopt); | ||
3115 | EXPORT_SYMBOL(kernel_setsockopt); | ||
3116 | EXPORT_SYMBOL(kernel_sendpage); | ||
3117 | EXPORT_SYMBOL(kernel_sock_ioctl); | ||
3118 | EXPORT_SYMBOL(kernel_sock_shutdown); | 3116 | EXPORT_SYMBOL(kernel_sock_shutdown); |