All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: jasowang@redhat.com, qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] vhost: ensure vhost_ops are set before calling iotlb callback
Date: Fri, 30 Jun 2017 12:33:33 -0400 (EDT)	[thread overview]
Message-ID: <374372131.45583910.1498840413273.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170630160422.14842-2-maxime.coquelin@redhat.com>



----- Original Message -----
> This patch fixes a crash that happens when vhost-user iommu
> support is enabled and vhost-user socket is closed.
> 
> When it happens, if an IOTLB invalidation notification is sent
> by the IOMMU, vhost_ops's NULL pointer is dereferenced.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

looks fine to me,

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  hw/virtio/vhost-backend.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
> index 4e31de1..cb055e8 100644
> --- a/hw/virtio/vhost-backend.c
> +++ b/hw/virtio/vhost-backend.c
> @@ -309,7 +309,10 @@ int vhost_backend_update_device_iotlb(struct vhost_dev
> *dev,
>          return -EINVAL;
>      }
>  
> -    return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
> +    if (dev->vhost_ops && dev->vhost_ops->vhost_send_device_iotlb_msg)
> +        return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
> +
> +    return -ENODEV;
>  }
>  
>  int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,
> @@ -321,7 +324,10 @@ int vhost_backend_invalidate_device_iotlb(struct
> vhost_dev *dev,
>      imsg.size = len;
>      imsg.type = VHOST_IOTLB_INVALIDATE;
>  
> -    return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
> +    if (dev->vhost_ops && dev->vhost_ops->vhost_send_device_iotlb_msg)
> +        return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
> +
> +    return -ENODEV;
>  }
>  
>  int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
> --
> 2.9.4
> 
> 

  reply	other threads:[~2017-06-30 16:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30 16:04 [Qemu-devel] [PATCH 0/2] vhost-user: fix crashes on disconnect when iommu is on Maxime Coquelin
2017-06-30 16:04 ` [Qemu-devel] [PATCH 1/2] vhost: ensure vhost_ops are set before calling iotlb callback Maxime Coquelin
2017-06-30 16:33   ` Marc-André Lureau [this message]
2017-06-30 16:04 ` [Qemu-devel] [PATCH 2/2] vhost-user: unregister slave req handler at cleanup time Maxime Coquelin
2017-06-30 16:23   ` Marc-André Lureau

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=374372131.45583910.1498840413273.JavaMail.zimbra@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@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 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.