netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Jason Wang <jasowang@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	netdev@vger.kernel.org, Brad Hubbard <bhubbard@redhat.com>
Subject: Re: [PATCH net] tun: fix recovery from gup errors
Date: Mon, 24 Jun 2013 15:54:12 +0300	[thread overview]
Message-ID: <20130624125412.GA690@redhat.com> (raw)
In-Reply-To: <51C715F5.2050300@cogentembedded.com>

On Sun, Jun 23, 2013 at 07:36:21PM +0400, Sergei Shtylyov wrote:
> Hello.
> 
> On 23-06-2013 18:19, Michael S. Tsirkin wrote:
> 
> >get user pages might fail partially in tun zero copy
> >mode. To recover we need to put all pages that we got,
> >but code used a wrong index resulting in double-free
> >errors.
> 
> >Reported-by: Brad Hubbard <bhubbard@redhat.com>
> >Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> >---
> 
> >I haven't figured out why do we get failures,
> >but recovery is clearly wrong.
> 
> >This is also -stable material.
> 
> >  drivers/net/tun.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> >diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> >index bfa9bb4..c098b1e 100644
> >--- a/drivers/net/tun.c
> >+++ b/drivers/net/tun.c
> >@@ -1010,8 +1010,9 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
> >  			return -EMSGSIZE;
> >  		num_pages = get_user_pages_fast(base, size, 0, &page[i]);
> >  		if (num_pages != size) {
> >-			for (i = 0; i < num_pages; i++)
> >-				put_page(page[i]);
> >+			int j;
> 
>   Empty line wouldn't hurt here, after declaration.
> 
> >+			for (j = 0; j < num_pages; j++)
> >+				put_page(page[i + j]);

I think it's clearer without: this is the only code
within this block, declaration is really part of
the loop that comes after it.
An empty line would break it up visually.

  reply	other threads:[~2013-06-24 12:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-23 14:19 [PATCH net] tun: fix recovery from gup errors Michael S. Tsirkin
2013-06-23 15:36 ` Sergei Shtylyov
2013-06-24 12:54   ` Michael S. Tsirkin [this message]
2013-06-24 18:34     ` David Miller
2013-06-24  3:22 ` Jason Wang
2013-06-25 23:24   ` David Miller
2013-06-24 11:31 ` Neil Horman

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=20130624125412.GA690@redhat.com \
    --to=mst@redhat.com \
    --cc=bhubbard@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).