]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
Drivers: hv: vmbus: Prevent load re-ordering when reading ring buffer
authorMichael Kelley <mikelley@microsoft.com>
Sun, 27 Mar 2022 15:25:10 +0000 (08:25 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:42:27 +0000 (14:42 +0200)
commit5beefa32b8d30f69fa591895b18926494bfd8d07
tree1ccd1b9f0292e66aa9c59731b24bb2e0990c0854
parent530f46e1bccedb20e7af59027a6c72e8f6ba361c
Drivers: hv: vmbus: Prevent load re-ordering when reading ring buffer

BugLink: https://bugs.launchpad.net/bugs/1969857
[ Upstream commit b6cae15b5710c8097aad26a2e5e752c323ee5348 ]

When reading a packet from a host-to-guest ring buffer, there is no
memory barrier between reading the write index (to see if there is
a packet to read) and reading the contents of the packet. The Hyper-V
host uses store-release when updating the write index to ensure that
writes of the packet data are completed first. On the guest side,
the processor can reorder and read the packet data before the write
index, and sometimes get stale packet data. Getting such stale packet
data has been observed in a reproducible case in a VM on ARM64.

Fix this by using virt_load_acquire() to read the write index,
ensuring that reads of the packet data cannot be reordered
before it. Preventing such reordering is logically correct, and
with this change, getting stale data can no longer be reproduced.

Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
Link: https://lore.kernel.org/r/1648394710-33480-1-git-send-email-mikelley@microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/hv/ring_buffer.c