Skip to content

Commit

Permalink
vduse: Disallow injecting interrupt before DRIVER_OK is set
Browse files Browse the repository at this point in the history
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: c8a6153 ("vduse: Introduce VDUSE - vDPA Device in Userspace")
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Link: https://lore.kernel.org/r/20210923075722.98-1-xieyongji@bytedance.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Xie Yongji authored and Michael S. Tsirkin committed Oct 22, 2021
1 parent 6422251 commit 1394103
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/vdpa/vdpa_user/vduse_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,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;

ret = 0;
queue_work(vduse_irq_wq, &dev->inject);
break;
Expand Down Expand Up @@ -1045,6 +1049,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;
Expand Down

0 comments on commit 1394103

Please sign in to comment.