1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/arch
David Hildenbrand 5f230f41fd KVM: s390: vsie: fix some corner-cases when grabbing vsie pages
We try to reuse the same vsie page when re-executing the vsie with a
given SCB address. The result is that we use the same shadow SCB --
residing in the vsie page -- and can avoid flushing the TLB when
re-running the vsie on a CPU.

So, when we allocate a fresh vsie page, or when we reuse a vsie page for
a different SCB address -- reusing the shadow SCB in different context --
we set ihcpu=0xffff to trigger the flush.

However, after we looked up the SCB address in the radix tree, but before
we grabbed the vsie page by raising the refcount to 2, someone could reuse
the vsie page for a different SCB address, adjusting page->index and the
radix tree. In that case, we would be reusing the vsie page with a
wrong page->index.

Another corner case is that we might set the SCB address for a vsie
page, but fail the insertion into the radix tree. Whoever would reuse
that page would remove the corresponding radix tree entry -- which might
now be a valid entry pointing at another page, resulting in the wrong
vsie page getting removed from the radix tree.

Let's handle such races better, by validating that the SCB address of a
vsie page didn't change after we grabbed it (not reuse for a different
SCB; the alternative would be performing another tree lookup), and by
setting the SCB address to invalid until the insertion in the tree
succeeded (SCB addresses are aligned to 512, so ULONG_MAX is invalid).

These scenarios are rare, the effects a bit unclear, and these issues were
only found by code inspection. Let's CC stable to be safe.

Fixes: a3508fbe9d ("KVM: s390: vsie: initial support for nested virtualization")
Cc: stable@vger.kernel.org
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Tested-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Message-ID: <20250107154344.1003072-2-david@redhat.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
2025-01-31 12:03:34 +01:00
..
alpha The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
arc The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
arm Summary: 2025-01-29 10:35:40 -08:00
arm64 Summary: 2025-01-29 10:35:40 -08:00
csky asm-generic: pgalloc: provide generic __pgd_{alloc,free} 2025-01-25 20:22:24 -08:00
hexagon The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
loongarch LoongArch changes for v6.14 2025-01-28 08:52:01 -08:00
m68k m68knommu: updates and fixes for v6.14 2025-01-27 08:30:06 -08:00
microblaze asm-generic: pgalloc: provide generic __pgd_{alloc,free} 2025-01-25 20:22:24 -08:00
mips Char/Misc/IIO driver updates for 6.14-rc1 2025-01-27 16:51:51 -08:00
nios2 asm-generic: pgalloc: provide generic __pgd_{alloc,free} 2025-01-25 20:22:24 -08:00
openrisc The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
parisc The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
powerpc powerpc fixes for 6.14 #2 2025-01-29 10:55:04 -08:00
riscv treewide: const qualify ctl_tables where applicable 2025-01-28 13:48:37 +01:00
s390 KVM: s390: vsie: fix some corner-cases when grabbing vsie pages 2025-01-31 12:03:34 +01:00
sh mm/memblock: add memblock_alloc_or_panic interface 2025-01-25 20:22:38 -08:00
sparc Driver core and debugfs updates 2025-01-28 12:25:12 -08:00
um The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
x86 xen: branch for v6.14-rc1 2025-01-29 11:39:20 -08:00
xtensa Xtensa updates for v6.14 2025-01-27 08:16:33 -08:00
.gitignore
Kconfig m68k: Use kernel's generic muldi3 libgcc function 2024-12-09 13:29:17 +01:00