vhost: make sure used idx is seen before log in vhost_add_used_n()
authorJason Wang <jasowang@redhat.com>
Thu, 13 Dec 2018 02:53:37 +0000 (10:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jan 2019 16:14:45 +0000 (17:14 +0100)
commit2510d91bdafe6ebe95864290866bb6c3e714b6e8
tree39237129ba64774811a03e62372b8b661991e568
parent3009452fb260459deff51533f284dd0d004cbbac
vhost: make sure used idx is seen before log in vhost_add_used_n()

[ Upstream commit 841df922417eb82c835e93d4b93eb6a68c99d599 ]

We miss a write barrier that guarantees used idx is updated and seen
before log. This will let userspace sync and copy used ring before
used idx is update. Fix this by adding a barrier before log_write().

Fixes: 8dd014adfea6f ("vhost-net: mergeable buffers support")
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vhost/vhost.c