Skip to content

Commit ad32b48

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "Last minute bugfixes. A couple of security things. And an error handling bugfix that is never encountered by most people, but that also makes it kind of safe to push at the last minute, and it helps push the fix to stable a bit sooner" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vhost: make sure log_num < in_num vhost: block speculation of translated descriptors virtio_ring: fix unmap of indirect descriptors
2 parents 6dcf6a4 + 060423b commit ad32b48

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

drivers/vhost/vhost.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,8 +2071,10 @@ static int translate_desc(struct vhost_virtqueue *vq, u64 addr, u32 len,
20712071
_iov = iov + ret;
20722072
size = node->size - addr + node->start;
20732073
_iov->iov_len = min((u64)len - s, size);
2074-
_iov->iov_base = (void __user *)(unsigned long)
2075-
(node->userspace_addr + addr - node->start);
2074+
_iov->iov_base = (void __user *)
2075+
((unsigned long)node->userspace_addr +
2076+
array_index_nospec((unsigned long)(addr - node->start),
2077+
node->size));
20762078
s += size;
20772079
addr += size;
20782080
++ret;
@@ -2178,7 +2180,7 @@ static int get_indirect(struct vhost_virtqueue *vq,
21782180
/* If this is an input descriptor, increment that count. */
21792181
if (access == VHOST_ACCESS_WO) {
21802182
*in_num += ret;
2181-
if (unlikely(log)) {
2183+
if (unlikely(log && ret)) {
21822184
log[*log_num].addr = vhost64_to_cpu(vq, desc.addr);
21832185
log[*log_num].len = vhost32_to_cpu(vq, desc.len);
21842186
++*log_num;
@@ -2319,7 +2321,7 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
23192321
/* If this is an input descriptor,
23202322
* increment that count. */
23212323
*in_num += ret;
2322-
if (unlikely(log)) {
2324+
if (unlikely(log && ret)) {
23232325
log[*log_num].addr = vhost64_to_cpu(vq, desc.addr);
23242326
log[*log_num].len = vhost32_to_cpu(vq, desc.len);
23252327
++*log_num;

drivers/virtio/virtio_ring.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,17 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
566566

567567
unmap_release:
568568
err_idx = i;
569-
i = head;
569+
570+
if (indirect)
571+
i = 0;
572+
else
573+
i = head;
570574

571575
for (n = 0; n < total_sg; n++) {
572576
if (i == err_idx)
573577
break;
574578
vring_unmap_one_split(vq, &desc[i]);
575-
i = virtio16_to_cpu(_vq->vdev, vq->split.vring.desc[i].next);
579+
i = virtio16_to_cpu(_vq->vdev, desc[i].next);
576580
}
577581

578582
if (indirect)

0 commit comments

Comments
 (0)