aboutsummaryrefslogtreecommitdiffstats
path: root/net/compat.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /net/compat.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'net/compat.c')
-rw-r--r--net/compat.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/net/compat.c b/net/compat.c
index a407c3addbae..ec24d9edb025 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/gfp.h>
15#include <linux/fs.h> 16#include <linux/fs.h>
16#include <linux/types.h> 17#include <linux/types.h>
17#include <linux/file.h> 18#include <linux/file.h>
@@ -390,9 +391,6 @@ asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
390 int err; 391 int err;
391 struct socket *sock; 392 struct socket *sock;
392 393
393 if (optlen < 0)
394 return -EINVAL;
395
396 if ((sock = sockfd_lookup(fd, &err))!=NULL) 394 if ((sock = sockfd_lookup(fd, &err))!=NULL)
397 { 395 {
398 err = security_socket_setsockopt(sock,level,optname); 396 err = security_socket_setsockopt(sock,level,optname);
@@ -727,10 +725,10 @@ EXPORT_SYMBOL(compat_mc_getsockopt);
727 725
728/* Argument list sizes for compat_sys_socketcall */ 726/* Argument list sizes for compat_sys_socketcall */
729#define AL(x) ((x) * sizeof(u32)) 727#define AL(x) ((x) * sizeof(u32))
730static unsigned char nas[19]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), 728static unsigned char nas[20]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
731 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), 729 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
732 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3), 730 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
733 AL(4)}; 731 AL(4),AL(5)};
734#undef AL 732#undef AL
735 733
736asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags) 734asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags)
@@ -755,13 +753,35 @@ asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
755 return sys_recvfrom(fd, buf, len, flags | MSG_CMSG_COMPAT, addr, addrlen); 753 return sys_recvfrom(fd, buf, len, flags | MSG_CMSG_COMPAT, addr, addrlen);
756} 754}
757 755
756asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
757 unsigned vlen, unsigned int flags,
758 struct compat_timespec __user *timeout)
759{
760 int datagrams;
761 struct timespec ktspec;
762
763 if (timeout == NULL)
764 return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
765 flags | MSG_CMSG_COMPAT, NULL);
766
767 if (get_compat_timespec(&ktspec, timeout))
768 return -EFAULT;
769
770 datagrams = __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
771 flags | MSG_CMSG_COMPAT, &ktspec);
772 if (datagrams > 0 && put_compat_timespec(&ktspec, timeout))
773 datagrams = -EFAULT;
774
775 return datagrams;
776}
777
758asmlinkage long compat_sys_socketcall(int call, u32 __user *args) 778asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
759{ 779{
760 int ret; 780 int ret;
761 u32 a[6]; 781 u32 a[6];
762 u32 a0, a1; 782 u32 a0, a1;
763 783
764 if (call < SYS_SOCKET || call > SYS_ACCEPT4) 784 if (call < SYS_SOCKET || call > SYS_RECVMMSG)
765 return -EINVAL; 785 return -EINVAL;
766 if (copy_from_user(a, args, nas[call])) 786 if (copy_from_user(a, args, nas[call]))
767 return -EFAULT; 787 return -EFAULT;
@@ -823,6 +843,10 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
823 case SYS_RECVMSG: 843 case SYS_RECVMSG:
824 ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]); 844 ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]);
825 break; 845 break;
846 case SYS_RECVMMSG:
847 ret = compat_sys_recvmmsg(a0, compat_ptr(a1), a[2], a[3],
848 compat_ptr(a[4]));
849 break;
826 case SYS_ACCEPT4: 850 case SYS_ACCEPT4:
827 ret = sys_accept4(a0, compat_ptr(a1), compat_ptr(a[2]), a[3]); 851 ret = sys_accept4(a0, compat_ptr(a1), compat_ptr(a[2]), a[3]);
828 break; 852 break;