virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: axboe@kernel.dk, martin.petersen@oracle.com,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	kasan-dev@googlegroups.com,
	virtualization@lists.linux-foundation.org,
	James.Bottomley@hansenpartnership.com,
	torvalds@linux-foundation.org, edumazet@google.com,
	linux@roeck-us.net, netdev@vger.kernel.org, c@redhat.com,
	kuba@kernel.org, pabeni@redhat.com, andres@anarazel.de,
	davem@davemloft.net, Dmitry Vyukov <dvyukov@google.com>
Subject: Re: upstream kernel crashes
Date: Wed, 17 Aug 2022 06:53:53 -0400	[thread overview]
Message-ID: <20220817065207-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1660718191.3631961-1-xuanzhuo@linux.alibaba.com>

On Wed, Aug 17, 2022 at 02:36:31PM +0800, Xuan Zhuo wrote:
> On Wed, 17 Aug 2022 08:13:59 +0200, Dmitry Vyukov <dvyukov@google.com> wrote:
> > On Mon, 15 Aug 2022 17:32:06 -0400, Michael wrote:
> > > So if you pass the size parameter for a legacy device it will
> > > try to make the ring smaller and that is not legal with
> > > legacy at all. But the driver treats legacy and modern
> > > the same, it allocates a smaller queue anyway.
> > >
> > > Lo and behold, I pass disable-modern=on to qemu and it happily
> > > corrupts memory exactly the same as GCP does.
> >
> > Ouch!
> >
> > I understand that the host does the actual corruption,
> > but could you think of any additional debug checking in the guest
> > that would caught this in future? Potentially only when KASAN
> > is enabled which can verify validity of memory ranges.
> > Some kind of additional layer of sanity checking.
> >
> > This caused a bit of a havoc for syzbot with almost 100 unique
> > crash signatures, so would be useful to catch such issues more
> > reliably in future.
> 
> We can add a check to vring size before calling vp_legacy_set_queue_address().
> Checking the memory range directly is a bit cumbersome.
> 
> Thanks.

With a comment along the lines of

/* Legacy virtio pci has no way to communicate a change in vq size to
 * the hypervisor. If ring sizes don't match hypervisor will happily
 * corrupt memory.
 */


> diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c
> index 2257f1b3d8ae..0673831f45b6 100644
> --- a/drivers/virtio/virtio_pci_legacy.c
> +++ b/drivers/virtio/virtio_pci_legacy.c
> @@ -146,6 +146,8 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
>                 goto out_del_vq;
>         }
> 
> +       BUG_ON(num != virtqueue_get_vring_size(vq));
> +
>         /* activate the queue */
>         vp_legacy_set_queue_address(&vp_dev->ldev, index, q_pfn);
> 
> 
> >
> > Thanks

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2022-08-17 10:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220814212610.GA3690074@roeck-us.net>
     [not found] ` <CAHk-=wgf2EfLHui6A5NbWoaVBB2f8t-XBUiOMkyjN2NU41t6eA@mail.gmail.com>
     [not found]   ` <20220814223743.26ebsbnrvrjien4f@awork3.anarazel.de>
     [not found]     ` <CAHk-=wi6raoJE-1cyRU0YxJ+9ReO1eXmOAq0FwKAyZS7nhvk9w@mail.gmail.com>
     [not found]       ` <1c057afa-92df-ee3c-5978-3731d3db9345@kernel.dk>
     [not found]         ` <20220815013651.mrm7qgklk6sgpkbb@awork3.anarazel.de>
     [not found]           ` <CAHk-=wikzU4402P-FpJRK_QwfVOS+t-3p1Wx5awGHTvr-s_0Ew@mail.gmail.com>
     [not found]             ` <20220815071143.n2t5xsmifnigttq2@awork3.anarazel.de>
     [not found]               ` <20220815031549-mutt-send-email-mst@kernel.org>
     [not found]                 ` <3df6bb82-1951-455d-a768-e9e1513eb667@www.fastmail.com>
2022-08-15  8:02                   ` upstream kernel crashes Michael S. Tsirkin
     [not found]               ` <20220815034532-mutt-send-email-mst@kernel.org>
     [not found]                 ` <20220815081527.soikyi365azh5qpu@awork3.anarazel.de>
     [not found]                   ` <20220815042623-mutt-send-email-mst@kernel.org>
     [not found]                     ` <FCDC5DDE-3CDD-4B8A-916F-CA7D87B547CE@anarazel.de>
2022-08-15 15:40                       ` Michael S. Tsirkin
2022-08-15 16:45                         ` Andres Freund
2022-08-15 16:50                           ` Michael S. Tsirkin
2022-08-15 17:46                             ` Andres Freund
2022-08-15 20:21                               ` Michael S. Tsirkin
2022-08-15 20:53                                 ` Andres Freund
2022-08-15 21:04                                   ` Andres Freund
2022-08-15 21:10                                     ` Andres Freund
2022-08-15 21:32                                   ` Michael S. Tsirkin
2022-08-16  2:45                                     ` Xuan Zhuo
2022-08-17  6:13                                     ` Dmitry Vyukov via Virtualization
2022-08-17  6:36                                       ` Xuan Zhuo
2022-08-17 10:53                                         ` Michael S. Tsirkin [this message]
2022-08-17 15:58                                         ` Linus Torvalds
2022-08-18  1:55                                           ` Xuan Zhuo
2022-08-15 20:45                             ` Guenter Roeck

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=20220817065207-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=andres@anarazel.de \
    --cc=axboe@kernel.dk \
    --cc=c@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=martin.petersen@oracle.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xuanzhuo@linux.alibaba.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).