All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
	"Yonggang Luo" <luoyonggang@gmail.com>,
	"Miku Hatsune" <anznu1l@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@mailo.com>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"QEMU Stable" <qemu-stable@nongnu.org>
Subject: Re: [PULL v2 09/30] virtio-mmio: fix QUEUE_NUM_MAX
Date: Wed, 29 Jul 2026 05:38:11 -0400	[thread overview]
Message-ID: <20260729053423-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <23cbb4e8-1467-4a0f-9af7-67e3c64cba7e@tls.msk.ru>

On Wed, Jul 29, 2026 at 12:25:30PM +0300, Michael Tokarev wrote:
> On 7/29/26 08:12, Michael Tokarev wrote:
> > On 7/29/26 02:22, Michael S. Tsirkin wrote:
> > > On Tue, Jul 28, 2026 at 11:17:34PM +0300, Michael Tokarev wrote:
> > ..
> > > > So this whole change, for older versions, becomes just:
> > > > 
> > > > --- a/hw/virtio/virtio.c
> > > > +++ b/hw/virtio/virtio.c
> > > > @@ -2572,6 +2572,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
> > > >       if (i == VIRTIO_QUEUE_MAX || queue_size > VIRTQUEUE_MAX_SIZE)
> > > >           abort();
> > > > 
> > > > +    queue_size = VIRTQUEUE_MAX_SIZE; /* fixed properly in 11.1. */
> > > > +
> > > 
> > > Or you can stick to upstream and add the compat entry for 11.0.
> > 
> > Compat entry for 11.0 which will never be used?
> > With a non-obvious logic which boils down to this single line?
> > 
> > Or what do you mean?
> > 
> > BTW, can't this logic be implemented without a compat property in
> > the first place?  This x-override-queue-size seems like a hack.
> > or a.. twisted way to compare a machine version.
> > 
> > Can't this very place become
> > 
> >     if (machine_version < 11.1) {
> >        queue_size = VIRTQUEUE_MAX_SIZE;
> >     }
> > 
> > instead of using this indirect property?
> 
> Michael, I still don't understand what we're doing here and - now -
> why do we need to distinguish between old and new machine types at all.
> 
> Behavior before the fixes:
> 
>  qemu always reported queue size to be the maximum allowed one (1024),
>    even if actual queue size requested and allocated was smaller
>  qemu accepted requests to elements past the allocated size, which
>    allowed to read/write past the allocated buffer - which can't be
>    considered part of ABI, obviously :)
> 
> Behavior after the fixes, for new machine types:
> 
>  qemu reports actually requested and allocated queue size
>  qemu properly disallows access past the allocated queue size
> 
> What would break if we switch to the new behavior unconditionally,
> regardless of the machine types?

It's guest visible. You will get two reads from same register
suddenly returning different values.


> I don't understand why do you suggest to implement the same logic for
> older/stable qemu versions if it will always evaluate to allocating
> the max size for the queue regardless of the requested size.
> 
> Thanks,
> 
> /mjt

My preference, normally, is to just stick to upstream as much as
possibly. I just do not want slightly different code bases when we can
trivially have one.  If nothing else, less of a chance a follow up patch
will cause conflicts, and then it snowballs from there.


-- 
MST



  reply	other threads:[~2026-07-29  9:38 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 19:19 [PULL v2 00/30] pci, vhost, virtio, iommu: bugfixes Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 01/30] virtio: use masked features with set_features_ex Michael S. Tsirkin
2026-07-28  7:26   ` Paolo Abeni
2026-07-27 19:19 ` [PULL v2 02/30] virtio-net: fix OOB read in RSC receive path Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 03/30] virtio-net: fix short frame OOB read in receive_filter() Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 04/30] libvhost-user: protect against OOB writes in vu_set_inflight_fd Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 05/30] libvhost-user: protect against OOB vring queue access Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 06/30] hw/virtio: reject zero-length packed indirect descriptor table Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 07/30] vhost: do not crash on ring map failure Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 08/30] virtio-scsi: fix SCSIRequest leak on a bad request Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 09/30] virtio-mmio: fix QUEUE_NUM_MAX Michael S. Tsirkin
2026-07-28  8:40   ` Michael Tokarev
2026-07-28 19:45     ` Michael S. Tsirkin
2026-07-28 20:17       ` Michael Tokarev
2026-07-28 23:22         ` Michael S. Tsirkin
2026-07-29  5:12           ` Michael Tokarev
2026-07-29  5:24             ` Michael Tokarev
2026-07-29  6:43               ` Michael S. Tsirkin
2026-07-29  9:25             ` Michael Tokarev
2026-07-29  9:38               ` Michael S. Tsirkin [this message]
2026-07-29  9:49                 ` Michael Tokarev
2026-07-29 10:26                   ` Michael S. Tsirkin
2026-07-27 19:19 ` [PULL v2 10/30] virtio: fix queue size validation against allocated maximum Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 11/30] virtio: stop migrating num_default, validate vring.num on load Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 12/30] virtio: fail early on bad config_len in migration Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 13/30] vhost-user: assert nregions within limit Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 14/30] virtio-pmem: wait for flush requests on unrealize Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 15/30] libvhost-user: validate last_batch_head in vu_check_queue_inflights Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 16/30] libvhost-user: fix heap overflow " Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 17/30] libvduse: validate vq size Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 18/30] virtio-iommu: fix OOM due to unbounded call_rcu Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 19/30] virtio-snd: check rx buffer descriptor size Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 20/30] virtio-snd: check for overflow before g_malloc0 Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 21/30] hw/pci-host/q35.c: Always initialize smram-region even if SMM disabled Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 22/30] hw/pci-host/q35.c: Factor out creation of SMRAM MRs Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 23/30] hw/pci-host/q35.c: Avoid early return in mch_write_config() Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 24/30] hw/virtio/vdpa-dev: pass set_config buffer to vhost backend Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 25/30] hw/cxl: fix OOB access in cxl_doe_cdat_rsp via entry_handle Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 26/30] intel_iommu: Check address mask before using it in pasid-based iotlb invalidation Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 27/30] hw/net/virtio-net: Protect from DMA re-entrancy bugs Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 28/30] hw/virtio-rng: Fix host use-after-free (CVE-2026-50624) Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 29/30] backends/rng: cap request size to avoid oversized allocation Michael S. Tsirkin
2026-07-27 19:20 ` [PULL v2 30/30] virtio: avoid packed vring virtio_queue_empty() infinite loops (CVE-2026-16457) Michael S. Tsirkin
2026-07-28 11:42 ` [PULL v2 00/30] pci, vhost, virtio, iommu: bugfixes Stefan Hajnoczi

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=20260729053423-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=anznu1l@gmail.com \
    --cc=luoyonggang@gmail.com \
    --cc=mjt@tls.msk.ru \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@mailo.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=zhao1.liu@intel.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 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.