linux-brain/arch/powerpc
Ravi Bangoria 77b318a4e5 powerpc/perf: Dereference BHRB entries safely
commit f41d84dddc upstream.

It's theoretically possible that branch instructions recorded in
BHRB (Branch History Rolling Buffer) entries have already been
unmapped before they are processed by the kernel. Hence, trying to
dereference such memory location will result in a crash. eg:

    Unable to handle kernel paging request for data at address 0xd000000019c41764
    Faulting instruction address: 0xc000000000084a14
    NIP [c000000000084a14] branch_target+0x4/0x70
    LR [c0000000000eb828] record_and_restart+0x568/0x5c0
    Call Trace:
    [c0000000000eb3b4] record_and_restart+0xf4/0x5c0 (unreliable)
    [c0000000000ec378] perf_event_interrupt+0x298/0x460
    [c000000000027964] performance_monitor_exception+0x54/0x70
    [c000000000009ba4] performance_monitor_common+0x114/0x120

Fix it by deferefencing the addresses safely.

Fixes: 691231846c ("powerpc/perf: Fix setting of "to" addresses for BHRB")
Suggested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
[mpe: Use probe_kernel_read() which is clearer, tweak change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-29 17:43:00 +01:00
..
boot powerpc/corenet: explicitly disable the SDHC controller on kmcoge4 2017-11-15 15:53:13 +01:00
configs Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/scottwood/linux into next 2016-10-11 20:07:56 +11:00
crypto powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable() 2017-04-12 12:41:13 +02:00
include powerpc/64: Fix checksum folding in csum_tcpudp_nofold and ip_fast_csum_nofold 2017-12-16 16:25:47 +01:00
kernel powerpc/64s: Initialize ISAv3 MMU registers before setting partition table 2017-12-14 09:28:13 +01:00
kvm KVM: PPC: Book 3S: XICS: correct the real mode ICP rejecting counter 2017-11-15 15:53:12 +01:00
lib powerpc: Fix emulation of mfocrf in emulate_step() 2017-07-27 15:08:00 -07:00
math-emu
mm powerpc/64: Invalidate process table caching after setting process table 2017-12-14 09:28:17 +01:00
net powerpc/bpf: Add support for bpf constant blinding 2016-10-04 20:33:20 +11:00
oprofile powerpc/sparse: Make a bunch of things static 2016-09-13 17:35:47 +10:00
perf powerpc/perf: Dereference BHRB entries safely 2017-12-29 17:43:00 +01:00
platforms powerpc/opal: Fix EBUSY bug in acquiring tokens 2017-12-20 10:07:28 +01:00
scripts powerpc/ftrace: Add Kconfig & Make glue for mprofile-kernel 2016-03-07 14:53:56 +11:00
sysdev powerpc/ipic: Fix status get and status clear 2017-12-20 10:07:28 +01:00
xmon powerpc/xmon: Don't use ld on 32-bit 2016-09-13 17:37:02 +10:00
Kconfig security/keys: add CONFIG_KEYS_COMPAT to Kconfig 2017-11-18 11:22:24 +01:00
Kconfig.debug powerpc/mm: Catch usage of cpu/mmu_has_feature() before jump label init 2016-08-01 11:15:06 +10:00
Makefile powerpc: Fix compiling a BE kernel with a powerpc64le toolchain 2017-12-14 09:28:17 +01:00
relocs_check.sh powerpc/64: whitelist unresolved modversions CRCs 2016-09-22 14:46:31 +02:00