aboutsummaryrefslogtreecommitdiffstats
path: root/net/compat.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-07-01 07:26:02 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-15 11:53:39 -0400
commit1dacc76d0014a034b8aca14237c127d7c19d7726 (patch)
treed3ba044578fab9076ef4a73694fa7d23d4a50969 /net/compat.c
parent4f45b2cd4e78b5e49d7d41548345b879d3fdfeae (diff)
net/compat/wext: send different messages to compat tasks
Wireless extensions have the unfortunate problem that events are multicast netlink messages, and are not independent of pointer size. Thus, currently 32-bit tasks on 64-bit platforms cannot properly receive events and fail with all kinds of strange problems, for instance wpa_supplicant never notices disassociations, due to the way the 64-bit event looks (to a 32-bit process), the fact that the address is all zeroes is lost, it thinks instead it is 00:00:00:00:01:00. The same problem existed with the ioctls, until David Miller fixed those some time ago in an heroic effort. A different problem caused by this is that we cannot send the ASSOCREQIE/ASSOCRESPIE events because sending them causes a 32-bit wpa_supplicant on a 64-bit system to overwrite its internal information, which is worse than it not getting the information at all -- so we currently resort to sending a custom string event that it then parses. This, however, has a severe size limitation we are frequently hitting with modern access points; this limitation would can be lifted after this patch by sending the correct binary, not custom, event. A similar problem apparently happens for some other netlink users on x86_64 with 32-bit tasks due to the alignment for 64-bit quantities. In order to fix these problems, I have implemented a way to send compat messages to tasks. When sending an event, we send the non-compat event data together with a compat event data in skb_shinfo(main_skb)->frag_list. Then, when the event is read from the socket, the netlink code makes sure to pass out only the skb that is compatible with the task. This approach was suggested by David Miller, my original approach required always sending two skbs but that had various small problems. To determine whether compat is needed or not, I have used the MSG_CMSG_COMPAT flag, and adjusted the call path for recv and recvfrom to include it, even if those calls do not have a cmsg parameter. I have not solved one small part of the problem, and I don't think it is necessary to: if a 32-bit application uses read() rather than any form of recvmsg() it will still get the wrong (64-bit) event. However, neither do applications actually do this, nor would it be a regression. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/compat.c')
-rw-r--r--net/compat.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/net/compat.c b/net/compat.c
index 8d739053afe4..12728b17a226 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -743,6 +743,18 @@ asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, uns
743 return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT); 743 return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
744} 744}
745 745
746asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len, unsigned flags)
747{
748 return sys_recv(fd, buf, len, flags | MSG_CMSG_COMPAT);
749}
750
751asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
752 unsigned flags, struct sockaddr __user *addr,
753 int __user *addrlen)
754{
755 return sys_recvfrom(fd, buf, len, flags | MSG_CMSG_COMPAT, addr, addrlen);
756}
757
746asmlinkage long compat_sys_socketcall(int call, u32 __user *args) 758asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
747{ 759{
748 int ret; 760 int ret;
@@ -788,10 +800,11 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
788 ret = sys_sendto(a0, compat_ptr(a1), a[2], a[3], compat_ptr(a[4]), a[5]); 800 ret = sys_sendto(a0, compat_ptr(a1), a[2], a[3], compat_ptr(a[4]), a[5]);
789 break; 801 break;
790 case SYS_RECV: 802 case SYS_RECV:
791 ret = sys_recv(a0, compat_ptr(a1), a[2], a[3]); 803 ret = compat_sys_recv(a0, compat_ptr(a1), a[2], a[3]);
792 break; 804 break;
793 case SYS_RECVFROM: 805 case SYS_RECVFROM:
794 ret = sys_recvfrom(a0, compat_ptr(a1), a[2], a[3], compat_ptr(a[4]), compat_ptr(a[5])); 806 ret = compat_sys_recvfrom(a0, compat_ptr(a1), a[2], a[3],
807 compat_ptr(a[4]), compat_ptr(a[5]));
795 break; 808 break;
796 case SYS_SHUTDOWN: 809 case SYS_SHUTDOWN:
797 ret = sys_shutdown(a0,a1); 810 ret = sys_shutdown(a0,a1);