Skip to content

Commit

Permalink
net: Cap number of elements for sendmmsg
Browse files Browse the repository at this point in the history
commit 98382f4 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>
  • Loading branch information
Anton Blanchard authored and Greg Kroah-Hartman committed Aug 16, 2011
1 parent 365f1cd commit 91f620f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 91f620f

Please sign in to comment.