From: Al Viro Date: Fri, 20 Mar 2015 17:41:43 +0000 (+0000) Subject: net: validate the range we feed to iov_iter_init() in sys_sendto/sys_recvfrom X-Git-Tag: MMI-PSA29.97-13-9~10418^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4de930efc23b92ddf88ce91c405ee645fe6e27ea;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git net: validate the range we feed to iov_iter_init() in sys_sendto/sys_recvfrom Cc: stable@vger.kernel.org # v3.19 Signed-off-by: Al Viro Signed-off-by: David S. Miller --- diff --git a/net/socket.c b/net/socket.c index bbedbfcb42c2..245330ca0015 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1702,6 +1702,8 @@ SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len, if (len > INT_MAX) len = INT_MAX; + if (unlikely(!access_ok(VERIFY_READ, buff, len))) + return -EFAULT; sock = sockfd_lookup_light(fd, &err, &fput_needed); if (!sock) goto out; @@ -1760,6 +1762,8 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size, if (size > INT_MAX) size = INT_MAX; + if (unlikely(!access_ok(VERIFY_WRITE, ubuf, size))) + return -EFAULT; sock = sockfd_lookup_light(fd, &err, &fput_needed); if (!sock) goto out;