diff --git a/kernel.spec b/kernel.spec index ada7ee6..79d2e9c 100644 --- a/kernel.spec +++ b/kernel.spec @@ -816,6 +816,9 @@ Patch25059: ceph-fix.patch #CVE-2013-2232 rhbz 981552 981564 Patch25060: ipv6-ip6_sk_dst_check-must-not-assume-ipv6-dst.patch +#rhbz 976789 980643 +Patch25062: vhost-net-fix-use-after-free-in-vhost_net_flush.patch + # END OF PATCH DEFINITIONS %endif @@ -1580,6 +1583,9 @@ ApplyPatch ceph-fix.patch #CVE-2013-2232 rhbz 981552 981564 ApplyPatch ipv6-ip6_sk_dst_check-must-not-assume-ipv6-dst.patch +#rhbz 976789 980643 +ApplyPatch vhost-net-fix-use-after-free-in-vhost_net_flush.patch + # END OF PATCH APPLICATIONS %endif @@ -2397,6 +2403,7 @@ fi %changelog * Fri Jul 05 2013 Josh Boyer +- Add vhost-net use-after-free fix (rhbz 976789 980643) - Add fix for timer issue in bridge code (rhbz 980254) - CVE-2013-2232 ipv6: using ipv4 vs ipv6 structure during routing lookup in sendmsg (rhbz 981552 981564) diff --git a/vhost-net-fix-use-after-free-in-vhost_net_flush.patch b/vhost-net-fix-use-after-free-in-vhost_net_flush.patch new file mode 100644 index 0000000..f9a6a7b --- /dev/null +++ b/vhost-net-fix-use-after-free-in-vhost_net_flush.patch @@ -0,0 +1,76 @@ +From 0c9d7f6ea817d5328a09a78e901b16e1836ca4d7 Mon Sep 17 00:00:00 2001 +From: "Michael S. Tsirkin" +Date: Tue, 25 Jun 2013 17:29:46 +0300 +Subject: [PATCH] vhost-net: fix use-after-free in vhost_net_flush + +vhost_net_ubuf_put_and_wait has a confusing name: +it will actually also free it's argument. +Thus since commit 1280c27f8e29acf4af2da914e80ec27c3dbd5c01 + "vhost-net: flush outstanding DMAs on memory change" +vhost_net_flush tries to use the argument after passing it +to vhost_net_ubuf_put_and_wait, this results +in use after free. +To fix, don't free the argument in vhost_net_ubuf_put_and_wait, +add an new API for callers that want to free ubufs. + +Acked-by: Asias He +Acked-by: Jason Wang +Signed-off-by: Michael S. Tsirkin +--- + drivers/vhost/net.c | 4 ++-- + drivers/vhost/vhost.c | 5 +++++ + drivers/vhost/vhost.h | 1 + + 3 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c +index dfff647..d8d4f57 100644 +--- a/drivers/vhost/net.c ++++ b/drivers/vhost/net.c +@@ -857,7 +857,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) + mutex_unlock(&vq->mutex); + + if (oldubufs) { +- vhost_ubuf_put_and_wait(oldubufs); ++ vhost_ubuf_put_wait_and_free(oldubufs); + mutex_lock(&vq->mutex); + vhost_zerocopy_signal_used(n, vq); + mutex_unlock(&vq->mutex); +@@ -875,7 +875,7 @@ err_used: + rcu_assign_pointer(vq->private_data, oldsock); + vhost_net_enable_vq(n, vq); + if (ubufs) +- vhost_ubuf_put_and_wait(ubufs); ++ vhost_ubuf_put_wait_and_free(ubufs); + err_ubufs: + fput(sock->file); + err_vq: +diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c +index 9759249..ff53c9e 100644 +--- a/drivers/vhost/vhost.c ++++ b/drivers/vhost/vhost.c +@@ -1581,5 +1581,10 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs) + { + kref_put(&ubufs->kref, vhost_zerocopy_done_signal); + wait_event(ubufs->wait, !atomic_read(&ubufs->kref.refcount)); ++} ++ ++void vhost_ubuf_put_wait_and_free(struct vhost_ubuf_ref *ubufs) ++{ ++ vhost_ubuf_put_and_wait(ubufs); + kfree(ubufs); + } +diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h +index 17261e2..dd63b35 100644 +--- a/drivers/vhost/vhost.h ++++ b/drivers/vhost/vhost.h +@@ -63,6 +63,7 @@ struct vhost_ubuf_ref { + struct vhost_ubuf_ref *vhost_ubuf_alloc(struct vhost_virtqueue *, bool zcopy); + void vhost_ubuf_put(struct vhost_ubuf_ref *); + void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *); ++void vhost_ubuf_put_wait_and_free(struct vhost_ubuf_ref *); + + struct ubuf_info; + +-- +1.8.2.1 +