diff options
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 177 |
1 files changed, 83 insertions, 94 deletions
diff --git a/net/socket.c b/net/socket.c index 367d5477d00f..2270b941bcc7 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -124,7 +124,7 @@ static int sock_fasync(int fd, struct file *filp, int on); | |||
124 | static ssize_t sock_sendpage(struct file *file, struct page *page, | 124 | static ssize_t sock_sendpage(struct file *file, struct page *page, |
125 | int offset, size_t size, loff_t *ppos, int more); | 125 | int offset, size_t size, loff_t *ppos, int more); |
126 | 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, |
127 | struct pipe_inode_info *pipe, size_t len, | 127 | struct pipe_inode_info *pipe, size_t len, |
128 | unsigned int flags); | 128 | unsigned int flags); |
129 | 129 | ||
130 | /* | 130 | /* |
@@ -162,7 +162,7 @@ static const struct net_proto_family *net_families[NPROTO] __read_mostly; | |||
162 | * Statistics counters of the socket lists | 162 | * Statistics counters of the socket lists |
163 | */ | 163 | */ |
164 | 164 | ||
165 | static DEFINE_PER_CPU(int, sockets_in_use) = 0; | 165 | static DEFINE_PER_CPU(int, sockets_in_use); |
166 | 166 | ||
167 | /* | 167 | /* |
168 | * Support routines. | 168 | * Support routines. |
@@ -170,15 +170,6 @@ static DEFINE_PER_CPU(int, sockets_in_use) = 0; | |||
170 | * divide and look after the messy bits. | 170 | * divide and look after the messy bits. |
171 | */ | 171 | */ |
172 | 172 | ||
173 | #define MAX_SOCK_ADDR 128 /* 108 for Unix domain - | ||
174 | 16 for IP, 16 for IPX, | ||
175 | 24 for IPv6, | ||
176 | about 80 for AX.25 | ||
177 | must be at least one bigger than | ||
178 | the AF_UNIX size (see net/unix/af_unix.c | ||
179 | :unix_mkname()). | ||
180 | */ | ||
181 | |||
182 | /** | 173 | /** |
183 | * move_addr_to_kernel - copy a socket address into kernel space | 174 | * move_addr_to_kernel - copy a socket address into kernel space |
184 | * @uaddr: Address in user space | 175 | * @uaddr: Address in user space |
@@ -309,9 +300,9 @@ static int init_inodecache(void) | |||
309 | } | 300 | } |
310 | 301 | ||
311 | static const struct super_operations sockfs_ops = { | 302 | static const struct super_operations sockfs_ops = { |
312 | .alloc_inode = sock_alloc_inode, | 303 | .alloc_inode = sock_alloc_inode, |
313 | .destroy_inode =sock_destroy_inode, | 304 | .destroy_inode = sock_destroy_inode, |
314 | .statfs = simple_statfs, | 305 | .statfs = simple_statfs, |
315 | }; | 306 | }; |
316 | 307 | ||
317 | static int sockfs_get_sb(struct file_system_type *fs_type, | 308 | static int sockfs_get_sb(struct file_system_type *fs_type, |
@@ -411,6 +402,7 @@ int sock_map_fd(struct socket *sock, int flags) | |||
411 | 402 | ||
412 | return fd; | 403 | return fd; |
413 | } | 404 | } |
405 | EXPORT_SYMBOL(sock_map_fd); | ||
414 | 406 | ||
415 | static struct socket *sock_from_file(struct file *file, int *err) | 407 | static struct socket *sock_from_file(struct file *file, int *err) |
416 | { | 408 | { |
@@ -422,7 +414,7 @@ static struct socket *sock_from_file(struct file *file, int *err) | |||
422 | } | 414 | } |
423 | 415 | ||
424 | /** | 416 | /** |
425 | * sockfd_lookup - Go from a file number to its socket slot | 417 | * sockfd_lookup - Go from a file number to its socket slot |
426 | * @fd: file handle | 418 | * @fd: file handle |
427 | * @err: pointer to an error code return | 419 | * @err: pointer to an error code return |
428 | * | 420 | * |
@@ -450,6 +442,7 @@ struct socket *sockfd_lookup(int fd, int *err) | |||
450 | fput(file); | 442 | fput(file); |
451 | return sock; | 443 | return sock; |
452 | } | 444 | } |
445 | EXPORT_SYMBOL(sockfd_lookup); | ||
453 | 446 | ||
454 | 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) |
455 | { | 448 | { |
@@ -540,6 +533,7 @@ void sock_release(struct socket *sock) | |||
540 | } | 533 | } |
541 | sock->file = NULL; | 534 | sock->file = NULL; |
542 | } | 535 | } |
536 | EXPORT_SYMBOL(sock_release); | ||
543 | 537 | ||
544 | int sock_tx_timestamp(struct msghdr *msg, struct sock *sk, | 538 | int sock_tx_timestamp(struct msghdr *msg, struct sock *sk, |
545 | union skb_shared_tx *shtx) | 539 | union skb_shared_tx *shtx) |
@@ -586,6 +580,7 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) | |||
586 | ret = wait_on_sync_kiocb(&iocb); | 580 | ret = wait_on_sync_kiocb(&iocb); |
587 | return ret; | 581 | return ret; |
588 | } | 582 | } |
583 | EXPORT_SYMBOL(sock_sendmsg); | ||
589 | 584 | ||
590 | int kernel_sendmsg(struct socket *sock, struct msghdr *msg, | 585 | int kernel_sendmsg(struct socket *sock, struct msghdr *msg, |
591 | struct kvec *vec, size_t num, size_t size) | 586 | struct kvec *vec, size_t num, size_t size) |
@@ -604,6 +599,7 @@ int kernel_sendmsg(struct socket *sock, struct msghdr *msg, | |||
604 | set_fs(oldfs); | 599 | set_fs(oldfs); |
605 | return result; | 600 | return result; |
606 | } | 601 | } |
602 | EXPORT_SYMBOL(kernel_sendmsg); | ||
607 | 603 | ||
608 | static int ktime2ts(ktime_t kt, struct timespec *ts) | 604 | static int ktime2ts(ktime_t kt, struct timespec *ts) |
609 | { | 605 | { |
@@ -664,7 +660,6 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, | |||
664 | put_cmsg(msg, SOL_SOCKET, | 660 | put_cmsg(msg, SOL_SOCKET, |
665 | SCM_TIMESTAMPING, sizeof(ts), &ts); | 661 | SCM_TIMESTAMPING, sizeof(ts), &ts); |
666 | } | 662 | } |
667 | |||
668 | EXPORT_SYMBOL_GPL(__sock_recv_timestamp); | 663 | EXPORT_SYMBOL_GPL(__sock_recv_timestamp); |
669 | 664 | ||
670 | 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) |
@@ -720,6 +715,7 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg, | |||
720 | ret = wait_on_sync_kiocb(&iocb); | 715 | ret = wait_on_sync_kiocb(&iocb); |
721 | return ret; | 716 | return ret; |
722 | } | 717 | } |
718 | EXPORT_SYMBOL(sock_recvmsg); | ||
723 | 719 | ||
724 | static int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, | 720 | static int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, |
725 | size_t size, int flags) | 721 | size_t size, int flags) |
@@ -752,6 +748,7 @@ int kernel_recvmsg(struct socket *sock, struct msghdr *msg, | |||
752 | set_fs(oldfs); | 748 | set_fs(oldfs); |
753 | return result; | 749 | return result; |
754 | } | 750 | } |
751 | EXPORT_SYMBOL(kernel_recvmsg); | ||
755 | 752 | ||
756 | static void sock_aio_dtor(struct kiocb *iocb) | 753 | static void sock_aio_dtor(struct kiocb *iocb) |
757 | { | 754 | { |
@@ -774,7 +771,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page, | |||
774 | } | 771 | } |
775 | 772 | ||
776 | 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, |
777 | struct pipe_inode_info *pipe, size_t len, | 774 | struct pipe_inode_info *pipe, size_t len, |
778 | unsigned int flags) | 775 | unsigned int flags) |
779 | { | 776 | { |
780 | struct socket *sock = file->private_data; | 777 | struct socket *sock = file->private_data; |
@@ -887,7 +884,7 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
887 | */ | 884 | */ |
888 | 885 | ||
889 | static DEFINE_MUTEX(br_ioctl_mutex); | 886 | static DEFINE_MUTEX(br_ioctl_mutex); |
890 | 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); |
891 | 888 | ||
892 | void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *)) | 889 | void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *)) |
893 | { | 890 | { |
@@ -895,7 +892,6 @@ void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *)) | |||
895 | br_ioctl_hook = hook; | 892 | br_ioctl_hook = hook; |
896 | mutex_unlock(&br_ioctl_mutex); | 893 | mutex_unlock(&br_ioctl_mutex); |
897 | } | 894 | } |
898 | |||
899 | EXPORT_SYMBOL(brioctl_set); | 895 | EXPORT_SYMBOL(brioctl_set); |
900 | 896 | ||
901 | static DEFINE_MUTEX(vlan_ioctl_mutex); | 897 | static DEFINE_MUTEX(vlan_ioctl_mutex); |
@@ -907,7 +903,6 @@ void vlan_ioctl_set(int (*hook) (struct net *, void __user *)) | |||
907 | vlan_ioctl_hook = hook; | 903 | vlan_ioctl_hook = hook; |
908 | mutex_unlock(&vlan_ioctl_mutex); | 904 | mutex_unlock(&vlan_ioctl_mutex); |
909 | } | 905 | } |
910 | |||
911 | EXPORT_SYMBOL(vlan_ioctl_set); | 906 | EXPORT_SYMBOL(vlan_ioctl_set); |
912 | 907 | ||
913 | static DEFINE_MUTEX(dlci_ioctl_mutex); | 908 | static DEFINE_MUTEX(dlci_ioctl_mutex); |
@@ -919,7 +914,6 @@ void dlci_ioctl_set(int (*hook) (unsigned int, void __user *)) | |||
919 | dlci_ioctl_hook = hook; | 914 | dlci_ioctl_hook = hook; |
920 | mutex_unlock(&dlci_ioctl_mutex); | 915 | mutex_unlock(&dlci_ioctl_mutex); |
921 | } | 916 | } |
922 | |||
923 | EXPORT_SYMBOL(dlci_ioctl_set); | 917 | EXPORT_SYMBOL(dlci_ioctl_set); |
924 | 918 | ||
925 | static long sock_do_ioctl(struct net *net, struct socket *sock, | 919 | static long sock_do_ioctl(struct net *net, struct socket *sock, |
@@ -1047,6 +1041,7 @@ out_release: | |||
1047 | sock = NULL; | 1041 | sock = NULL; |
1048 | goto out; | 1042 | goto out; |
1049 | } | 1043 | } |
1044 | EXPORT_SYMBOL(sock_create_lite); | ||
1050 | 1045 | ||
1051 | /* No kernel lock held - perfect */ | 1046 | /* No kernel lock held - perfect */ |
1052 | static unsigned int sock_poll(struct file *file, poll_table *wait) | 1047 | static unsigned int sock_poll(struct file *file, poll_table *wait) |
@@ -1147,6 +1142,7 @@ call_kill: | |||
1147 | rcu_read_unlock(); | 1142 | rcu_read_unlock(); |
1148 | return 0; | 1143 | return 0; |
1149 | } | 1144 | } |
1145 | EXPORT_SYMBOL(sock_wake_async); | ||
1150 | 1146 | ||
1151 | 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, |
1152 | struct socket **res, int kern) | 1148 | struct socket **res, int kern) |
@@ -1265,11 +1261,13 @@ int sock_create(int family, int type, int protocol, struct socket **res) | |||
1265 | { | 1261 | { |
1266 | 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); |
1267 | } | 1263 | } |
1264 | EXPORT_SYMBOL(sock_create); | ||
1268 | 1265 | ||
1269 | 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) |
1270 | { | 1267 | { |
1271 | return __sock_create(&init_net, family, type, protocol, res, 1); | 1268 | return __sock_create(&init_net, family, type, protocol, res, 1); |
1272 | } | 1269 | } |
1270 | EXPORT_SYMBOL(sock_create_kern); | ||
1273 | 1271 | ||
1274 | SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol) | 1272 | SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol) |
1275 | { | 1273 | { |
@@ -1474,7 +1472,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr, | |||
1474 | goto out; | 1472 | goto out; |
1475 | 1473 | ||
1476 | err = -ENFILE; | 1474 | err = -ENFILE; |
1477 | if (!(newsock = sock_alloc())) | 1475 | newsock = sock_alloc(); |
1476 | if (!newsock) | ||
1478 | goto out_put; | 1477 | goto out_put; |
1479 | 1478 | ||
1480 | newsock->type = sock->type; | 1479 | newsock->type = sock->type; |
@@ -1861,8 +1860,7 @@ SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned, flags) | |||
1861 | if (MSG_CMSG_COMPAT & flags) { | 1860 | if (MSG_CMSG_COMPAT & flags) { |
1862 | if (get_compat_msghdr(&msg_sys, msg_compat)) | 1861 | if (get_compat_msghdr(&msg_sys, msg_compat)) |
1863 | return -EFAULT; | 1862 | return -EFAULT; |
1864 | } | 1863 | } else if (copy_from_user(&msg_sys, msg, sizeof(struct msghdr))) |
1865 | else if (copy_from_user(&msg_sys, msg, sizeof(struct msghdr))) | ||
1866 | return -EFAULT; | 1864 | return -EFAULT; |
1867 | 1865 | ||
1868 | sock = sockfd_lookup_light(fd, &err, &fput_needed); | 1866 | sock = sockfd_lookup_light(fd, &err, &fput_needed); |
@@ -1964,8 +1962,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg, | |||
1964 | if (MSG_CMSG_COMPAT & flags) { | 1962 | if (MSG_CMSG_COMPAT & flags) { |
1965 | if (get_compat_msghdr(msg_sys, msg_compat)) | 1963 | if (get_compat_msghdr(msg_sys, msg_compat)) |
1966 | return -EFAULT; | 1964 | return -EFAULT; |
1967 | } | 1965 | } else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr))) |
1968 | else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr))) | ||
1969 | return -EFAULT; | 1966 | return -EFAULT; |
1970 | 1967 | ||
1971 | err = -EMSGSIZE; | 1968 | err = -EMSGSIZE; |
@@ -2191,10 +2188,10 @@ SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg, | |||
2191 | /* Argument list sizes for sys_socketcall */ | 2188 | /* Argument list sizes for sys_socketcall */ |
2192 | #define AL(x) ((x) * sizeof(unsigned long)) | 2189 | #define AL(x) ((x) * sizeof(unsigned long)) |
2193 | static const unsigned char nargs[20] = { | 2190 | static const unsigned char nargs[20] = { |
2194 | 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), |
2195 | 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), |
2196 | 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), |
2197 | AL(4),AL(5) | 2194 | AL(4), AL(5) |
2198 | }; | 2195 | }; |
2199 | 2196 | ||
2200 | #undef AL | 2197 | #undef AL |
@@ -2340,6 +2337,7 @@ int sock_register(const struct net_proto_family *ops) | |||
2340 | printk(KERN_INFO "NET: Registered protocol family %d\n", ops->family); | 2337 | printk(KERN_INFO "NET: Registered protocol family %d\n", ops->family); |
2341 | return err; | 2338 | return err; |
2342 | } | 2339 | } |
2340 | EXPORT_SYMBOL(sock_register); | ||
2343 | 2341 | ||
2344 | /** | 2342 | /** |
2345 | * sock_unregister - remove a protocol handler | 2343 | * sock_unregister - remove a protocol handler |
@@ -2366,6 +2364,7 @@ void sock_unregister(int family) | |||
2366 | 2364 | ||
2367 | printk(KERN_INFO "NET: Unregistered protocol family %d\n", family); | 2365 | printk(KERN_INFO "NET: Unregistered protocol family %d\n", family); |
2368 | } | 2366 | } |
2367 | EXPORT_SYMBOL(sock_unregister); | ||
2369 | 2368 | ||
2370 | static int __init sock_init(void) | 2369 | static int __init sock_init(void) |
2371 | { | 2370 | { |
@@ -2395,6 +2394,10 @@ static int __init sock_init(void) | |||
2395 | netfilter_init(); | 2394 | netfilter_init(); |
2396 | #endif | 2395 | #endif |
2397 | 2396 | ||
2397 | #ifdef CONFIG_NETWORK_PHY_TIMESTAMPING | ||
2398 | skb_timestamping_init(); | ||
2399 | #endif | ||
2400 | |||
2398 | return 0; | 2401 | return 0; |
2399 | } | 2402 | } |
2400 | 2403 | ||
@@ -2490,13 +2493,13 @@ static int dev_ifconf(struct net *net, struct compat_ifconf __user *uifc32) | |||
2490 | ifc.ifc_req = NULL; | 2493 | ifc.ifc_req = NULL; |
2491 | uifc = compat_alloc_user_space(sizeof(struct ifconf)); | 2494 | uifc = compat_alloc_user_space(sizeof(struct ifconf)); |
2492 | } else { | 2495 | } else { |
2493 | size_t len =((ifc32.ifc_len / sizeof (struct compat_ifreq)) + 1) * | 2496 | size_t len = ((ifc32.ifc_len / sizeof(struct compat_ifreq)) + 1) * |
2494 | sizeof (struct ifreq); | 2497 | sizeof(struct ifreq); |
2495 | uifc = compat_alloc_user_space(sizeof(struct ifconf) + len); | 2498 | uifc = compat_alloc_user_space(sizeof(struct ifconf) + len); |
2496 | ifc.ifc_len = len; | 2499 | ifc.ifc_len = len; |
2497 | ifr = ifc.ifc_req = (void __user *)(uifc + 1); | 2500 | ifr = ifc.ifc_req = (void __user *)(uifc + 1); |
2498 | ifr32 = compat_ptr(ifc32.ifcbuf); | 2501 | ifr32 = compat_ptr(ifc32.ifcbuf); |
2499 | 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)) { |
2500 | if (copy_in_user(ifr, ifr32, sizeof(struct compat_ifreq))) | 2503 | if (copy_in_user(ifr, ifr32, sizeof(struct compat_ifreq))) |
2501 | return -EFAULT; | 2504 | return -EFAULT; |
2502 | ifr++; | 2505 | ifr++; |
@@ -2516,9 +2519,9 @@ static int dev_ifconf(struct net *net, struct compat_ifconf __user *uifc32) | |||
2516 | ifr = ifc.ifc_req; | 2519 | ifr = ifc.ifc_req; |
2517 | ifr32 = compat_ptr(ifc32.ifcbuf); | 2520 | ifr32 = compat_ptr(ifc32.ifcbuf); |
2518 | for (i = 0, j = 0; | 2521 | for (i = 0, j = 0; |
2519 | 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; |
2520 | i += sizeof (struct compat_ifreq), j += sizeof (struct ifreq)) { | 2523 | i += sizeof(struct compat_ifreq), j += sizeof(struct ifreq)) { |
2521 | if (copy_in_user(ifr32, ifr, sizeof (struct compat_ifreq))) | 2524 | if (copy_in_user(ifr32, ifr, sizeof(struct compat_ifreq))) |
2522 | return -EFAULT; | 2525 | return -EFAULT; |
2523 | ifr32++; | 2526 | ifr32++; |
2524 | ifr++; | 2527 | ifr++; |
@@ -2567,7 +2570,7 @@ static int compat_siocwandev(struct net *net, struct compat_ifreq __user *uifr32 | |||
2567 | compat_uptr_t uptr32; | 2570 | compat_uptr_t uptr32; |
2568 | struct ifreq __user *uifr; | 2571 | struct ifreq __user *uifr; |
2569 | 2572 | ||
2570 | uifr = compat_alloc_user_space(sizeof (*uifr)); | 2573 | uifr = compat_alloc_user_space(sizeof(*uifr)); |
2571 | if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq))) | 2574 | if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq))) |
2572 | return -EFAULT; | 2575 | return -EFAULT; |
2573 | 2576 | ||
@@ -2601,9 +2604,9 @@ static int bond_ioctl(struct net *net, unsigned int cmd, | |||
2601 | return -EFAULT; | 2604 | return -EFAULT; |
2602 | 2605 | ||
2603 | old_fs = get_fs(); | 2606 | old_fs = get_fs(); |
2604 | set_fs (KERNEL_DS); | 2607 | set_fs(KERNEL_DS); |
2605 | err = dev_ioctl(net, cmd, &kifr); | 2608 | err = dev_ioctl(net, cmd, &kifr); |
2606 | set_fs (old_fs); | 2609 | set_fs(old_fs); |
2607 | 2610 | ||
2608 | return err; | 2611 | return err; |
2609 | case SIOCBONDSLAVEINFOQUERY: | 2612 | case SIOCBONDSLAVEINFOQUERY: |
@@ -2710,9 +2713,9 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd, | |||
2710 | return -EFAULT; | 2713 | return -EFAULT; |
2711 | 2714 | ||
2712 | old_fs = get_fs(); | 2715 | old_fs = get_fs(); |
2713 | set_fs (KERNEL_DS); | 2716 | set_fs(KERNEL_DS); |
2714 | err = dev_ioctl(net, cmd, (void __user *)&ifr); | 2717 | err = dev_ioctl(net, cmd, (void __user *)&ifr); |
2715 | set_fs (old_fs); | 2718 | set_fs(old_fs); |
2716 | 2719 | ||
2717 | if (cmd == SIOCGIFMAP && !err) { | 2720 | if (cmd == SIOCGIFMAP && !err) { |
2718 | err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name)); | 2721 | err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name)); |
@@ -2734,7 +2737,7 @@ static int compat_siocshwtstamp(struct net *net, struct compat_ifreq __user *uif | |||
2734 | compat_uptr_t uptr32; | 2737 | compat_uptr_t uptr32; |
2735 | struct ifreq __user *uifr; | 2738 | struct ifreq __user *uifr; |
2736 | 2739 | ||
2737 | uifr = compat_alloc_user_space(sizeof (*uifr)); | 2740 | uifr = compat_alloc_user_space(sizeof(*uifr)); |
2738 | if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq))) | 2741 | if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq))) |
2739 | return -EFAULT; | 2742 | return -EFAULT; |
2740 | 2743 | ||
@@ -2750,20 +2753,20 @@ static int compat_siocshwtstamp(struct net *net, struct compat_ifreq __user *uif | |||
2750 | } | 2753 | } |
2751 | 2754 | ||
2752 | struct rtentry32 { | 2755 | struct rtentry32 { |
2753 | u32 rt_pad1; | 2756 | u32 rt_pad1; |
2754 | struct sockaddr rt_dst; /* target address */ | 2757 | struct sockaddr rt_dst; /* target address */ |
2755 | struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ | 2758 | struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ |
2756 | struct sockaddr rt_genmask; /* target network mask (IP) */ | 2759 | struct sockaddr rt_genmask; /* target network mask (IP) */ |
2757 | unsigned short rt_flags; | 2760 | unsigned short rt_flags; |
2758 | short rt_pad2; | 2761 | short rt_pad2; |
2759 | u32 rt_pad3; | 2762 | u32 rt_pad3; |
2760 | unsigned char rt_tos; | 2763 | unsigned char rt_tos; |
2761 | unsigned char rt_class; | 2764 | unsigned char rt_class; |
2762 | short rt_pad4; | 2765 | short rt_pad4; |
2763 | short rt_metric; /* +1 for binary compatibility! */ | 2766 | short rt_metric; /* +1 for binary compatibility! */ |
2764 | /* char * */ u32 rt_dev; /* forcing the device at add */ | 2767 | /* char * */ u32 rt_dev; /* forcing the device at add */ |
2765 | u32 rt_mtu; /* per route MTU/Window */ | 2768 | u32 rt_mtu; /* per route MTU/Window */ |
2766 | u32 rt_window; /* Window clamping */ | 2769 | u32 rt_window; /* Window clamping */ |
2767 | unsigned short rt_irtt; /* Initial RTT */ | 2770 | unsigned short rt_irtt; /* Initial RTT */ |
2768 | }; | 2771 | }; |
2769 | 2772 | ||
@@ -2793,29 +2796,29 @@ static int routing_ioctl(struct net *net, struct socket *sock, | |||
2793 | 2796 | ||
2794 | if (sock && sock->sk && sock->sk->sk_family == AF_INET6) { /* ipv6 */ | 2797 | if (sock && sock->sk && sock->sk->sk_family == AF_INET6) { /* ipv6 */ |
2795 | struct in6_rtmsg32 __user *ur6 = argp; | 2798 | struct in6_rtmsg32 __user *ur6 = argp; |
2796 | ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst), | 2799 | ret = copy_from_user(&r6.rtmsg_dst, &(ur6->rtmsg_dst), |
2797 | 3 * sizeof(struct in6_addr)); | 2800 | 3 * sizeof(struct in6_addr)); |
2798 | ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type)); | 2801 | ret |= __get_user(r6.rtmsg_type, &(ur6->rtmsg_type)); |
2799 | ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len)); | 2802 | ret |= __get_user(r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len)); |
2800 | ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len)); | 2803 | ret |= __get_user(r6.rtmsg_src_len, &(ur6->rtmsg_src_len)); |
2801 | ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric)); | 2804 | ret |= __get_user(r6.rtmsg_metric, &(ur6->rtmsg_metric)); |
2802 | ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info)); | 2805 | ret |= __get_user(r6.rtmsg_info, &(ur6->rtmsg_info)); |
2803 | ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags)); | 2806 | ret |= __get_user(r6.rtmsg_flags, &(ur6->rtmsg_flags)); |
2804 | ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex)); | 2807 | ret |= __get_user(r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex)); |
2805 | 2808 | ||
2806 | r = (void *) &r6; | 2809 | r = (void *) &r6; |
2807 | } else { /* ipv4 */ | 2810 | } else { /* ipv4 */ |
2808 | struct rtentry32 __user *ur4 = argp; | 2811 | struct rtentry32 __user *ur4 = argp; |
2809 | ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst), | 2812 | ret = copy_from_user(&r4.rt_dst, &(ur4->rt_dst), |
2810 | 3 * sizeof(struct sockaddr)); | 2813 | 3 * sizeof(struct sockaddr)); |
2811 | ret |= __get_user (r4.rt_flags, &(ur4->rt_flags)); | 2814 | ret |= __get_user(r4.rt_flags, &(ur4->rt_flags)); |
2812 | ret |= __get_user (r4.rt_metric, &(ur4->rt_metric)); | 2815 | ret |= __get_user(r4.rt_metric, &(ur4->rt_metric)); |
2813 | ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu)); | 2816 | ret |= __get_user(r4.rt_mtu, &(ur4->rt_mtu)); |
2814 | ret |= __get_user (r4.rt_window, &(ur4->rt_window)); | 2817 | ret |= __get_user(r4.rt_window, &(ur4->rt_window)); |
2815 | ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt)); | 2818 | ret |= __get_user(r4.rt_irtt, &(ur4->rt_irtt)); |
2816 | ret |= __get_user (rtdev, &(ur4->rt_dev)); | 2819 | ret |= __get_user(rtdev, &(ur4->rt_dev)); |
2817 | if (rtdev) { | 2820 | if (rtdev) { |
2818 | ret |= copy_from_user (devname, compat_ptr(rtdev), 15); | 2821 | ret |= copy_from_user(devname, compat_ptr(rtdev), 15); |
2819 | r4.rt_dev = devname; devname[15] = 0; | 2822 | r4.rt_dev = devname; devname[15] = 0; |
2820 | } else | 2823 | } else |
2821 | r4.rt_dev = NULL; | 2824 | r4.rt_dev = NULL; |
@@ -2828,9 +2831,9 @@ static int routing_ioctl(struct net *net, struct socket *sock, | |||
2828 | goto out; | 2831 | goto out; |
2829 | } | 2832 | } |
2830 | 2833 | ||
2831 | set_fs (KERNEL_DS); | 2834 | set_fs(KERNEL_DS); |
2832 | ret = sock_do_ioctl(net, sock, cmd, (unsigned long) r); | 2835 | ret = sock_do_ioctl(net, sock, cmd, (unsigned long) r); |
2833 | set_fs (old_fs); | 2836 | set_fs(old_fs); |
2834 | 2837 | ||
2835 | out: | 2838 | out: |
2836 | return ret; | 2839 | return ret; |
@@ -2993,11 +2996,13 @@ int kernel_bind(struct socket *sock, struct sockaddr *addr, int addrlen) | |||
2993 | { | 2996 | { |
2994 | return sock->ops->bind(sock, addr, addrlen); | 2997 | return sock->ops->bind(sock, addr, addrlen); |
2995 | } | 2998 | } |
2999 | EXPORT_SYMBOL(kernel_bind); | ||
2996 | 3000 | ||
2997 | int kernel_listen(struct socket *sock, int backlog) | 3001 | int kernel_listen(struct socket *sock, int backlog) |
2998 | { | 3002 | { |
2999 | return sock->ops->listen(sock, backlog); | 3003 | return sock->ops->listen(sock, backlog); |
3000 | } | 3004 | } |
3005 | EXPORT_SYMBOL(kernel_listen); | ||
3001 | 3006 | ||
3002 | int kernel_accept(struct socket *sock, struct socket **newsock, int flags) | 3007 | int kernel_accept(struct socket *sock, struct socket **newsock, int flags) |
3003 | { | 3008 | { |
@@ -3022,24 +3027,28 @@ int kernel_accept(struct socket *sock, struct socket **newsock, int flags) | |||
3022 | done: | 3027 | done: |
3023 | return err; | 3028 | return err; |
3024 | } | 3029 | } |
3030 | EXPORT_SYMBOL(kernel_accept); | ||
3025 | 3031 | ||
3026 | int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, | 3032 | int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, |
3027 | int flags) | 3033 | int flags) |
3028 | { | 3034 | { |
3029 | return sock->ops->connect(sock, addr, addrlen, flags); | 3035 | return sock->ops->connect(sock, addr, addrlen, flags); |
3030 | } | 3036 | } |
3037 | EXPORT_SYMBOL(kernel_connect); | ||
3031 | 3038 | ||
3032 | int kernel_getsockname(struct socket *sock, struct sockaddr *addr, | 3039 | int kernel_getsockname(struct socket *sock, struct sockaddr *addr, |
3033 | int *addrlen) | 3040 | int *addrlen) |
3034 | { | 3041 | { |
3035 | return sock->ops->getname(sock, addr, addrlen, 0); | 3042 | return sock->ops->getname(sock, addr, addrlen, 0); |
3036 | } | 3043 | } |
3044 | EXPORT_SYMBOL(kernel_getsockname); | ||
3037 | 3045 | ||
3038 | int kernel_getpeername(struct socket *sock, struct sockaddr *addr, | 3046 | int kernel_getpeername(struct socket *sock, struct sockaddr *addr, |
3039 | int *addrlen) | 3047 | int *addrlen) |
3040 | { | 3048 | { |
3041 | return sock->ops->getname(sock, addr, addrlen, 1); | 3049 | return sock->ops->getname(sock, addr, addrlen, 1); |
3042 | } | 3050 | } |
3051 | EXPORT_SYMBOL(kernel_getpeername); | ||
3043 | 3052 | ||
3044 | int kernel_getsockopt(struct socket *sock, int level, int optname, | 3053 | int kernel_getsockopt(struct socket *sock, int level, int optname, |
3045 | char *optval, int *optlen) | 3054 | char *optval, int *optlen) |
@@ -3056,6 +3065,7 @@ int kernel_getsockopt(struct socket *sock, int level, int optname, | |||
3056 | set_fs(oldfs); | 3065 | set_fs(oldfs); |
3057 | return err; | 3066 | return err; |
3058 | } | 3067 | } |
3068 | EXPORT_SYMBOL(kernel_getsockopt); | ||
3059 | 3069 | ||
3060 | int kernel_setsockopt(struct socket *sock, int level, int optname, | 3070 | int kernel_setsockopt(struct socket *sock, int level, int optname, |
3061 | char *optval, unsigned int optlen) | 3071 | char *optval, unsigned int optlen) |
@@ -3072,6 +3082,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname, | |||
3072 | set_fs(oldfs); | 3082 | set_fs(oldfs); |
3073 | return err; | 3083 | return err; |
3074 | } | 3084 | } |
3085 | EXPORT_SYMBOL(kernel_setsockopt); | ||
3075 | 3086 | ||
3076 | int kernel_sendpage(struct socket *sock, struct page *page, int offset, | 3087 | int kernel_sendpage(struct socket *sock, struct page *page, int offset, |
3077 | size_t size, int flags) | 3088 | size_t size, int flags) |
@@ -3083,6 +3094,7 @@ int kernel_sendpage(struct socket *sock, struct page *page, int offset, | |||
3083 | 3094 | ||
3084 | return sock_no_sendpage(sock, page, offset, size, flags); | 3095 | return sock_no_sendpage(sock, page, offset, size, flags); |
3085 | } | 3096 | } |
3097 | EXPORT_SYMBOL(kernel_sendpage); | ||
3086 | 3098 | ||
3087 | 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) |
3088 | { | 3100 | { |
@@ -3095,33 +3107,10 @@ int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg) | |||
3095 | 3107 | ||
3096 | return err; | 3108 | return err; |
3097 | } | 3109 | } |
3110 | EXPORT_SYMBOL(kernel_sock_ioctl); | ||
3098 | 3111 | ||
3099 | 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) |
3100 | { | 3113 | { |
3101 | return sock->ops->shutdown(sock, how); | 3114 | return sock->ops->shutdown(sock, how); |
3102 | } | 3115 | } |
3103 | |||
3104 | EXPORT_SYMBOL(sock_create); | ||
3105 | EXPORT_SYMBOL(sock_create_kern); | ||
3106 | EXPORT_SYMBOL(sock_create_lite); | ||
3107 | EXPORT_SYMBOL(sock_map_fd); | ||
3108 | EXPORT_SYMBOL(sock_recvmsg); | ||
3109 | EXPORT_SYMBOL(sock_register); | ||
3110 | EXPORT_SYMBOL(sock_release); | ||
3111 | EXPORT_SYMBOL(sock_sendmsg); | ||
3112 | EXPORT_SYMBOL(sock_unregister); | ||
3113 | EXPORT_SYMBOL(sock_wake_async); | ||
3114 | EXPORT_SYMBOL(sockfd_lookup); | ||
3115 | EXPORT_SYMBOL(kernel_sendmsg); | ||
3116 | EXPORT_SYMBOL(kernel_recvmsg); | ||
3117 | EXPORT_SYMBOL(kernel_bind); | ||
3118 | EXPORT_SYMBOL(kernel_listen); | ||
3119 | EXPORT_SYMBOL(kernel_accept); | ||
3120 | EXPORT_SYMBOL(kernel_connect); | ||
3121 | EXPORT_SYMBOL(kernel_getsockname); | ||
3122 | EXPORT_SYMBOL(kernel_getpeername); | ||
3123 | EXPORT_SYMBOL(kernel_getsockopt); | ||
3124 | EXPORT_SYMBOL(kernel_setsockopt); | ||
3125 | EXPORT_SYMBOL(kernel_sendpage); | ||
3126 | EXPORT_SYMBOL(kernel_sock_ioctl); | ||
3127 | EXPORT_SYMBOL(kernel_sock_shutdown); | 3116 | EXPORT_SYMBOL(kernel_sock_shutdown); |