linux-stable/arch/x86
JP Kobryn 403d201d1f perf/x86/lbr: Filter vsyscall addresses
[ Upstream commit e53899771a ]

We found that a panic can occur when a vsyscall is made while LBR sampling
is active. If the vsyscall is interrupted (NMI) for perf sampling, this
call sequence can occur (most recent at top):

    __insn_get_emulate_prefix()
    insn_get_emulate_prefix()
    insn_get_prefixes()
    insn_get_opcode()
    decode_branch_type()
    get_branch_type()
    intel_pmu_lbr_filter()
    intel_pmu_handle_irq()
    perf_event_nmi_handler()

Within __insn_get_emulate_prefix() at frame 0, a macro is called:

    peek_nbyte_next(insn_byte_t, insn, i)

Within this macro, this dereference occurs:

    (insn)->next_byte

Inspecting registers at this point, the value of the next_byte field is the
address of the vsyscall made, for example the location of the vsyscall
version of gettimeofday() at 0xffffffffff600000. The access to an address
in the vsyscall region will trigger an oops due to an unhandled page fault.

To fix the bug, filtering for vsyscalls can be done when
determining the branch type. This patch will return
a "none" branch if a kernel address if found to lie in the
vsyscall region.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: JP Kobryn <inwardvessel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-10-25 11:58:58 +02:00
..
boot x86/sev: Check for user-space IOIO pointing to kernel space 2023-10-25 11:58:55 +02:00
configs x86/kbuild: Enable CONFIG_KALLSYMS_ALL=y in the defconfigs 2022-01-27 11:04:56 +01:00
crypto crypto: x86/ghash - fix unaligned access in ghash_setkey() 2023-03-10 09:39:08 +01:00
entry x86/mm: Fix VDSO and VVAR placement on 5-level paging machines 2023-08-16 18:21:59 +02:00
events perf/x86/lbr: Filter vsyscall addresses 2023-10-25 11:58:58 +02:00
hyperv x86/hyperv: Remove unregister syscore call from Hyper-V cleanup 2022-12-31 13:14:39 +01:00
ia32
include x86/cpu: Fix AMD erratum #1485 on Zen4-based CPUs 2023-10-19 23:05:36 +02:00
kernel x86/sev: Check for user-space IOIO pointing to kernel space 2023-10-25 11:58:55 +02:00
kvm KVM: x86: Mask LVTPC when handling a PMI 2023-10-25 11:58:55 +02:00
lib x86/retpoline,kprobes: Fix position of thunk sections with CONFIG_LTO_CLANG 2023-08-26 14:23:40 +02:00
math-emu x86: Prepare asm files for straight-line-speculation 2022-05-15 20:18:49 +02:00
mm x86/mm: Use mm_alloc() in poking_init() 2023-08-08 19:58:33 +02:00
net x86/extable: Extend extable functionality 2022-07-29 17:25:26 +02:00
pci x86/PCI: Add quirk for AMD XHCI controller that loses MSI-X state in D3hot 2023-04-20 12:13:55 +02:00
platform x86/olpc: fix 'logical not is only applied to the left hand side' 2022-08-17 14:24:18 +02:00
power x86/pm: Add enumeration check before spec MSRs save/restore setup 2022-12-02 17:41:09 +01:00
purgatory x86/purgatory: Remove LTO flags 2023-09-23 11:10:01 +02:00
ras
realmode x86/mm: Flush global TLB when switching to trampoline page-table 2022-01-27 11:04:35 +01:00
tools
um x86: um: vdso: Add '%rcx' and '%r11' to the syscall clobber list 2023-03-11 13:57:26 +01:00
video
xen x86/xen: Fix secondary processors' FPU initialization 2023-08-08 19:58:32 +02:00
.gitignore
Kbuild
Kconfig x86/srso: Add a Speculative RAS Overflow mitigation 2023-08-08 19:58:34 +02:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug arch: make TRACE_IRQFLAGS_NMI_SUPPORT generic 2022-08-17 14:23:00 +02:00
Makefile x86/realmode: build with -D__DISABLE_EXPORTS 2022-07-23 12:53:56 +02:00
Makefile.um
Makefile_32.cpu