kernel_optimize_test/arch/x86
Yi Wang 0fb470eb48 KVM: SVM: fix panic on out-of-bounds guest IRQ
commit a80ced6ea514000d34bf1239d47553de0d1ee89e upstream.

As guest_irq is coming from KVM_IRQFD API call, it may trigger
crash in svm_update_pi_irte() due to out-of-bounds:

crash> bt
PID: 22218  TASK: ffff951a6ad74980  CPU: 73  COMMAND: "vcpu8"
 #0 [ffffb1ba6707fa40] machine_kexec at ffffffff8565b397
 #1 [ffffb1ba6707fa90] __crash_kexec at ffffffff85788a6d
 #2 [ffffb1ba6707fb58] crash_kexec at ffffffff8578995d
 #3 [ffffb1ba6707fb70] oops_end at ffffffff85623c0d
 #4 [ffffb1ba6707fb90] no_context at ffffffff856692c9
 #5 [ffffb1ba6707fbf8] exc_page_fault at ffffffff85f95b51
 #6 [ffffb1ba6707fc50] asm_exc_page_fault at ffffffff86000ace
    [exception RIP: svm_update_pi_irte+227]
    RIP: ffffffffc0761b53  RSP: ffffb1ba6707fd08  RFLAGS: 00010086
    RAX: ffffb1ba6707fd78  RBX: ffffb1ba66d91000  RCX: 0000000000000001
    RDX: 00003c803f63f1c0  RSI: 000000000000019a  RDI: ffffb1ba66db2ab8
    RBP: 000000000000019a   R8: 0000000000000040   R9: ffff94ca41b82200
    R10: ffffffffffffffcf  R11: 0000000000000001  R12: 0000000000000001
    R13: 0000000000000001  R14: ffffffffffffffcf  R15: 000000000000005f
    ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
 #7 [ffffb1ba6707fdb8] kvm_irq_routing_update at ffffffffc09f19a1 [kvm]
 #8 [ffffb1ba6707fde0] kvm_set_irq_routing at ffffffffc09f2133 [kvm]
 #9 [ffffb1ba6707fe18] kvm_vm_ioctl at ffffffffc09ef544 [kvm]
    RIP: 00007f143c36488b  RSP: 00007f143a4e04b8  RFLAGS: 00000246
    RAX: ffffffffffffffda  RBX: 00007f05780041d0  RCX: 00007f143c36488b
    RDX: 00007f05780041d0  RSI: 000000004008ae6a  RDI: 0000000000000020
    RBP: 00000000000004e8   R8: 0000000000000008   R9: 00007f05780041e0
    R10: 00007f0578004560  R11: 0000000000000246  R12: 00000000000004e0
    R13: 000000000000001a  R14: 00007f1424001c60  R15: 00007f0578003bc0
    ORIG_RAX: 0000000000000010  CS: 0033  SS: 002b

Vmx have been fix this in commit 3a8b0677fc (KVM: VMX: Do not BUG() on
out-of-bounds guest IRQ), so we can just copy source from that to fix
this.

Co-developed-by: Yi Liu <liu.yi24@zte.com.cn>
Signed-off-by: Yi Liu <liu.yi24@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Message-Id: <20220309113025.44469-1-wang.yi59@zte.com.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-08 14:40:39 +02:00
..
boot x86/boot/compressed: Move CLANG_FLAGS to beginning of KBUILD_CFLAGS 2022-01-27 10:54:00 +01:00
configs x86/kbuild: Enable CONFIG_KALLSYMS_ALL=y in the defconfigs 2022-01-27 10:54:21 +01:00
crypto crypto: x86/curve25519 - fix cpu feature checking logic in mod_exit 2021-07-14 16:56:06 +02:00
entry x86/entry: Add a fence for kernel entry SWAPGS in paranoid_entry() 2021-12-08 09:03:27 +01:00
events perf/x86/intel/pt: Fix address filter config for 32-bit kernel 2022-04-08 14:40:04 +02:00
hyperv x86/hyperv: Fix NULL deref in set_hv_tscchange_cb() if Hyper-V setup fails 2021-11-26 10:39:19 +01:00
ia32
include x86/speculation: Add eIBRS + Retpoline options 2022-03-11 12:11:49 +01:00
kernel KVM: x86: fix sending PV IPI 2022-04-08 14:40:39 +02:00
kvm KVM: SVM: fix panic on out-of-bounds guest IRQ 2022-04-08 14:40:39 +02:00
lib x86/iopl: Fake iopl(3) CLI/STI usage 2021-11-21 13:46:36 +01:00
math-emu
mm x86/boot: Add setup_indirect support in early_memremap_is_setup_data() 2022-03-16 14:16:02 +01:00
net bpf: Handle return value of BPF_PROG_TYPE_STRUCT_OPS prog 2021-10-06 15:55:50 +02:00
oprofile
pci PCI: Add AMD RS690 quirk to enable 64-bit DMA 2021-06-30 08:47:23 -04:00
platform x86/sme: Explicitly map new EFI memmap table as encrypted 2021-12-14 11:32:35 +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
realmode x86/mm: Flush global TLB when switching to trampoline page-table 2022-01-27 10:54:14 +01:00
tools x86/tools: Fix objdump version check again 2021-08-18 08:59:15 +02:00
um um: registers: Rename function names to avoid conflicts and build problems 2022-01-27 10:54:18 +01:00
video
xen xen: fix is_xen_pmu() 2022-04-08 14:40:29 +02:00
.gitignore
Kbuild
Kconfig x86/sme: Explicitly map new EFI memmap table as encrypted 2021-12-14 11:32:35 +01:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug
Makefile x86/build: Propagate $(CLANG_FLAGS) to $(REALMODE_FLAGS) 2021-05-11 14:47:18 +02:00
Makefile_32.cpu
Makefile.um