qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] vfio/pci: Fix a use-after-free issue


From: Matthew Rosato
Subject: Re: [PATCH v2] vfio/pci: Fix a use-after-free issue
Date: Tue, 23 May 2023 13:00:53 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0

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!

> ---
> 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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]