Skip to content

Commit

Permalink
vhost: fix invalid call FD handling
Browse files Browse the repository at this point in the history
[ upstream commit 0445f81883a3aa727ac7f8531beee2c225d3001a ]

This patch fixes cases where IRQ injection is tried while
the call FD is not valid, which should not happen.

Fixes: b1cce26 ("vhost: add notification for packed ring")
Fixes: e37ff95 ("vhost: support virtqueue interrupt/notification suppression")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  • Loading branch information
mcoquelin authored and kevintraynor committed Jul 11, 2023
1 parent f329acb commit 11a426e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/vhost/vhost.h
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,9 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
vhost_used_event(vq),
old, new);

if ((vhost_need_event(vhost_used_event(vq), new, old) &&
(vq->callfd >= 0)) ||
unlikely(!signalled_used_valid)) {
if ((vhost_need_event(vhost_used_event(vq), new, old) ||
unlikely(!signalled_used_valid)) &&
vq->callfd >= 0) {
eventfd_write(vq->callfd, (eventfd_t) 1);
if (dev->notify_ops->guest_notified)
dev->notify_ops->guest_notified(dev->vid);
Expand Down Expand Up @@ -851,7 +851,7 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)
if (vhost_need_event(off, new, old))
kick = true;
kick:
if (kick) {
if (kick && vq->callfd >= 0) {
eventfd_write(vq->callfd, (eventfd_t)1);
if (dev->notify_ops->guest_notified)
dev->notify_ops->guest_notified(dev->vid);
Expand Down

0 comments on commit 11a426e

Please sign in to comment.