Skip to content

Commit 419ac82

Browse files
rnavmpe
authored andcommitted
powerpc/bpf: Fix detecting BPF atomic instructions
Commit 91c960b ("bpf: Rename BPF_XADD and prepare to encode other atomics in .imm") converted BPF_XADD to BPF_ATOMIC and added a way to distinguish instructions based on the immediate field. Existing JIT implementations were updated to check for the immediate field and to reject programs utilizing anything more than BPF_ADD (such as BPF_FETCH) in the immediate field. However, the check added to powerpc64 JIT did not look at the correct BPF instruction. Due to this, such programs would be accepted and incorrectly JIT'ed resulting in soft lockups, as seen with the atomic bounds test. Fix this by looking at the correct immediate value. Fixes: 91c960b ("bpf: Rename BPF_XADD and prepare to encode other atomics in .imm") Reported-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Tested-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/4117b430ffaa8cd7af042496f87fd7539e4f17fd.1625145429.git.naveen.n.rao@linux.vnet.ibm.com
1 parent cd5d5e6 commit 419ac82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/powerpc/net/bpf_jit_comp64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context *
667667
* BPF_STX ATOMIC (atomic ops)
668668
*/
669669
case BPF_STX | BPF_ATOMIC | BPF_W:
670-
if (insn->imm != BPF_ADD) {
670+
if (imm != BPF_ADD) {
671671
pr_err_ratelimited(
672672
"eBPF filter atomic op code %02x (@%d) unsupported\n",
673673
code, i);
@@ -689,7 +689,7 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, struct codegen_context *
689689
PPC_BCC_SHORT(COND_NE, tmp_idx);
690690
break;
691691
case BPF_STX | BPF_ATOMIC | BPF_DW:
692-
if (insn->imm != BPF_ADD) {
692+
if (imm != BPF_ADD) {
693693
pr_err_ratelimited(
694694
"eBPF filter atomic op code %02x (@%d) unsupported\n",
695695
code, i);

0 commit comments

Comments
 (0)