net: recvmmsg: Strip MSG_WAITFORONE when calling recvmsg
Subsystems (3)
PATCH 1/1 net: recvmmsg: Strip MSG_WAITFORONE when calling recvmsg
recvmmsg fails on a raw socket with EINVAL. The reason for this is packet_recvmsg checks the incoming flags:
err = -EINVAL;
if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT|MSG_ERRQUEUE))
goto out;This patch strips out MSG_WAITFORONE when calling recvmmsg which fixes the issue.
---
We could also add MSG_WAITFORONE to the raw socket recvmsg check, or just remove the check completely. Thoughts?
net/socket.c +4 -2
@@ -2232,14 +2232,16 @@ int __sys_recvmmsg(int fd, struct mmsghd*/ if (MSG_CMSG_COMPAT & flags) { err =__sys_recvmsg (sock, (struct msghdr __user *)compat_entry, - &msg_sys, flags, datagrams); + &msg_sys, flags & ~MSG_WAITFORONE , + datagrams);if (err <0 )break ; err =__put_user (err, &compat_entry->msg_len); ++compat_entry; }else { err =__sys_recvmsg (sock, (struct msghdr __user *)entry, - &msg_sys, flags, datagrams); + &msg_sys, flags & ~MSG_WAITFORONE , + datagrams);if (err <0 )break ; err =put_user (err, &entry->msg_len);
David Miller
maintainerFrom: Anton Blanchard <[email protected]>
Date: Tue, 17 May 2011 08:59:24 +1000
Quoted 11 lines
recvmmsg fails on a raw socket with EINVAL. The reason for this is
packet_recvmsgchecks the incoming flags:err = -EINVAL; if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT|MSG_ERRQUEUE)) goto out;This patch strips out
MSG_WAITFORONEwhen calling recvmmsg which fixes the issue.
Quoted 6 lines
Signed-off-by Anton Blanchard <[email protected]>Cc [email protected] [2.6.34+]---
We could also add
MSG_WAITFORONEto the raw socket recvmsg check, or just remove the check completely. Thoughts?
I think both should be done.
Tests like the one packet_recvmsg() is doing makes it really hard to add new MSG_* flags generically (ie. by adding the flag and having some generic socket operation all recvmsg() implementations call process that flag bit in some way).
It should just explicitly check for the bits it doesn't support.
And recvmmsg() should clear the bit because it is a completely internal thing. It's similar to how we hide MSG_CMSG_COMPAT from userspace.
Anyways I'll apply this patch, and feel free to submit the other one.
Thanks.