Skip to content

Commit 5472f14

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: "Misc virtio and vdpa bugfixes" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vdpa: Consider device id larger than 31 virtio/vsock: fix the transport to work with VMADDR_CID_ANY virtio_ring: Fix querying of maximum DMA mapping size for virtio device virtio: always enter drivers/virtio/ vduse: check that offset is within bounds in get_config() vdpa: check that offsets are within bounds vduse: fix memory corruption in vduse_dev_ioctl()
2 parents aa50faf + bb47620 commit 5472f14

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

drivers/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ obj-$(CONFIG_DMADEVICES) += dma/
4141
# SOC specific infrastructure drivers.
4242
obj-y += soc/
4343

44-
obj-$(CONFIG_VIRTIO) += virtio/
45-
obj-$(CONFIG_VIRTIO_PCI_LIB) += virtio/
44+
obj-y += virtio/
4645
obj-$(CONFIG_VDPA) += vdpa/
4746
obj-$(CONFIG_XEN) += xen/
4847

drivers/vdpa/vdpa.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m
404404
goto msg_err;
405405

406406
while (mdev->id_table[i].device) {
407-
supported_classes |= BIT(mdev->id_table[i].device);
407+
if (mdev->id_table[i].device <= 63)
408+
supported_classes |= BIT_ULL(mdev->id_table[i].device);
408409
i++;
409410
}
410411

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,8 @@ static void vduse_vdpa_get_config(struct vdpa_device *vdpa, unsigned int offset,
655655
{
656656
struct vduse_dev *dev = vdpa_to_vduse(vdpa);
657657

658-
if (len > dev->config_size - offset)
658+
if (offset > dev->config_size ||
659+
len > dev->config_size - offset)
659660
return;
660661

661662
memcpy(buf, dev->config + offset, len);
@@ -975,7 +976,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
975976
break;
976977

977978
ret = -EINVAL;
978-
if (config.length == 0 ||
979+
if (config.offset > dev->config_size ||
980+
config.length == 0 ||
979981
config.length > dev->config_size - config.offset)
980982
break;
981983

drivers/vhost/vdpa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static int vhost_vdpa_config_validate(struct vhost_vdpa *v,
197197
struct vdpa_device *vdpa = v->vdpa;
198198
long size = vdpa->config->get_config_size(vdpa);
199199

200-
if (c->len == 0)
200+
if (c->len == 0 || c->off > size)
201201
return -EINVAL;
202202

203203
if (c->len > size - c->off)

drivers/virtio/virtio_ring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ size_t virtio_max_dma_size(struct virtio_device *vdev)
268268
size_t max_segment_size = SIZE_MAX;
269269

270270
if (vring_use_dma_api(vdev))
271-
max_segment_size = dma_max_mapping_size(&vdev->dev);
271+
max_segment_size = dma_max_mapping_size(vdev->dev.parent);
272272

273273
return max_segment_size;
274274
}

net/vmw_vsock/virtio_transport_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,8 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
12991299
space_available = virtio_transport_space_update(sk, pkt);
13001300

13011301
/* Update CID in case it has changed after a transport reset event */
1302-
vsk->local_addr.svm_cid = dst.svm_cid;
1302+
if (vsk->local_addr.svm_cid != VMADDR_CID_ANY)
1303+
vsk->local_addr.svm_cid = dst.svm_cid;
13031304

13041305
if (space_available)
13051306
sk->sk_write_space(sk);

0 commit comments

Comments
 (0)