]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.18.132/vhost-make-sure-used-idx-is-seen-before-log-in-vhost_add_used_n.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.132 / vhost-make-sure-used-idx-is-seen-before-log-in-vhost_add_used_n.patch
CommitLineData
c923e3ad
GKH
1From foo@baz Sat Jan 5 08:35:42 CET 2019
2From: Jason Wang <jasowang@redhat.com>
3Date: Thu, 13 Dec 2018 10:53:37 +0800
4Subject: vhost: make sure used idx is seen before log in vhost_add_used_n()
5
6From: Jason Wang <jasowang@redhat.com>
7
8[ Upstream commit 841df922417eb82c835e93d4b93eb6a68c99d599 ]
9
10We miss a write barrier that guarantees used idx is updated and seen
11before log. This will let userspace sync and copy used ring before
12used idx is update. Fix this by adding a barrier before log_write().
13
14Fixes: 8dd014adfea6f ("vhost-net: mergeable buffers support")
15Acked-by: Michael S. Tsirkin <mst@redhat.com>
16Signed-off-by: Jason Wang <jasowang@redhat.com>
17Signed-off-by: David S. Miller <davem@davemloft.net>
18Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19---
20 drivers/vhost/vhost.c | 2 ++
21 1 file changed, 2 insertions(+)
22
23--- a/drivers/vhost/vhost.c
24+++ b/drivers/vhost/vhost.c
25@@ -1409,6 +1409,8 @@ int vhost_add_used_n(struct vhost_virtqu
26 return -EFAULT;
27 }
28 if (unlikely(vq->log_used)) {
29+ /* Make sure used idx is seen before log. */
30+ smp_wmb();
31 /* Log used index update. */
32 log_write(vq->log_base,
33 vq->log_addr + offsetof(struct vring_used, idx),