• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンa021a2dd8b790437d27db95774969349632f856a (tree)
日時2022-01-28 00:14:21
作者Ross Lagerwall <ross.lagerwall@citr...>
コミッターAnthony PERARD

ログメッセージ

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>

変更サマリ

差分

--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -52,7 +52,7 @@ typedef struct MapCacheEntry {
5252 hwaddr paddr_index;
5353 uint8_t *vaddr_base;
5454 unsigned long *valid_mapping;
55- uint8_t lock;
55+ uint32_t lock;
5656 #define XEN_MAPCACHE_ENTRY_DUMMY (1 << 0)
5757 uint8_t flags;
5858 hwaddr size;
@@ -355,6 +355,12 @@ tryagain:
355355 if (lock) {
356356 MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev));
357357 entry->lock++;
358+ if (entry->lock == 0) {
359+ fprintf(stderr,
360+ "mapcache entry lock overflow: "TARGET_FMT_plx" -> %p\n",
361+ entry->paddr_index, entry->vaddr_base);
362+ abort();
363+ }
358364 reventry->dma = dma;
359365 reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset;
360366 reventry->paddr_index = mapcache->last_entry->paddr_index;