All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, jon.maloy@ericsson.com,
	allan.stephens@windriver.com,
	Dan Rosenberg <drosenberg@vsecurity.com>
Subject: Re: [PATCH] net: Limit socket I/O iovec total length to INT_MAX.
Date: Fri, 29 Oct 2010 17:45:32 +0100	[thread overview]
Message-ID: <20101029164532.GV19804@ZenIV.linux.org.uk> (raw)
In-Reply-To: <AANLkTi=sUDRzGnkp57OCQUi9APHWLYLShhiTVHLyq1eV@mail.gmail.com>

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?

  reply	other threads:[~2010-10-29 16:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-28 18:22 [PATCH] net: Limit socket I/O iovec total length to INT_MAX David Miller
2010-10-28 18:33 ` Linus Torvalds
2010-10-28 18:37   ` David Miller
2010-10-29  6:40 ` Linus Torvalds
2010-10-29 14:00   ` Dan Rosenberg
2010-10-29 15:28     ` Linus Torvalds
2010-10-29 16:21       ` Linus Torvalds
2010-10-29 16:45         ` Al Viro [this message]
2010-10-29 17:01           ` Linus Torvalds
2010-10-29 17:32             ` Al Viro
2010-10-29 19:32         ` David Miller
2010-10-29 19:37           ` Linus Torvalds
2010-10-29 19:55             ` David Miller
2010-10-29 20:22               ` Dan Rosenberg
2010-10-29 18:51       ` Rick Jones
2010-10-29 18:59         ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101029164532.GV19804@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=allan.stephens@windriver.com \
    --cc=davem@davemloft.net \
    --cc=drosenberg@vsecurity.com \
    --cc=jon.maloy@ericsson.com \
    --cc=netdev@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.