qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cindy Lu <lulu@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, qemu-stable@nongnu.org,
	 Lei Yang <leiyang@redhat.com>, Jason Wang <jasowang@redhat.com>
Subject: Re: [PULL 1/1] virtio-pci: fix use of a released vector
Date: Tue, 16 Apr 2024 20:47:57 +0800	[thread overview]
Message-ID: <CACLfguX=OXk9Q-ax87FOTADT+b5Yov1x14XBgxH5J2=SGy1O6w@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA_WxhOpjtZ5r-CfoOaf1aiKeaEV9eX=drb1JaBCiBoDKA@mail.gmail.com>

On Tue, Apr 16, 2024 at 7:50 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Tue, 16 Apr 2024 at 12:05, Cindy Lu <lulu@redhat.com> wrote:
> >
> > On Tue, Apr 16, 2024 at 6:01 PM Peter Maydell <peter.maydell@linaro.org> wrote:
> > > Here we pass that through to kvm_virtio_pci_vector_use_one().
> > > In kvm_virtio_pci_vector_use_one()'s error-exit path ("undo")
> > > it does
> > >     vector = virtio_queue_vector(vdev, queue_no);
> > > and in virtio_queue_vector() it does:
> > >
> > >     return n < VIRTIO_QUEUE_MAX ? vdev->vq[n].vector :
> > >         VIRTIO_NO_VECTOR;
> > >
> > > where 'n' is an int, so if we can get here with queue_no being
> > > VIRTIO_CONFIG_IRQ_IDX then we'll index off the front of the
> > > vdev->vq[] array.
> > >
> > > Maybe this is a "can't happen" case, but it does seem odd that
> > > virtio_queue_vector() only bounds-checks the "too big" case
> > > for its argument and not the "too small" case and/or it
> > > doesn't have a special case for VIRTIO_CONFIG_IRQ_IDX.
> > >
> > > > +    }
> > > > +}
> > > > +
> > >
> > hi peter
> > I think we can simply remove the part
> >     vector = virtio_queue_vector(vdev, queue_no);
> > the vector is get from virtio_pci_get_notifier() and don't need to get it again
> > I will send the fix soon
>
> The error handling in kvm_virtio_pci_vector_use_one() looks
> a bit odd in other ways, too. The only bit of "undoing"
> it does as far as I can see is calling kvm_virtio_pci_irqfd_release(),
> but there is no code path that gets to there where the
> main codepath's call to kvm_virtio-pci_irqfd_use() succeeded
> and needs to be undone. So perhaps the entire "undo" code
> block should be deleted, and the "goto undo" lines
> replaced by simple "return ret;" ?  (The codepath
> for "kvm_virtio_pci_irqfd_use() failed" already does the
> "kvm_virtio_pci_vq_vector_release()" by hand there.)
>
> thanks
> -- PMM
>
Hi peter,
Really thanks for your help. I have rewrite this part, the error
handling part is incorrect
Thanks
Cindy



  parent reply	other threads:[~2024-04-16 12:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 10:52 [PULL 0/1] virtio: bugfix Michael S. Tsirkin
2024-04-15 10:52 ` [PULL 1/1] virtio-pci: fix use of a released vector Michael S. Tsirkin
2024-04-16 10:01   ` Peter Maydell
2024-04-16 11:04     ` Cindy Lu
2024-04-16 11:50       ` Peter Maydell
2024-04-16 12:22         ` Peter Maydell
2024-04-16 13:06           ` Cindy Lu
2024-04-16 13:11             ` Peter Maydell
2024-04-16 12:47         ` Cindy Lu [this message]
2024-04-15 14:24 ` [PULL 0/1] virtio: bugfix Peter Maydell

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='CACLfguX=OXk9Q-ax87FOTADT+b5Yov1x14XBgxH5J2=SGy1O6w@mail.gmail.com' \
    --to=lulu@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=leiyang@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.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).