linux-stable/arch
Cfir Cohen 1972ca0470 KVM: Fix UAF in nested posted interrupt processing
commit c2dd5146e9 upstream.

nested_get_vmcs12_pages() processes the posted_intr address in vmcs12. It
caches the kmap()ed page object and pointer, however, it doesn't handle
errors correctly: it's possible to cache a valid pointer, then release
the page and later dereference the dangling pointer.

I was able to reproduce with the following steps:

1. Call vmlaunch with valid posted_intr_desc_addr but an invalid
MSR_EFER. This causes nested_get_vmcs12_pages() to cache the kmap()ed
pi_desc_page and pi_desc. Later the invalid EFER value fails
check_vmentry_postreqs() which fails the first vmlaunch.

2. Call vmlanuch with a valid EFER but an invalid posted_intr_desc_addr
(I set it to 2G - 0x80). The second time we call nested_get_vmcs12_pages
pi_desc_page is unmapped and released and pi_desc_page is set to NULL
(the "shouldn't happen" clause). Due to the invalid
posted_intr_desc_addr, kvm_vcpu_gpa_to_page() fails and
nested_get_vmcs12_pages() returns. It doesn't return an error value so
vmlaunch proceeds. Note that at this time we have a dangling pointer in
vmx->nested.pi_desc and POSTED_INTR_DESC_ADDR in L0's vmcs.

3. Issue an IPI in L2 guest code. This triggers a call to
vmx_complete_nested_posted_interrupt() and pi_test_and_clear_on() which
dereferences the dangling pointer.

Vulnerable code requires nested and enable_apicv variables to be set to
true. The host CPU must also support posted interrupts.

Fixes: 5e2f30b756 "KVM: nVMX: get rid of nested_get_page()"
Cc: stable@vger.kernel.org
Reviewed-by: Andy Honig <ahonig@google.com>
Signed-off-by: Cfir Cohen <cfir@google.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-29 13:37:56 +01:00
..
alpha arch/alpha, termios: implement BOTHER, IBSHIFT and termios2 2018-11-21 09:19:20 +01:00
arc ARC: io.h: Implement reads{x}()/writes{x}() 2018-12-21 14:15:16 +01:00
arm ARM: 8816/1: dma-mapping: fix potential uninitialized return 2018-12-21 14:15:21 +01:00
arm64 arm64: dma-mapping: Fix FORCE_CONTIGUOUS buffer clearing 2018-12-19 19:19:50 +01:00
c6x kbuild: rename LDFLAGS to KBUILD_LDFLAGS 2018-08-24 08:22:08 +09:00
h8300 Kbuild updates for v4.19 (2nd) 2018-08-25 13:40:38 -07:00
hexagon hexagon: modify ffs() and fls() to return int 2018-09-10 19:42:15 -05:00
ia64 ia64: Fix allnoconfig section mismatch for ioc_init/ioc_iommu_info 2018-08-22 14:12:47 -07:00
m68k crypto: speck - remove Speck 2018-11-13 11:08:46 -08:00
microblaze microblaze: function_graph: Simplify with function_graph_enter() 2018-12-05 19:32:09 +01:00
mips mips: fix mips_get_syscall_arg o32 check 2018-12-08 12:59:07 +01:00
nds32 nds32: function_graph: Simplify with function_graph_enter() 2018-12-05 19:32:09 +01:00
nios2 nios2: kconfig: remove duplicate DEBUG_STACK_USAGE symbol defintions 2018-08-27 09:47:20 +08:00
openrisc OpenRISC updates for 4.19 2018-08-23 14:09:37 -07:00
parisc parisc: Enable -ffunction-sections for modules on 32-bit kernel 2018-12-13 09:16:18 +01:00
powerpc powerpc: Look for "stdout-path" when setting up legacy consoles 2018-12-19 19:19:52 +01:00
riscv riscv: fix warning in arch/riscv/include/asm/module.h 2018-12-13 09:16:14 +01:00
s390 s390/cpum_cf: Reject request for sampling in event initialization 2018-12-17 09:24:32 +01:00
sh sh/function_graph: Simplify with function_graph_enter() 2018-12-05 19:32:09 +01:00
sparc sparc/function_graph: Simplify with function_graph_enter() 2018-12-05 19:32:10 +01:00
um um: Give start_idle_thread() a return code 2018-11-27 16:12:59 +01:00
unicore32 mm: convert return type of handle_mm_fault() caller to vm_fault_t 2018-08-17 16:20:28 -07:00
x86 KVM: Fix UAF in nested posted interrupt processing 2018-12-29 13:37:56 +01:00
xtensa xtensa: fix coprocessor part of ptrace_{get,set}xregs 2018-12-05 19:32:06 +01:00
.gitignore
Kconfig Merge branch 'tlb-fixes' 2018-08-23 14:55:01 -07:00