1
0
Fork 0
freescale-linux-fslc/arch/x86
Sean Christopherson d046f724bb KVM: x86: Ensure liveliness of nested VM-Enter fail tracepoint message
commit f31500b0d437a2464ca5972d8f5439e156b74960 upstream.

Use the __string() machinery provided by the tracing subystem to make a
copy of the string literals consumed by the "nested VM-Enter failed"
tracepoint.  A complete copy is necessary to ensure that the tracepoint
can't outlive the data/memory it consumes and deference stale memory.

Because the tracepoint itself is defined by kvm, if kvm-intel and/or
kvm-amd are built as modules, the memory holding the string literals
defined by the vendor modules will be freed when the module is unloaded,
whereas the tracepoint and its data in the ring buffer will live until
kvm is unloaded (or "indefinitely" if kvm is built-in).

This bug has existed since the tracepoint was added, but was recently
exposed by a new check in tracing to detect exactly this type of bug.

  fmt: '%s%s
  ' current_buffer: ' vmx_dirty_log_t-140127  [003] ....  kvm_nested_vmenter_failed: '
  WARNING: CPU: 3 PID: 140134 at kernel/trace/trace.c:3759 trace_check_vprintf+0x3be/0x3e0
  CPU: 3 PID: 140134 Comm: less Not tainted 5.13.0-rc1-ce2e73ce600a-req #184
  Hardware name: ASUS Q87M-E/Q87M-E, BIOS 1102 03/03/2014
  RIP: 0010:trace_check_vprintf+0x3be/0x3e0
  Code: <0f> 0b 44 8b 4c 24 1c e9 a9 fe ff ff c6 44 02 ff 00 49 8b 97 b0 20
  RSP: 0018:ffffa895cc37bcb0 EFLAGS: 00010282
  RAX: 0000000000000000 RBX: ffffa895cc37bd08 RCX: 0000000000000027
  RDX: 0000000000000027 RSI: 00000000ffffdfff RDI: ffff9766cfad74f8
  RBP: ffffffffc0a041d4 R08: ffff9766cfad74f0 R09: ffffa895cc37bad8
  R10: 0000000000000001 R11: 0000000000000001 R12: ffffffffc0a041d4
  R13: ffffffffc0f4dba8 R14: 0000000000000000 R15: ffff976409f2c000
  FS:  00007f92fa200740(0000) GS:ffff9766cfac0000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 0000559bd11b0000 CR3: 000000019fbaa002 CR4: 00000000001726e0
  Call Trace:
   trace_event_printf+0x5e/0x80
   trace_raw_output_kvm_nested_vmenter_failed+0x3a/0x60 [kvm]
   print_trace_line+0x1dd/0x4e0
   s_show+0x45/0x150
   seq_read_iter+0x2d5/0x4c0
   seq_read+0x106/0x150
   vfs_read+0x98/0x180
   ksys_read+0x5f/0xe0
   do_syscall_64+0x40/0xb0
   entry_SYSCALL_64_after_hwframe+0x44/0xae

Cc: Steven Rostedt <rostedt@goodmis.org>
Fixes: 380e0055bc ("KVM: nVMX: trace nested VM-Enter failures detected by H/W")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Message-Id: <20210607175748.674002-1-seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-16 12:01:46 +02:00
..
boot x86/boot/compressed/64: Check SEV encryption in the 32-bit boot-path 2021-05-26 12:06:57 +02:00
configs * A defconfig fix, from Daniel Díaz. 2020-09-20 15:06:43 -07:00
crypto crypto: poly1305 - fix poly1305_core_setkey() declaration 2021-05-14 09:50:13 +02:00
entry x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls 2021-03-17 17:06:36 +01:00
events perf/x86/intel/uncore: Fix M2M event umask for Ice Lake server 2021-06-16 12:01:39 +02:00
hyperv x86/hyperv: Fix kexec panic/hang issues 2021-01-27 11:54:57 +01:00
ia32 x86: remove address space overrides using set_fs() 2020-09-08 22:21:36 -04:00
include x86/kvm: Disable all PV features on crash 2021-06-10 13:39:29 +02:00
kernel x86/nmi_watchdog: Fix old-style NMI watchdog regression on old Intel CPUs 2021-06-16 12:01:46 +02:00
kvm KVM: x86: Ensure liveliness of nested VM-Enter fail tracepoint message 2021-06-16 12:01:46 +02:00
lib x86/msr: Fix wr/rdmsr_safe_regs_on_cpu() prototypes 2021-05-22 11:40:51 +02:00
math-emu treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
mm x86/sev: Check SME/SEV support in CPUID first 2021-06-10 13:39:27 +02:00
net bpf, x86: Validate computation of branch displacements for x86-32 2021-04-10 13:36:11 +02:00
oprofile x86: Use pr_warn instead of pr_warning 2019-10-18 15:00:18 +02:00
pci x86/pci: Create PCI/MSI irqdomain after x86_init.pci.arch_init() 2021-02-17 11:02:28 +01:00
platform x86/efi: Remove EFI PGD build time checks 2021-02-17 11:02:24 +01:00
power PM: hibernate: x86: Use crc32 instead of md5 for hibernation e820 integrity check 2021-05-14 09:50:21 +02:00
purgatory treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
ras treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
realmode x86/head/64: Don't call verify_cpu() on starting APs 2020-09-09 11:33:20 +02:00
tools x86/build: Treat R_386_PLT32 relocation as R_386_PC32 2021-03-07 12:34:04 +01:00
um arch/um: partially revert the conversion to __section() macro 2020-10-26 15:39:37 -07:00
video
xen x86/Xen: swap NX determination and GDT setup on BSP 2021-05-26 12:06:57 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Kbuild
Kconfig x86/platform/uv: Fix !KEXEC build failure 2021-05-14 09:50:20 +02:00
Kconfig.assembler x86/delay: Introduce TPAUSE delay 2020-05-07 16:06:20 +02:00
Kconfig.cpu treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Kconfig.debug x86, powerpc: Rename memcpy_mcsafe() to copy_mc_to_{user, kernel}() 2020-10-06 11:18:04 +02:00
Makefile x86/build: Propagate $(CLANG_FLAGS) to $(REALMODE_FLAGS) 2021-05-11 14:47:18 +02:00
Makefile.um
Makefile_32.cpu