From: Alex Williamson <alex.williamson@redhat.com>
To: Matthew Rosato <mjrosato@linux.ibm.com>
Cc: Zhenzhong Duan <zhenzhong.duan@intel.com>,
qemu-devel@nongnu.org, minwoo.im@samsung.com, clg@redhat.com,
chao.p.peng@intel.com
Subject: Re: [PATCH v2] vfio/pci: Fix a use-after-free issue
Date: Tue, 23 May 2023 11:52:10 -0600 [thread overview]
Message-ID: <20230523115210.6bc526f5.alex.williamson@redhat.com> (raw)
In-Reply-To: <20230523111747.747878e5.alex.williamson@redhat.com>
On Tue, 23 May 2023 11:17:47 -0600
Alex Williamson <alex.williamson@redhat.com> wrote:
> On Tue, 23 May 2023 13:00:53 -0400
> Matthew Rosato <mjrosato@linux.ibm.com> wrote:
>
> > On 5/16/23 10:46 PM, Zhenzhong Duan wrote:
> > > vbasedev->name is freed wrongly which leads to garbage VFIO trace log.
> > > Fix it by allocating a dup of vbasedev->name and then free the dup.
> > >
> > > Fixes: 2dca1b37a7 ("vfio/pci: add support for VF token")
> > > Suggested-by: Alex Williamson <alex.williamson@redhat.com>
> > > Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> >
> > Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
> >
> > Also verified that this resolves an issue seen on s390, as we were
> > seeing not just garbage logs but QEMU crashes in certain cases e.g.
> > during device unplug. Thanks!
>
> Thanks for the testing and reminder, I'll get a pull request out for
> this. Thanks,
Actually Cedric volunteered to bundle this with some pending patches,
so...
Acked-by: Alex Williamson <alex.williamson@redhat.com>
> > > ---
> > > v2: "toke" -> "token", Cedric
> > > Update with Alex suggested change
> > >
> > > hw/vfio/pci.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> > > index bf27a3990564..73874a94de12 100644
> > > --- a/hw/vfio/pci.c
> > > +++ b/hw/vfio/pci.c
> > > @@ -2994,7 +2994,7 @@ static void vfio_realize(PCIDevice *pdev,
> > > Error **errp) qemu_uuid_unparse(&vdev->vf_token, uuid);
> > > name = g_strdup_printf("%s vf_token=%s", vbasedev->name,
> > > uuid); } else {
> > > - name = vbasedev->name;
> > > + name = g_strdup(vbasedev->name);
> > > }
> > >
> > > ret = vfio_get_device(group, name, vbasedev, errp);
> >
>
next prev parent reply other threads:[~2023-05-23 17:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 2:46 [PATCH v2] vfio/pci: Fix a use-after-free issue Zhenzhong Duan
2023-05-17 6:11 ` Cédric Le Goater
2023-05-23 17:00 ` Matthew Rosato
2023-05-23 17:17 ` Alex Williamson
2023-05-23 17:52 ` Alex Williamson [this message]
2023-05-24 6:08 ` Philippe Mathieu-Daudé
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=20230523115210.6bc526f5.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=chao.p.peng@intel.com \
--cc=clg@redhat.com \
--cc=minwoo.im@samsung.com \
--cc=mjrosato@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=zhenzhong.duan@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 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).