diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-11 17:10:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-11 17:10:23 -0400 |
commit | 6da7e95326976c0bee625f642e1c8ffa970efa07 (patch) | |
tree | a7e61e93661331fe3114328bd81a9113285436f2 | |
parent | 3b3ce01a57ad45d1ea4c63012d6f1e740d151d8d (diff) | |
parent | 3b2fbb3f06efe5bd2dfdce2a1db703e23c1a78af (diff) |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio/vhost fixes and cleanups from Michael Tsirkin:
"Misc fixes and cleanups all over the place"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
virtio/s390: deprecate old transport
virtio/s390: keep early_put_chars
virtio_blk: Fix a slient kernel panic
virtio-vsock: fix include guard typo
vhost/vsock: fix vhost virtio_vsock_pkt use-after-free
9p/trans_virtio: use kvfree() for iov_iter_get_pages_alloc()
virtio: fix error handling for debug builds
virtio: fix memory leak in virtqueue_add()
-rw-r--r-- | arch/s390/Kconfig | 13 | ||||
-rw-r--r-- | drivers/block/virtio_blk.c | 26 | ||||
-rw-r--r-- | drivers/s390/virtio/Makefile | 6 | ||||
-rw-r--r-- | drivers/s390/virtio/kvm_virtio.c | 4 | ||||
-rw-r--r-- | drivers/vhost/vsock.c | 6 | ||||
-rw-r--r-- | drivers/virtio/virtio_ring.c | 3 | ||||
-rw-r--r-- | include/uapi/linux/virtio_vsock.h | 2 | ||||
-rw-r--r-- | net/9p/trans_virtio.c | 4 |
8 files changed, 40 insertions, 24 deletions
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 0e348781327b..e751fe25d6ab 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig | |||
@@ -872,4 +872,17 @@ config S390_GUEST | |||
872 | Select this option if you want to run the kernel as a guest under | 872 | Select this option if you want to run the kernel as a guest under |
873 | the KVM hypervisor. | 873 | the KVM hypervisor. |
874 | 874 | ||
875 | config S390_GUEST_OLD_TRANSPORT | ||
876 | def_bool y | ||
877 | prompt "Guest support for old s390 virtio transport (DEPRECATED)" | ||
878 | depends on S390_GUEST | ||
879 | help | ||
880 | Enable this option to add support for the old s390-virtio | ||
881 | transport (i.e. virtio devices NOT based on virtio-ccw). This | ||
882 | type of virtio devices is only available on the experimental | ||
883 | kuli userspace or with old (< 2.6) qemu. If you are running | ||
884 | with a modern version of qemu (which supports virtio-ccw since | ||
885 | 1.4 and uses it by default since version 2.4), you probably won't | ||
886 | need this. | ||
887 | |||
875 | endmenu | 888 | endmenu |
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 1523e05c46fc..93b1aaa5ba3b 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -391,22 +391,16 @@ static int init_vq(struct virtio_blk *vblk) | |||
391 | num_vqs = 1; | 391 | num_vqs = 1; |
392 | 392 | ||
393 | vblk->vqs = kmalloc(sizeof(*vblk->vqs) * num_vqs, GFP_KERNEL); | 393 | vblk->vqs = kmalloc(sizeof(*vblk->vqs) * num_vqs, GFP_KERNEL); |
394 | if (!vblk->vqs) { | 394 | if (!vblk->vqs) |
395 | err = -ENOMEM; | 395 | return -ENOMEM; |
396 | goto out; | ||
397 | } | ||
398 | 396 | ||
399 | names = kmalloc(sizeof(*names) * num_vqs, GFP_KERNEL); | 397 | names = kmalloc(sizeof(*names) * num_vqs, GFP_KERNEL); |
400 | if (!names) | ||
401 | goto err_names; | ||
402 | |||
403 | callbacks = kmalloc(sizeof(*callbacks) * num_vqs, GFP_KERNEL); | 398 | callbacks = kmalloc(sizeof(*callbacks) * num_vqs, GFP_KERNEL); |
404 | if (!callbacks) | ||
405 | goto err_callbacks; | ||
406 | |||
407 | vqs = kmalloc(sizeof(*vqs) * num_vqs, GFP_KERNEL); | 399 | vqs = kmalloc(sizeof(*vqs) * num_vqs, GFP_KERNEL); |
408 | if (!vqs) | 400 | if (!names || !callbacks || !vqs) { |
409 | goto err_vqs; | 401 | err = -ENOMEM; |
402 | goto out; | ||
403 | } | ||
410 | 404 | ||
411 | for (i = 0; i < num_vqs; i++) { | 405 | for (i = 0; i < num_vqs; i++) { |
412 | callbacks[i] = virtblk_done; | 406 | callbacks[i] = virtblk_done; |
@@ -417,7 +411,7 @@ static int init_vq(struct virtio_blk *vblk) | |||
417 | /* Discover virtqueues and write information to configuration. */ | 411 | /* Discover virtqueues and write information to configuration. */ |
418 | err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names); | 412 | err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names); |
419 | if (err) | 413 | if (err) |
420 | goto err_find_vqs; | 414 | goto out; |
421 | 415 | ||
422 | for (i = 0; i < num_vqs; i++) { | 416 | for (i = 0; i < num_vqs; i++) { |
423 | spin_lock_init(&vblk->vqs[i].lock); | 417 | spin_lock_init(&vblk->vqs[i].lock); |
@@ -425,16 +419,12 @@ static int init_vq(struct virtio_blk *vblk) | |||
425 | } | 419 | } |
426 | vblk->num_vqs = num_vqs; | 420 | vblk->num_vqs = num_vqs; |
427 | 421 | ||
428 | err_find_vqs: | 422 | out: |
429 | kfree(vqs); | 423 | kfree(vqs); |
430 | err_vqs: | ||
431 | kfree(callbacks); | 424 | kfree(callbacks); |
432 | err_callbacks: | ||
433 | kfree(names); | 425 | kfree(names); |
434 | err_names: | ||
435 | if (err) | 426 | if (err) |
436 | kfree(vblk->vqs); | 427 | kfree(vblk->vqs); |
437 | out: | ||
438 | return err; | 428 | return err; |
439 | } | 429 | } |
440 | 430 | ||
diff --git a/drivers/s390/virtio/Makefile b/drivers/s390/virtio/Makefile index 241891a57caf..df40692a9011 100644 --- a/drivers/s390/virtio/Makefile +++ b/drivers/s390/virtio/Makefile | |||
@@ -6,4 +6,8 @@ | |||
6 | # it under the terms of the GNU General Public License (version 2 only) | 6 | # it under the terms of the GNU General Public License (version 2 only) |
7 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
8 | 8 | ||
9 | obj-$(CONFIG_S390_GUEST) += kvm_virtio.o virtio_ccw.o | 9 | s390-virtio-objs := virtio_ccw.o |
10 | ifdef CONFIG_S390_GUEST_OLD_TRANSPORT | ||
11 | s390-virtio-objs += kvm_virtio.o | ||
12 | endif | ||
13 | obj-$(CONFIG_S390_GUEST) += $(s390-virtio-objs) | ||
diff --git a/drivers/s390/virtio/kvm_virtio.c b/drivers/s390/virtio/kvm_virtio.c index 1d060fd293a3..5e5c11f37b24 100644 --- a/drivers/s390/virtio/kvm_virtio.c +++ b/drivers/s390/virtio/kvm_virtio.c | |||
@@ -458,6 +458,8 @@ static int __init kvm_devices_init(void) | |||
458 | if (test_devices_support(total_memory_size) < 0) | 458 | if (test_devices_support(total_memory_size) < 0) |
459 | return -ENODEV; | 459 | return -ENODEV; |
460 | 460 | ||
461 | pr_warn("The s390-virtio transport is deprecated. Please switch to a modern host providing virtio-ccw.\n"); | ||
462 | |||
461 | rc = vmem_add_mapping(total_memory_size, PAGE_SIZE); | 463 | rc = vmem_add_mapping(total_memory_size, PAGE_SIZE); |
462 | if (rc) | 464 | if (rc) |
463 | return rc; | 465 | return rc; |
@@ -482,7 +484,7 @@ static int __init kvm_devices_init(void) | |||
482 | } | 484 | } |
483 | 485 | ||
484 | /* code for early console output with virtio_console */ | 486 | /* code for early console output with virtio_console */ |
485 | static __init int early_put_chars(u32 vtermno, const char *buf, int count) | 487 | static int early_put_chars(u32 vtermno, const char *buf, int count) |
486 | { | 488 | { |
487 | char scratch[17]; | 489 | char scratch[17]; |
488 | unsigned int len = count; | 490 | unsigned int len = count; |
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 0ddf3a2dbfc4..e3b30ea9ece5 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c | |||
@@ -307,6 +307,8 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) | |||
307 | 307 | ||
308 | vhost_disable_notify(&vsock->dev, vq); | 308 | vhost_disable_notify(&vsock->dev, vq); |
309 | for (;;) { | 309 | for (;;) { |
310 | u32 len; | ||
311 | |||
310 | if (!vhost_vsock_more_replies(vsock)) { | 312 | if (!vhost_vsock_more_replies(vsock)) { |
311 | /* Stop tx until the device processes already | 313 | /* Stop tx until the device processes already |
312 | * pending replies. Leave tx virtqueue | 314 | * pending replies. Leave tx virtqueue |
@@ -334,13 +336,15 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) | |||
334 | continue; | 336 | continue; |
335 | } | 337 | } |
336 | 338 | ||
339 | len = pkt->len; | ||
340 | |||
337 | /* Only accept correctly addressed packets */ | 341 | /* Only accept correctly addressed packets */ |
338 | if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid) | 342 | if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid) |
339 | virtio_transport_recv_pkt(pkt); | 343 | virtio_transport_recv_pkt(pkt); |
340 | else | 344 | else |
341 | virtio_transport_free_pkt(pkt); | 345 | virtio_transport_free_pkt(pkt); |
342 | 346 | ||
343 | vhost_add_used(vq, head, sizeof(pkt->hdr) + pkt->len); | 347 | vhost_add_used(vq, head, sizeof(pkt->hdr) + len); |
344 | added = true; | 348 | added = true; |
345 | } | 349 | } |
346 | 350 | ||
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 114a0c88afb8..e383ecdaca59 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -327,6 +327,8 @@ static inline int virtqueue_add(struct virtqueue *_vq, | |||
327 | * host should service the ring ASAP. */ | 327 | * host should service the ring ASAP. */ |
328 | if (out_sgs) | 328 | if (out_sgs) |
329 | vq->notify(&vq->vq); | 329 | vq->notify(&vq->vq); |
330 | if (indirect) | ||
331 | kfree(desc); | ||
330 | END_USE(vq); | 332 | END_USE(vq); |
331 | return -ENOSPC; | 333 | return -ENOSPC; |
332 | } | 334 | } |
@@ -426,6 +428,7 @@ unmap_release: | |||
426 | if (indirect) | 428 | if (indirect) |
427 | kfree(desc); | 429 | kfree(desc); |
428 | 430 | ||
431 | END_USE(vq); | ||
429 | return -EIO; | 432 | return -EIO; |
430 | } | 433 | } |
431 | 434 | ||
diff --git a/include/uapi/linux/virtio_vsock.h b/include/uapi/linux/virtio_vsock.h index 6b011c19b50f..1d57ed3d84d2 100644 --- a/include/uapi/linux/virtio_vsock.h +++ b/include/uapi/linux/virtio_vsock.h | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef _UAPI_LINUX_VIRTIO_VSOCK_H | 34 | #ifndef _UAPI_LINUX_VIRTIO_VSOCK_H |
35 | #define _UAPI_LINUX_VIRTIO_VOSCK_H | 35 | #define _UAPI_LINUX_VIRTIO_VSOCK_H |
36 | 36 | ||
37 | #include <linux/types.h> | 37 | #include <linux/types.h> |
38 | #include <linux/virtio_ids.h> | 38 | #include <linux/virtio_ids.h> |
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 4acb1d5417aa..f24b25c25106 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
@@ -507,8 +507,8 @@ err_out: | |||
507 | /* wakeup anybody waiting for slots to pin pages */ | 507 | /* wakeup anybody waiting for slots to pin pages */ |
508 | wake_up(&vp_wq); | 508 | wake_up(&vp_wq); |
509 | } | 509 | } |
510 | kfree(in_pages); | 510 | kvfree(in_pages); |
511 | kfree(out_pages); | 511 | kvfree(out_pages); |
512 | return err; | 512 | return err; |
513 | } | 513 | } |
514 | 514 | ||