netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: recvmmsg: Strip MSG_WAITFORONE when calling recvmsg
@ 2011-05-16 22:59 Anton Blanchard
  2011-05-17 19:38 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Blanchard @ 2011-05-16 22:59 UTC (permalink / raw)
  To: acme, davem; +Cc: netdev


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.

Signed-off-by: Anton Blanchard <anton@samba.org>
Cc: stable@kernel.org [2.6.34+]
---

We could also add MSG_WAITFORONE to the raw socket recvmsg check, or
just remove the check completely. Thoughts?

Index: linux-net/net/socket.c
===================================================================
--- linux-net.orig/net/socket.c	2011-05-09 08:59:22.757767314 +1000
+++ linux-net/net/socket.c	2011-05-16 17:14:52.501268819 +1000
@@ -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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: recvmmsg: Strip MSG_WAITFORONE when calling recvmsg
  2011-05-16 22:59 [PATCH] net: recvmmsg: Strip MSG_WAITFORONE when calling recvmsg Anton Blanchard
@ 2011-05-17 19:38 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-05-17 19:38 UTC (permalink / raw)
  To: anton; +Cc: acme, netdev

From: Anton Blanchard <anton@samba.org>
Date: Tue, 17 May 2011 08:59:24 +1000

> 
> 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.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>
> Cc: stable@kernel.org [2.6.34+]
> ---
> 
> We could also add MSG_WAITFORONE to 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-17 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-16 22:59 [PATCH] net: recvmmsg: Strip MSG_WAITFORONE when calling recvmsg Anton Blanchard
2011-05-17 19:38 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).