[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101029164532.GV19804@ZenIV.linux.org.uk>
Date: Fri, 29 Oct 2010 17:45:32 +0100
From: Al Viro <viro@...IV.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
jon.maloy@...csson.com, allan.stephens@...driver.com,
Dan Rosenberg <drosenberg@...curity.com>
Subject: Re: [PATCH] net: Limit socket I/O iovec total length to INT_MAX.
On Fri, Oct 29, 2010 at 09:21:16AM -0700, Linus Torvalds wrote:
> ret = -EINVAL;
> for (seg = 0; seg < nr_segs; seg++) {
> - compat_ssize_t tmp = tot_len;
> compat_uptr_t buf;
> compat_ssize_t len;
>
> @@ -624,13 +624,13 @@ ssize_t compat_rw_copy_check_uvector(int type,
> }
> if (len < 0) /* size_t not fitting in compat_ssize_t .. */
> goto out;
> - tot_len += len;
> - if (tot_len < tmp) /* maths overflow on the compat_ssize_t */
> - goto out;
> if (!access_ok(vrfy_dir(type), compat_ptr(buf), len)) {
> ret = -EFAULT;
> goto out;
> }
> + if (len > MAX_RW_COUNT - tot_len)
> + len = MAX_RW_COUNT - tot_len;
> + tot_len += len;
> iov->iov_base = compat_ptr(buf);
> iov->iov_len = (compat_size_t) len;
> uvector++;
Interesting... Had anybody tested vectors with 0 iov_len in the end and/or
middle? Looks like something rarely hit in practice...
I don't see anything obviously broken (and we obviously have allowed
iov_len == 0 cases all along, so if anything, breakage won't be new).
However, I wonder if things like sendmsg() for datagrams have warranties
against silent truncation. Davem?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists