Commit 6da7e953 authored by Linus Torvalds's avatar Linus Torvalds

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()
parents 3b3ce01a 3b2fbb3f
...@@ -872,4 +872,17 @@ config S390_GUEST ...@@ -872,4 +872,17 @@ config S390_GUEST
Select this option if you want to run the kernel as a guest under Select this option if you want to run the kernel as a guest under
the KVM hypervisor. the KVM hypervisor.
config S390_GUEST_OLD_TRANSPORT
def_bool y
prompt "Guest support for old s390 virtio transport (DEPRECATED)"
depends on S390_GUEST
help
Enable this option to add support for the old s390-virtio
transport (i.e. virtio devices NOT based on virtio-ccw). This
type of virtio devices is only available on the experimental
kuli userspace or with old (< 2.6) qemu. If you are running
with a modern version of qemu (which supports virtio-ccw since
1.4 and uses it by default since version 2.4), you probably won't
need this.
endmenu endmenu
...@@ -391,22 +391,16 @@ static int init_vq(struct virtio_blk *vblk) ...@@ -391,22 +391,16 @@ static int init_vq(struct virtio_blk *vblk)
num_vqs = 1; num_vqs = 1;
vblk->vqs = kmalloc(sizeof(*vblk->vqs) * num_vqs, GFP_KERNEL); vblk->vqs = kmalloc(sizeof(*vblk->vqs) * num_vqs, GFP_KERNEL);
if (!vblk->vqs) { if (!vblk->vqs)
err = -ENOMEM; return -ENOMEM;
goto out;
}
names = kmalloc(sizeof(*names) * num_vqs, GFP_KERNEL); names = kmalloc(sizeof(*names) * num_vqs, GFP_KERNEL);
if (!names)
goto err_names;
callbacks = kmalloc(sizeof(*callbacks) * num_vqs, GFP_KERNEL); callbacks = kmalloc(sizeof(*callbacks) * num_vqs, GFP_KERNEL);
if (!callbacks)
goto err_callbacks;
vqs = kmalloc(sizeof(*vqs) * num_vqs, GFP_KERNEL); vqs = kmalloc(sizeof(*vqs) * num_vqs, GFP_KERNEL);
if (!vqs) if (!names || !callbacks || !vqs) {
goto err_vqs; err = -ENOMEM;
goto out;
}
for (i = 0; i < num_vqs; i++) { for (i = 0; i < num_vqs; i++) {
callbacks[i] = virtblk_done; callbacks[i] = virtblk_done;
...@@ -417,7 +411,7 @@ static int init_vq(struct virtio_blk *vblk) ...@@ -417,7 +411,7 @@ static int init_vq(struct virtio_blk *vblk)
/* Discover virtqueues and write information to configuration. */ /* Discover virtqueues and write information to configuration. */
err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names); err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names);
if (err) if (err)
goto err_find_vqs; goto out;
for (i = 0; i < num_vqs; i++) { for (i = 0; i < num_vqs; i++) {
spin_lock_init(&vblk->vqs[i].lock); spin_lock_init(&vblk->vqs[i].lock);
...@@ -425,16 +419,12 @@ static int init_vq(struct virtio_blk *vblk) ...@@ -425,16 +419,12 @@ static int init_vq(struct virtio_blk *vblk)
} }
vblk->num_vqs = num_vqs; vblk->num_vqs = num_vqs;
err_find_vqs: out:
kfree(vqs); kfree(vqs);
err_vqs:
kfree(callbacks); kfree(callbacks);
err_callbacks:
kfree(names); kfree(names);
err_names:
if (err) if (err)
kfree(vblk->vqs); kfree(vblk->vqs);
out:
return err; return err;
} }
......
...@@ -6,4 +6,8 @@ ...@@ -6,4 +6,8 @@
# it under the terms of the GNU General Public License (version 2 only) # it under the terms of the GNU General Public License (version 2 only)
# as published by the Free Software Foundation. # as published by the Free Software Foundation.
obj-$(CONFIG_S390_GUEST) += kvm_virtio.o virtio_ccw.o s390-virtio-objs := virtio_ccw.o
ifdef CONFIG_S390_GUEST_OLD_TRANSPORT
s390-virtio-objs += kvm_virtio.o
endif
obj-$(CONFIG_S390_GUEST) += $(s390-virtio-objs)
...@@ -458,6 +458,8 @@ static int __init kvm_devices_init(void) ...@@ -458,6 +458,8 @@ static int __init kvm_devices_init(void)
if (test_devices_support(total_memory_size) < 0) if (test_devices_support(total_memory_size) < 0)
return -ENODEV; return -ENODEV;
pr_warn("The s390-virtio transport is deprecated. Please switch to a modern host providing virtio-ccw.\n");
rc = vmem_add_mapping(total_memory_size, PAGE_SIZE); rc = vmem_add_mapping(total_memory_size, PAGE_SIZE);
if (rc) if (rc)
return rc; return rc;
...@@ -482,7 +484,7 @@ static int __init kvm_devices_init(void) ...@@ -482,7 +484,7 @@ static int __init kvm_devices_init(void)
} }
/* code for early console output with virtio_console */ /* code for early console output with virtio_console */
static __init int early_put_chars(u32 vtermno, const char *buf, int count) static int early_put_chars(u32 vtermno, const char *buf, int count)
{ {
char scratch[17]; char scratch[17];
unsigned int len = count; unsigned int len = count;
......
...@@ -307,6 +307,8 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) ...@@ -307,6 +307,8 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
vhost_disable_notify(&vsock->dev, vq); vhost_disable_notify(&vsock->dev, vq);
for (;;) { for (;;) {
u32 len;
if (!vhost_vsock_more_replies(vsock)) { if (!vhost_vsock_more_replies(vsock)) {
/* Stop tx until the device processes already /* Stop tx until the device processes already
* pending replies. Leave tx virtqueue * pending replies. Leave tx virtqueue
...@@ -334,13 +336,15 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work) ...@@ -334,13 +336,15 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
continue; continue;
} }
len = pkt->len;
/* Only accept correctly addressed packets */ /* Only accept correctly addressed packets */
if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid) if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid)
virtio_transport_recv_pkt(pkt); virtio_transport_recv_pkt(pkt);
else else
virtio_transport_free_pkt(pkt); virtio_transport_free_pkt(pkt);
vhost_add_used(vq, head, sizeof(pkt->hdr) + pkt->len); vhost_add_used(vq, head, sizeof(pkt->hdr) + len);
added = true; added = true;
} }
......
...@@ -327,6 +327,8 @@ static inline int virtqueue_add(struct virtqueue *_vq, ...@@ -327,6 +327,8 @@ static inline int virtqueue_add(struct virtqueue *_vq,
* host should service the ring ASAP. */ * host should service the ring ASAP. */
if (out_sgs) if (out_sgs)
vq->notify(&vq->vq); vq->notify(&vq->vq);
if (indirect)
kfree(desc);
END_USE(vq); END_USE(vq);
return -ENOSPC; return -ENOSPC;
} }
...@@ -426,6 +428,7 @@ static inline int virtqueue_add(struct virtqueue *_vq, ...@@ -426,6 +428,7 @@ static inline int virtqueue_add(struct virtqueue *_vq,
if (indirect) if (indirect)
kfree(desc); kfree(desc);
END_USE(vq);
return -EIO; return -EIO;
} }
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
*/ */
#ifndef _UAPI_LINUX_VIRTIO_VSOCK_H #ifndef _UAPI_LINUX_VIRTIO_VSOCK_H
#define _UAPI_LINUX_VIRTIO_VOSCK_H #define _UAPI_LINUX_VIRTIO_VSOCK_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/virtio_ids.h> #include <linux/virtio_ids.h>
......
...@@ -507,8 +507,8 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req, ...@@ -507,8 +507,8 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
/* wakeup anybody waiting for slots to pin pages */ /* wakeup anybody waiting for slots to pin pages */
wake_up(&vp_wq); wake_up(&vp_wq);
} }
kfree(in_pages); kvfree(in_pages);
kfree(out_pages); kvfree(out_pages);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment