Skip to content

Commit

Permalink
vhost: fix check on virtqueue access in in-flight getter
Browse files Browse the repository at this point in the history
[ upstream commit 288cd1f8ca3ebaf20aeed92966da9020a5793852 ]

Acquiring the access lock is not enough to ensure
virtqueue's metadata such as vring pointers are valid.

The access status must also be checked.

Fixes: 0c0935c ("vhost: allow to check in-flight packets for async vhost")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: David Marchand <david.marchand@redhat.com>
  • Loading branch information
mcoquelin authored and kevintraynor committed Nov 15, 2023
1 parent 201e1f6 commit 587aea0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/vhost/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1929,9 +1929,15 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
return ret;
}

if (unlikely(!vq->access_ok)) {
ret = -1;
goto out_unlock;
}

if (vq->async)
ret = vq->async->pkts_inflight_n;

out_unlock:
rte_spinlock_unlock(&vq->access_lock);

return ret;
Expand Down

0 comments on commit 587aea0

Please sign in to comment.