From: Daniel Mrzyglod Date: Fri, 22 Sep 2017 15:21:49 +0000 (+0200) Subject: net/virtio: fix untrusted scalar value X-Git-Tag: spdx-start~1657 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7b3249c56e29bec5f710624335bd4246c2a356fb;p=dpdk.git net/virtio: fix untrusted scalar value The unscrutinized value may be incorrectly assumed to be within a certain range by later operations. In vhost_user_read: An unscrutinized value from an untrusted source used in a trusted context - the value of sz_payload may be harmfull and we need limit them to the max value of payload. Coverity issue: 139601 Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer") Cc: stable@dpdk.org Signed-off-by: Daniel Mrzyglod Acked-by: Jianfeng Tan Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index 4ad7b21b40..97bd83267c 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -130,6 +130,10 @@ vhost_user_read(int fd, struct vhost_user_msg *msg) } sz_payload = msg->size; + + if ((size_t)sz_payload > sizeof(msg->payload)) + goto fail; + if (sz_payload) { ret = recv(fd, (void *)((char *)msg + sz_hdr), sz_payload, 0); if (ret < sz_payload) {