linux/arch/powerpc/net
Hari Bathini 6f657bb66f powerpc/bpf: Fix write protecting JIT code
commit 44a8214de9 upstream.

Running program with bpf-to-bpf function calls results in data access
exception (0x300) with the below call trace:

  bpf_int_jit_compile+0x238/0x750 (unreliable)
  bpf_check+0x2008/0x2710
  bpf_prog_load+0xb00/0x13a0
  __sys_bpf+0x6f4/0x27c0
  sys_bpf+0x2c/0x40
  system_call_exception+0x164/0x330
  system_call_vectored_common+0xe8/0x278

as bpf_int_jit_compile() tries writing to write protected JIT code
location during the extra pass.

Fix it by holding off write protection of JIT code until the extra
pass, where branch target addresses fixup happens.

Fixes: 62e3d4210a ("powerpc/bpf: Write protect JIT code")
Cc: stable@vger.kernel.org # v5.14+
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20211025055649.114728-1-hbathini@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2021-11-18 19:17:19 +01:00
..
bpf_jit.h powerpc/bpf: Validate branch ranges 2021-10-07 18:52:33 +11:00
bpf_jit64.h powerpc/bpf: Emit stf barrier instruction sequences for BPF_NOSPEC 2021-10-07 19:52:58 +11:00
bpf_jit_comp.c powerpc/bpf: Fix write protecting JIT code 2021-11-18 19:17:19 +01:00
bpf_jit_comp32.c powerpc/bpf ppc32: Fix BPF_SUB when imm == 0x80000000 2021-10-07 19:52:59 +11:00
bpf_jit_comp64.c powerpc/bpf: Emit stf barrier instruction sequences for BPF_NOSPEC 2021-10-07 19:52:58 +11:00
Makefile powerpc/bpf: Implement extended BPF on PPC32 2021-04-03 21:22:21 +11:00