From: Anton Blanchard Date: Thu, 4 Aug 2011 14:07:39 +0000 (+0000) Subject: net: Cap number of elements for sendmmsg X-Git-Tag: firefly_0821_release~3680^2~4716^2~4 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=98382f419f32d2c12d021943b87dea555677144b;p=firefly-linux-kernel-4.4.55.git net: Cap number of elements for sendmmsg 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 Cc: stable [3.0+] Signed-off-by: David S. Miller --- diff --git a/net/socket.c b/net/socket.c index e4ed2359eb43..b5c6de4f268a 100644 --- a/net/socket.c +++ b/net/socket.c @@ -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);