]>
Commit | Line | Data |
---|---|---|
c923e3ad GKH |
1 | From foo@baz Sat Jan 5 08:35:42 CET 2019 |
2 | From: Jason Wang <jasowang@redhat.com> | |
3 | Date: Thu, 13 Dec 2018 10:53:37 +0800 | |
4 | Subject: vhost: make sure used idx is seen before log in vhost_add_used_n() | |
5 | ||
6 | From: Jason Wang <jasowang@redhat.com> | |
7 | ||
8 | [ Upstream commit 841df922417eb82c835e93d4b93eb6a68c99d599 ] | |
9 | ||
10 | We miss a write barrier that guarantees used idx is updated and seen | |
11 | before log. This will let userspace sync and copy used ring before | |
12 | used idx is update. Fix this by adding a barrier before log_write(). | |
13 | ||
14 | Fixes: 8dd014adfea6f ("vhost-net: mergeable buffers support") | |
15 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | |
16 | Signed-off-by: Jason Wang <jasowang@redhat.com> | |
17 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
18 | Signed-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), |