All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Xie Yongji <xieyongji@bytedance.com>
Cc: virtualization <virtualization@lists.linux-foundation.org>,
	mst <mst@redhat.com>
Subject: Re: [PATCH] vduse: Disallow injecting interrupt before DRIVER_OK is set
Date: Sun, 26 Sep 2021 10:28:08 +0800	[thread overview]
Message-ID: <CACGkMEvgom2033EKH=sAFc+dC-njzVXwTdZRaU5U7Ezzg86nWQ@mail.gmail.com> (raw)
In-Reply-To: <20210923075722.98-1-xieyongji@bytedance.com>

On Thu, Sep 23, 2021 at 3:57 PM Xie Yongji <xieyongji@bytedance.com> wrote:
>
> The interrupt callback should not be triggered before DRIVER_OK
> is set. Otherwise, it might break the virtio device driver.
> So let's add a check to avoid the unexpected behavior.
>
> Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace")
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
> ---
>  drivers/vdpa/vdpa_user/vduse_dev.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
> index 29a38ecba19e..972c13a7e5da 100644
> --- a/drivers/vdpa/vdpa_user/vduse_dev.c
> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c
> @@ -968,6 +968,10 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
>                 break;
>         }
>         case VDUSE_DEV_INJECT_CONFIG_IRQ:
> +               ret = -EINVAL;
> +               if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
> +                       break;
> +

I wonder if we need any synchronization with set_status()?

Thanks

>                 ret = 0;
>                 queue_work(vduse_irq_wq, &dev->inject);
>                 break;
> @@ -1047,6 +1051,10 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
>         case VDUSE_VQ_INJECT_IRQ: {
>                 u32 index;
>
> +               ret = -EINVAL;
> +               if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
> +                       break;
> +
>                 ret = -EFAULT;
>                 if (get_user(index, (u32 __user *)argp))
>                         break;
> --
> 2.11.0
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

       reply	other threads:[~2021-09-26  2:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210923075722.98-1-xieyongji@bytedance.com>
2021-09-26  2:28 ` Jason Wang [this message]
2021-10-13 11:26 ` [PATCH] vduse: Disallow injecting interrupt before DRIVER_OK is set Michael S. Tsirkin

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='CACGkMEvgom2033EKH=sAFc+dC-njzVXwTdZRaU5U7Ezzg86nWQ@mail.gmail.com' \
    --to=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xieyongji@bytedance.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.