qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: jean-philippe menil <jpmenil@gmail.com>
Cc: netdev@vger.kernel.org, jasowang@redhat.com,
	John Fastabend <john.fastabend@gmail.com>,
	virtualization@lists.linux-foundation.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] BUG: KASAN: use-after-free in free_old_xmit_skbs
Date: Thu, 22 Jun 2017 21:53:03 +0300	[thread overview]
Message-ID: <20170622215125-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAOTcU=u_HSMQiwDF3Snv5P8mT-b_Aepeb=Z9gbLd1j=2P+Yy+A@mail.gmail.com>

On Thu, Jun 22, 2017 at 08:15:58AM +0200, jean-philippe menil wrote:
> 2017-06-06 1:52 GMT+02:00 Michael S. Tsirkin <mst@redhat.com>:
> 
>     On Mon, Jun 05, 2017 at 05:08:25AM +0300, Michael S. Tsirkin wrote:
>     > On Mon, Jun 05, 2017 at 12:48:53AM +0200, Jean-Philippe Menil wrote:
>     > > Hi,
>     > >
>     > > while playing with xdp and ebpf, i'm hitting the following:
>     > >
>     > > [  309.993136]
>     > > ==================================================================
>     > > [  309.994735] BUG: KASAN: use-after-free in
>     > > free_old_xmit_skbs.isra.29+0x2b7/0x2e0 [virtio_net]
>     > > [  309.998396] Read of size 8 at addr ffff88006aa64220 by task sshd/323
>     > > [  310.000650]
>     > > [  310.002305] CPU: 1 PID: 323 Comm: sshd Not tainted 4.12.0-rc3+ #2
>     > > [  310.004018] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
>     BIOS
>     > > 1.10.2-20170228_101828-anatol 04/01/2014

...

>     >
>     > Since commit 680557cf79f82623e2c4fd42733077d60a843513
>     >     virtio_net: rework mergeable buffer handling
>     >
>     > we no longer must do the resets, we now have enough space
>     > to store a bit saying whether a buffer is xdp one or not.
>     >
>     > And that's probably a cleaner way to fix these issues than
>     > try to find and fix the race condition.
>     >
>     > John?
>     >
>     > --
>     > MST
> 
> 
>     I think I see the source of the race. virtio net calls
>     netif_device_detach and assumes no packets will be sent after
>     this point. However, all it does is stop all queues so
>     no new packets will be transmitted.
> 
>     Try locking with HARD_TX_LOCK?
>    
> 
>     --
>     MST
> 
> 
> Hi Michael,
> 
> from what i see, the race appear when we hit virtnet_reset in virtnet_xdp_set.
> virtnet_reset
>   _remove_vq_common
>     virtnet_del_vqs
>       virtnet_free_queues
>         kfree(vi->sq)
> when the xdp program (with two instances of the program to trigger it faster)
> is added or removed.
> 
> It's easily repeatable, with 2 cpus and 4 queues on the qemu command line,
> running the xdp_ttl tool from Jesper.
> 
> For now, i'm able to continue my qualification, testing if xdp_qp is not null,
> but do not seem to be a sustainable trick.
> if (xdp_qp && vi->xdp_queues_pairs != xdp_qp)
> 
> Maybe it will be more clear to you with theses informations.
> 
> Best regards.
> 
> Jean-Philippe


I'm pretty clear about the issue here, I was trying to figure out a fix.
Jason, any thoughts?


-- 
MST

  reply	other threads:[~2017-06-22 18:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d2e8cf65-ea3d-7db2-9382-a063daf1168a@gmail.com>
     [not found] ` <20170605050423-mutt-send-email-mst@kernel.org>
2017-06-05 23:52   ` [Qemu-devel] BUG: KASAN: use-after-free in free_old_xmit_skbs Michael S. Tsirkin
2017-06-22  6:15     ` jean-philippe menil
2017-06-22 18:53       ` Michael S. Tsirkin [this message]
2017-06-23  8:43         ` Jason Wang
2017-06-23  9:33           ` Jean-Philippe Menil
2017-06-23 22:32           ` Cong Wang
2017-06-26  2:50             ` Jason Wang
2017-06-26  7:35               ` Jean-Philippe Menil
2017-06-27  2:13                 ` Jason Wang
2017-06-27 12:35                   ` Jean-Philippe Menil

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=20170622215125-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=john.fastabend@gmail.com \
    --cc=jpmenil@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=virtualization@lists.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 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).