vhost: fix queue number check when setting inflight FD
authorChenbo Xia <chenbo.xia@intel.com>
Mon, 14 Feb 2022 08:32:37 +0000 (16:32 +0800)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 10 Mar 2022 13:03:43 +0000 (14:03 +0100)
commit6442c329b9d2ded0f44b27d2016aaba8ba5844c5
tree155a07da091cca1fa4fb4388988b7b843bc36da4
parent312b94ef884f0cf4ee42dde36acf23a41172794d
vhost: fix queue number check when setting inflight FD

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: ad0a4ae491fe ("vhost: checkout resubmit inflight information")
Cc: stable@dpdk.org
Reported-by: Wenxiang Qian <leonwxqian@gmail.com>
Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/vhost/vhost_user.c