Add vhost-net use-after-free fix (rhbz 976789 980643)
This commit is contained in:
parent
8fb285bdac
commit
333a655d54
@ -794,6 +794,9 @@ Patch25055: ath3k-dont-use-stack-memory-for-DMA.patch
|
||||
Patch25056: iwl3945-better-skb-management-in-rx-path.patch
|
||||
Patch25057: iwl4965-better-skb-management-in-rx-path.patch
|
||||
|
||||
#rhbz 976789 980643
|
||||
Patch25062: vhost-net-fix-use-after-free-in-vhost_net_flush.patch
|
||||
|
||||
# END OF PATCH DEFINITIONS
|
||||
|
||||
%endif
|
||||
@ -1512,6 +1515,9 @@ ApplyPatch ath3k-dont-use-stack-memory-for-DMA.patch
|
||||
ApplyPatch iwl3945-better-skb-management-in-rx-path.patch
|
||||
ApplyPatch iwl4965-better-skb-management-in-rx-path.patch
|
||||
|
||||
#rhbz 976789 980643
|
||||
ApplyPatch vhost-net-fix-use-after-free-in-vhost_net_flush.patch
|
||||
|
||||
# END OF PATCH APPLICATIONS
|
||||
|
||||
%endif
|
||||
@ -2309,6 +2315,7 @@ fi
|
||||
# || ||
|
||||
%changelog
|
||||
* Fri Jul 05 2013 Josh Boyer <jwboyer@redhat.com>
|
||||
- Add vhost-net use-after-free fix (rhbz 976789 980643)
|
||||
- Add fix for timer issue in bridge code (rhbz 980254)
|
||||
|
||||
* Wed Jul 03 2013 Josh Boyer <jwboyer@redhat.com>
|
||||
|
76
vhost-net-fix-use-after-free-in-vhost_net_flush.patch
Normal file
76
vhost-net-fix-use-after-free-in-vhost_net_flush.patch
Normal file
@ -0,0 +1,76 @@
|
||||
Date: Tue, 25 Jun 2013 17:29:46 +0300
|
||||
From: "Michael S. Tsirkin" <mst@redhat.com>
|
||||
To: linux-kernel@vger.kernel.org
|
||||
Cc: "David S. Miller" <davem@davemloft.net>,
|
||||
Asias He <asias@redhat.com>, Jason Wang <jasowang@redhat.com>,
|
||||
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
|
||||
netdev@vger.kernel.org
|
||||
Subject: [PATCHv2] vhost-net: fix use-after-free in vhost_net_flush
|
||||
Message-ID: <20130625142946.GA17414@redhat.com>
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=us-ascii
|
||||
Content-Disposition: inline
|
||||
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11
|
||||
Sender: linux-kernel-owner@vger.kernel.org
|
||||
Precedence: bulk
|
||||
List-ID: <linux-kernel.vger.kernel.org>
|
||||
X-Mailing-List: linux-kernel@vger.kernel.org
|
||||
|
||||
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 <asias@redhat.com>
|
||||
Acked-by: Jason Wang <jasowang@redhat.com>
|
||||
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||||
|
||||
---
|
||||
|
||||
Please review, and queue for 3.10 and stable.
|
||||
Changes since v1:
|
||||
- no functional change, tweaked the commit message
|
||||
|
||||
drivers/vhost/net.c | 9 +++++++--
|
||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
|
||||
index 5c77d6a..534adb0 100644
|
||||
--- a/drivers/vhost/net.c
|
||||
+++ b/drivers/vhost/net.c
|
||||
@@ -149,6 +149,11 @@ static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs)
|
||||
{
|
||||
kref_put(&ubufs->kref, vhost_net_zerocopy_done_signal);
|
||||
wait_event(ubufs->wait, !atomic_read(&ubufs->kref.refcount));
|
||||
+}
|
||||
+
|
||||
+static void vhost_net_ubuf_put_wait_and_free(struct vhost_net_ubuf_ref *ubufs)
|
||||
+{
|
||||
+ vhost_net_ubuf_put_and_wait(ubufs);
|
||||
kfree(ubufs);
|
||||
}
|
||||
|
||||
@@ -1073,7 +1078,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
|
||||
mutex_unlock(&vq->mutex);
|
||||
|
||||
if (oldubufs) {
|
||||
- vhost_net_ubuf_put_and_wait(oldubufs);
|
||||
+ vhost_net_ubuf_put_wait_and_free(oldubufs);
|
||||
mutex_lock(&vq->mutex);
|
||||
vhost_zerocopy_signal_used(n, vq);
|
||||
mutex_unlock(&vq->mutex);
|
||||
@@ -1091,7 +1096,7 @@ err_used:
|
||||
vq->private_data = oldsock;
|
||||
vhost_net_enable_vq(n, vq);
|
||||
if (ubufs)
|
||||
- vhost_net_ubuf_put_and_wait(ubufs);
|
||||
+ vhost_net_ubuf_put_wait_and_free(ubufs);
|
||||
err_ubufs:
|
||||
fput(sock->file);
|
||||
err_vq:
|
||||
|
Loading…
Reference in New Issue
Block a user