linux-stable/arch
Paul Burton 4db02ac968 MIPS: eBPF: Always return sign extended 32b values
commit 13443154f6 upstream.

The function prototype used to call JITed eBPF code (ie. the type of the
struct bpf_prog bpf_func field) returns an unsigned int. The MIPS n64
ABI that MIPS64 kernels target defines that 32 bit integers should
always be sign extended when passed in registers as either arguments or
return values.

This means that when returning any value which may not already be sign
extended (ie. of type REG_64BIT or REG_32BIT_ZERO_EX) we need to perform
that sign extension in order to comply with the n64 ABI. Without this we
see strange looking test failures from test_bpf.ko, such as:

  test_bpf: #65 ALU64_MOV_X:
    dst = 4294967295 jited:1 ret -1 != -1 FAIL (1 times)

Although the return value printed matches the expected value, this is
only because printf is only examining the least significant 32 bits of
the 64 bit register value we returned. The register holding the expected
value is sign extended whilst the v0 register was set to a zero extended
value by our JITed code, so when compared by a conditional branch
instruction the values are not equal.

We already handle this when the return value register is of type
REG_32BIT_ZERO_EX, so simply extend this to also cover REG_64BIT.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Fixes: b6bd53f9c4 ("MIPS: Add missing file for eBPF JIT.")
Cc: stable@vger.kernel.org # v4.13+
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-27 10:08:49 +01:00
..
alpha alpha: Fix Eiger NR_IRQS to 128 2019-02-20 10:25:47 +01:00
arc ARC: perf: map generic branches to correct hardware condition 2019-01-31 08:14:35 +01:00
arm ARM: 8834/1: Fix: kprobes: optimized kprobes illegal instruction 2019-02-27 10:08:49 +01:00
arm64 arm64/sve: ptrace: Fix SVE_PT_REGS_OFFSET definition 2019-02-12 19:47:19 +01:00
c6x kbuild: rename LDFLAGS to KBUILD_LDFLAGS 2018-08-24 08:22:08 +09:00
h8300 Kbuild updates for v4.19 (2nd) 2018-08-25 13:40:38 -07:00
hexagon hexagon: modify ffs() and fls() to return int 2018-09-10 19:42:15 -05:00
ia64 ia64: Fix allnoconfig section mismatch for ioc_init/ioc_iommu_info 2018-08-22 14:12:47 -07:00
m68k m68k: Fix memblock-related crashes 2019-01-13 09:51:02 +01:00
microblaze mm: make the __PAGETABLE_PxD_FOLDED defines non-empty 2018-12-29 13:37:57 +01:00
mips MIPS: eBPF: Always return sign extended 32b values 2019-02-27 10:08:49 +01:00
nds32 nds32: Fix gcc 8.0 compiler option incompatible. 2019-02-12 19:46:57 +01:00
nios2 nios2: kconfig: remove duplicate DEBUG_STACK_USAGE symbol defintions 2018-08-27 09:47:20 +08:00
openrisc OpenRISC updates for 4.19 2018-08-23 14:09:37 -07:00
parisc mm: make the __PAGETABLE_PxD_FOLDED defines non-empty 2018-12-29 13:37:57 +01:00
powerpc powerpc/radix: Fix kernel crash with mremap() 2019-02-15 08:10:12 +01:00
riscv riscv: Add pte bit to distinguish swap from invalid 2019-02-20 10:25:46 +01:00
s390 s390/zcrypt: improve special ap message cmd handling 2019-02-12 19:47:04 +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 mm: convert return type of handle_mm_fault() caller to vm_fault_t 2018-08-17 16:20:28 -07:00
x86 x86/a.out: Clear the dump structure initially 2019-02-20 10:25:49 +01:00
xtensa xtensa: xtfpga.dtsi: fix dtc warnings about SPI 2019-02-12 19:47:05 +01:00
.gitignore
Kconfig Merge branch 'tlb-fixes' 2018-08-23 14:55:01 -07:00