Skip to content

Commit

Permalink
vhost: fix queue number check when setting inflight FD
Browse files Browse the repository at this point in the history
[ upstream commit 6442c32 ]

In function vhost_user_set_inflight_fd, queue number in inflight
message is used to access virtqueue. However, queue number could
be larger than VHOST_MAX_VRING and cause write OOB as this number
will be used to write inflight info in virtqueue structure. This
patch checks the queue number to avoid the issue and also make
sure virtqueues are allocated before setting inflight information.

Fixes: ad0a4ae ("vhost: checkout resubmit inflight information")

Reported-by: Wenxiang Qian <leonwxqian@gmail.com>
Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
chenbo-xia authored and bluca committed Mar 15, 2022
1 parent cc761b3 commit 9bac6ad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/librte_vhost/vhost_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,9 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev,
case VHOST_USER_SET_VRING_ADDR:
vring_idx = msg->payload.addr.index;
break;
case VHOST_USER_SET_INFLIGHT_FD:
vring_idx = msg->payload.inflight.num_queues - 1;
break;
default:
return 0;
}
Expand Down

0 comments on commit 9bac6ad

Please sign in to comment.