Skip to content

Commit

Permalink
vhost-vdpa: Fix integer overflow in vhost_vdpa_process_iotlb_update()
Browse files Browse the repository at this point in the history
[ Upstream commit 0e39829 ]

The "msg->iova + msg->size" addition can have an integer overflow
if the iotlb message is from a malicious user space application.
So let's fix it.

Fixes: 1b48dc0 ("vhost: vdpa: report iova range")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20210728130756.97-1-xieyongji@bytedance.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
YongjiXie authored and Sasha Levin committed Aug 26, 2021
1 parent 6caaf9f commit 8a821b8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/vhost/vdpa.c
Expand Up @@ -614,7 +614,8 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
long pinned;
int ret = 0;

if (msg->iova < v->range.first ||
if (msg->iova < v->range.first || !msg->size ||
msg->iova > U64_MAX - msg->size + 1 ||
msg->iova + msg->size - 1 > v->range.last)
return -EINVAL;

Expand Down

0 comments on commit 8a821b8

Please sign in to comment.