linux-stable/arch
Naveen N. Rao 92d4ee2e82 powerpc: bpf: Fix generation of load/store DW instructions
commit 86be36f650 upstream.

Yauheni Kaliuta pointed out that PTR_TO_STACK store/load verifier test
was failing on powerpc64 BE, and rightfully indicated that the PPC_LD()
macro is not masking away the last two bits of the offset per the ISA,
resulting in the generation of 'lwa' instruction instead of the intended
'ld' instruction.

Segher also pointed out that we can't simply mask away the last two bits
as that will result in loading/storing from/to a memory location that
was not intended.

This patch addresses this by using ldx/stdx if the offset is not
word-aligned. We load the offset into a temporary register (TMP_REG_2)
and use that as the index register in a subsequent ldx/stdx. We fix
PPC_LD() macro to mask off the last two bits, but enhance PPC_BPF_LL()
and PPC_BPF_STL() to factor in the offset value and generate the proper
instruction sequence. We also convert all existing users of PPC_LD() and
PPC_STD() to use these macros. All existing uses of these macros have
been audited to ensure that TMP_REG_2 can be clobbered.

Fixes: 156d0e290e ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
Cc: stable@vger.kernel.org # v4.9+

Reported-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-03 06:26:21 +02:00
..
alpha alpha: Fix Eiger NR_IRQS to 128 2019-02-20 10:25:47 +01:00
arc ARCv2: don't assume core 0x54 has dual issue 2019-03-23 20:09:51 +01:00
arm ARM: imx6q: cpuidle: fix bug that CPU might not wake up at expected time 2019-04-03 06:26:21 +02:00
arm64 arm64: KVM: Fix architecturally invalid reset value for FPEXC32_EL2 2019-03-23 20:10:08 +01:00
c6x
h8300
hexagon
ia64
m68k m68k: Add -ffreestanding to CFLAGS 2019-03-23 20:10:00 +01:00
microblaze mm: make the __PAGETABLE_PxD_FOLDED defines non-empty 2018-12-29 13:37:57 +01:00
mips MIPS: Fix kernel crash for R6 in jump label branch function 2019-03-27 14:14:39 +09:00
nds32 nds32: Fix gcc 8.0 compiler option incompatible. 2019-02-12 19:46:57 +01:00
nios2
openrisc
parisc parisc: Fix ptrace syscall number modification 2019-02-27 10:09:00 +01:00
powerpc powerpc: bpf: Fix generation of load/store DW instructions 2019-04-03 06:26:21 +02:00
riscv riscv: Adjust mmap base address at a third of task size 2019-03-13 14:02:28 -07:00
s390 s390/setup: fix boot crash for machine without EDAT-1 2019-03-23 20:10:13 +01:00
sh arch/sh/boards/mach-kfr2r09/setup.c: fix struct mtd_oob_ops build warning 2019-02-12 19:47:18 +01:00
sparc sparc/function_graph: Simplify with function_graph_enter() 2018-12-05 19:32:10 +01:00
um um: Avoid marking pages with "changed protection" 2019-02-12 19:47:17 +01:00
unicore32
x86 x86/unwind: Add hardcoded ORC entry for NULL 2019-03-27 14:14:42 +09:00
xtensa xtensa: SMP: limit number of possible CPUs by NR_CPUS 2019-03-13 14:02:29 -07:00
.gitignore
Kconfig