[PATCH] vhost: fix queue number check when setting inflight FD

Chenbo Xia chenbo.xia at intel.com
Wed Feb 16 02:53:13 CET 2022


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.

CVE-2021-3839
Fixes: ad0a4ae491fe ("vhost: checkout resubmit inflight information")
Cc: stable at dpdk.org

Reported-by: Wenxiang Qian <leonwxqian at gmail.com>
Signed-off-by: Chenbo Xia <chenbo.xia at intel.com>
---
 lib/vhost/vhost_user.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 1d3f89afd8..b20addd125 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -1718,6 +1718,12 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev,
 	num_queues = ctx->msg.payload.inflight.num_queues;
 	queue_size = ctx->msg.payload.inflight.queue_size;
 
+	if (num_queues > VHOST_MAX_VRING) {
+		VHOST_LOG_CONFIG(ERR, "(%s) invalid inflight queue num: %u\n",
+			dev->ifname, num_queues);
+		return RTE_VHOST_MSG_RESULT_ERR;
+	}
+
 	if (vq_is_packed(dev))
 		pervq_inflight_size = get_pervq_shm_size_packed(queue_size);
 	else
-- 
2.17.1



More information about the stable mailing list