History

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()

Linus Torvalds committed 10 years ago

Commit 6da7e952 parents 3b3ce01 3b2fbb38 files · +40 −24Browse files

Unified · Split

8 files
  1. arch/s390/Kconfig +13 −0
  2. drivers/block/virtio_blk.c +8 −18
  3. drivers/s390/virtio/Makefile +5 −1
  4. drivers/s390/virtio/kvm_virtio.c +3 −1
  5. drivers/vhost/vsock.c +5 −1
  6. drivers/virtio/virtio_ring.c +3 −0
  7. include/uapi/linux/virtio_vsock.h +1 −1
  8. net/9p/trans_virtio.c +2 −2
arch/s390/Kconfig+13−0
@@ -872,4 +872,17 @@ config S390_GUEST · 871 unmodified lines
872 Select this option if you want to run the kernel as a guest under872 Select this option if you want to run the kernel as a guest under
873 the KVM hypervisor.873 the KVM hypervisor.
874 874
875config 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
875endmenu888endmenu
drivers/block/virtio_blk.c+8−18
@@ -391,22 +391,16 @@ static int init_vq(struct virtio_blk *vblk) · 390 unmodified lines
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) · 4 unmodified lines
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) · 1 unmodified line
425 }419 }
426 vblk->num_vqs = num_vqs;420 vblk->num_vqs = num_vqs;
427 421
428 err_find_vqs:422out:
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
drivers/s390/virtio/Makefile+5−1
@@ -6,4 +6,8 @@ · 5 unmodified lines
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
9obj-$(CONFIG_S390_GUEST) += kvm_virtio.o virtio_ccw.o9s390-virtio-objs := virtio_ccw.o
10ifdef CONFIG_S390_GUEST_OLD_TRANSPORT
11s390-virtio-objs += kvm_virtio.o
12endif
13obj-$(CONFIG_S390_GUEST) += $(s390-virtio-objs)
drivers/s390/virtio/kvm_virtio.c+3−1
@@ -458,6 +458,8 @@ static int __init kvm_devices_init(void) · 457 unmodified lines
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) · 18 unmodified lines
482}484}
483 485
484/* code for early console output with virtio_console */486/* code for early console output with virtio_console */
485static __init int early_put_chars(u32 vtermno, const char *buf, int count)487static 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;
drivers/vhost/vsock.c+5−1
@@ -307,6 +307,8 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) · 306 unmodified lines
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 already313 /* Stop tx until the device processes already
312 * pending replies. Leave tx virtqueue314 * pending replies. Leave tx virtqueue
@@ -334,13 +336,15 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) · 21 unmodified lines
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 else344 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
drivers/virtio/virtio_ring.c+3−0
@@ -327,6 +327,8 @@ static inline int virtqueue_add(struct virtqueue *_vq, · 326 unmodified lines
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: · 93 unmodified lines
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
include/uapi/linux/virtio_vsock.h+1−1
@@ -32,7 +32,7 @@ · 31 unmodified lines
32 */32 */
33 33
34#ifndef _UAPI_LINUX_VIRTIO_VSOCK_H34#ifndef _UAPI_LINUX_VIRTIO_VSOCK_H
35#define _UAPI_LINUX_VIRTIO_VOSCK_H35#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>
net/9p/trans_virtio.c+2−2
@@ -507,8 +507,8 @@ err_out: · 506 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t