OSDN Git Service

xen-mapcache: Avoid entry->lock overflow
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Mon, 24 Jan 2022 10:44:50 +0000 (10:44 +0000)
committerAnthony PERARD <anthony.perard@citrix.com>
Thu, 27 Jan 2022 15:14:21 +0000 (15:14 +0000)
commita021a2dd8b790437d27db95774969349632f856a
tree31e8add60de793b97c0cf74f7dedfacc0088d78b
parent9288e803e61e8d56d1c6c6aa8beb58596fb84ed9
xen-mapcache: Avoid entry->lock overflow

In some cases, a particular mapcache entry may be mapped 256 times
causing the lock field to wrap to 0. For example, this may happen when
using emulated NVME and the guest submits a large scatter-gather write.
At this point, the entry map be remapped causing QEMU to write the wrong
data or crash (since remap is not atomic).

Avoid this overflow by increasing the lock field to a uint32_t and also
detect it and abort rather than continuing regardless.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Message-Id: <20220124104450.152481-1-ross.lagerwall@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
hw/i386/xen/xen-mapcache.c