Skip to content

Commit

Permalink
vhost: fix split ring potential buffer overflow
Browse files Browse the repository at this point in the history
[ upstream commit 134228c ]

In vhost datapath, descriptor's length are mostly used in two coherent
operations. First step is used for address translation, second step is
used for memory transaction from guest to host. But the interval between
two steps will give a window for malicious guest, in which can change
descriptor length after vhost calculated buffer size. Thus may lead to
buffer overflow in vhost side. This potential risk can be eliminated by
accessing the descriptor length once.

Fixes: 1be4ebb ("vhost: support indirect descriptor in mergeable Rx")

Signed-off-by: Marvin Liu <yong.liu@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
MarvinLiu123 authored and steevenlee committed May 8, 2021
1 parent 1716e66 commit 25d53e1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/librte_vhost/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,11 @@ fill_vec_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
return -1;
}

len += descs[idx].len;
dlen = descs[idx].len;
len += dlen;

if (unlikely(map_one_desc(dev, vq, buf_vec, &vec_id,
descs[idx].addr, descs[idx].len,
descs[idx].addr, dlen,
perm))) {
free_ind_table(idesc);
return -1;
Expand Down

0 comments on commit 25d53e1

Please sign in to comment.