net: Cap number of elements for sendmmsg
authorAnton Blanchard <anton@samba.org>
Thu, 4 Aug 2011 14:07:39 +0000 (14:07 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Aug 2011 01:31:33 +0000 (18:31 -0700)
commit 98382f419f32d2c12d021943b87dea555677144b upstream.

To limit the amount of time we can spend in sendmmsg, cap the
number of elements to UIO_MAXIOV (currently 1024).

For error handling an application using sendmmsg needs to retry at
the first unsent message, so capping is simpler and requires less
application logic than returning EINVAL.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/socket.c

index 8d28c6d225d65fbe621efbf042749a08a8e1bb74..e1cf264b411227c58697e8a53e31dd3dbeeda1db 100644 (file)
@@ -1999,6 +1999,9 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
        struct compat_mmsghdr __user *compat_entry;
        struct msghdr msg_sys;
 
+       if (vlen > UIO_MAXIOV)
+               vlen = UIO_MAXIOV;
+
        datagrams = 0;
 
        sock = sockfd_lookup_light(fd, &err, &fput_needed);