kernel_samsung_a53x/arch
Sean Christopherson dc9c86ed6c KVM: SVM: Flush pages under kvm->lock to fix UAF in svm_register_enc_region()
commit 5ef1d8c1ddbf696e47b226e11888eaf8d9e8e807 upstream.

Do the cache flush of converted pages in svm_register_enc_region() before
dropping kvm->lock to fix use-after-free issues where region and/or its
array of pages could be freed by a different task, e.g. if userspace has
__unregister_enc_region_locked() already queued up for the region.

Note, the "obvious" alternative of using local variables doesn't fully
resolve the bug, as region->pages is also dynamically allocated.  I.e. the
region structure itself would be fine, but region->pages could be freed.

Flushing multiple pages under kvm->lock is unfortunate, but the entire
flow is a rare slow path, and the manual flush is only needed on CPUs that
lack coherency for encrypted memory.

Fixes: 19a23da53932 ("Fix unsynchronized access to sev members through svm_register_enc_region")
Reported-by: Gabe Kirkpatrick <gkirkpatrick@google.com>
Cc: Josh Eads <josheads@google.com>
Cc: Peter Gonda <pgonda@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20240217013430.2079561-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-19 09:22:38 +01:00
..
alpha Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arc ARC: fix spare error 2024-11-18 12:12:17 +01:00
arm arm: dts: marvell: Fix maxium->maxim typo in brownstone dts 2024-11-19 09:22:14 +01:00
arm64 KVM: arm64: vgic-its: Test for valid IRQ in its_sync_lpi_pending_table() 2024-11-18 22:25:37 +01:00
c6x Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
csky Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
h8300 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hexagon Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ia64 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
m68k Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
microblaze Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mips MIPS: Clear Cause.BD in instruction_pointer_set 2024-11-19 08:44:35 +01:00
nds32 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nios2 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
openrisc Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
parisc parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds 2024-11-19 09:22:16 +01:00
powerpc powerpc/fsl: Fix mfpmr build errors with newer binutils 2024-11-19 09:22:17 +01:00
riscv riscv: Sparse-Memory/vmemmap out-of-bounds fix 2024-11-18 23:18:29 +01:00
s390 s390/vtime: fix average steal time calculation 2024-11-19 08:44:59 +01:00
sh sh: bios: Revive earlyprintk support 2024-11-18 11:43:04 +01:00
sparc sparc: vDSO: fix return value of __setup handler 2024-11-19 09:22:15 +01:00
um um: allow not setting extra rpaths in the linux binary 2024-11-18 23:19:35 +01:00
x86 KVM: SVM: Flush pages under kvm->lock to fix UAF in svm_register_enc_region() 2024-11-19 09:22:38 +01:00
xtensa Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00