kernel-fxtec-pro1x/arch/powerpc/net
Eric Dumazet a6359d5e2d powerpc/bpf: Fix tail call implementation
[ Upstream commit 7de086909365cd60a5619a45af3f4152516fd75c ]

We have seen many crashes on powerpc hosts while loading bpf programs.

The problem here is that bpf_int_jit_compile() does a first pass
to compute the program length.

Then it allocates memory to store the generated program and
calls bpf_jit_build_body() a second time (and a third time
later)

What I have observed is that the second bpf_jit_build_body()
could end up using few more words than expected.

If bpf_jit_binary_alloc() put the space for the program
at the end of the allocated page, we then write on
a non mapped memory.

It appears that bpf_jit_emit_tail_call() calls
bpf_jit_emit_common_epilogue() while ctx->seen might not
be stable.

Only after the second pass we can be sure ctx->seen wont be changed.

Trying to avoid a second pass seems quite complex and probably
not worth it.

Fixes: ce0761419f ("powerpc/bpf: Implement support for tail calls")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
Cc: Sandipan Das <sandipan@linux.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20191101033444.143741-1-edumazet@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-12-05 09:19:39 +01:00
..
bpf_jit.h powerpc/bpf: use unsigned division instruction for 64-bit operations 2019-06-25 11:36:00 +08:00
bpf_jit32.h powerpc: bpf: Fix generation of load/store DW instructions 2019-04-03 06:26:21 +02:00
bpf_jit64.h powerpc: bpf: Fix generation of load/store DW instructions 2019-04-03 06:26:21 +02:00
bpf_jit_asm.S powerpc: move ASM_CONST and stringify_in_c() into asm-const.h 2018-07-30 22:48:16 +10:00
bpf_jit_comp.c powerpc: move ASM_CONST and stringify_in_c() into asm-const.h 2018-07-30 22:48:16 +10:00
bpf_jit_comp64.c powerpc/bpf: Fix tail call implementation 2019-12-05 09:19:39 +01:00
Makefile powerpc/Makefiles: Convert ifeq to ifdef where possible 2018-08-08 00:32:36 +10:00