Skip to content

Commit 0e39829

Browse files
YongjiXiemstsirkin
authored andcommitted
vhost-vdpa: Fix integer overflow in vhost_vdpa_process_iotlb_update()
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 <[email protected]> Signed-off-by: Xie Yongji <[email protected]> Acked-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 43bb40c commit 0e39829

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/vhost/vdpa.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,8 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
614614
long pinned;
615615
int ret = 0;
616616

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

0 commit comments

Comments
 (0)