1
0
Fork 0
alistair23-linux/arch/powerpc/net
Daniel Borkmann b9c1e60e7b bpf, ppc64: fix unexpected r0=0 exit path inside bpf_xadd
None of the JITs is allowed to implement exit paths from the BPF
insn mappings other than BPF_JMP | BPF_EXIT. In the BPF core code
we have a couple of rewrites in eBPF (e.g. LD_ABS / LD_IND) and
in eBPF to cBPF translation to retain old existing behavior where
exceptions may occur; they are also tightly controlled by the
verifier where it disallows some of the features such as BPF to
BPF calls when legacy LD_ABS / LD_IND ops are present in the BPF
program. During recent review of all BPF_XADD JIT implementations
I noticed that the ppc64 one is buggy in that it contains two
jumps to exit paths. This is problematic as this can bypass verifier
expectations e.g. pointed out in commit f6b1b3bf0d ("bpf: fix
subprog verifier bypass by div/mod by 0 exception"). The first
exit path is obsoleted by the fix in ca36960211 ("bpf: allow xadd
only on aligned memory") anyway, and for the second one we need to
do a fetch, add and store loop if the reservation from lwarx/ldarx
was lost in the meantime.

Fixes: 156d0e290e ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
Tested-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2018-07-19 16:08:06 -07:00
..
Makefile bpf, ppc64: remove ld_abs/ld_ind 2018-05-03 16:49:20 -07:00
bpf_jit.h bpf, ppc64: implement jiting of BPF_J{LT, LE, SLT, SLE} 2017-08-09 16:53:57 -07:00
bpf_jit32.h powerpc/bpf/jit: Isolate classic BPF JIT specifics into a separate header 2016-06-24 15:15:51 +10:00
bpf_jit64.h bpf, ppc64: remove ld_abs/ld_ind 2018-05-03 16:49:20 -07:00
bpf_jit_asm.S powerpc/bpf/jit: Isolate classic BPF JIT specifics into a separate header 2016-06-24 15:15:51 +10:00
bpf_jit_comp.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
bpf_jit_comp64.c bpf, ppc64: fix unexpected r0=0 exit path inside bpf_xadd 2018-07-19 16:08:06 -07:00