Thread (10 messages) read the whole thread 10 messages, 5 authors, 2021-07-06

Re: [PATCH 1/2] powerpc/bpf: Fix detecting BPF atomic instructions

From: Alexei Starovoitov <hidden>
Date: 2021-07-01 19:33:42
Also in: bpf

On Thu, Jul 1, 2021 at 12:32 PM Naveen N. Rao
[off-list ref] wrote:
Alexei Starovoitov wrote:
quoted
On Thu, Jul 1, 2021 at 8:09 AM Naveen N. Rao
[off-list ref] wrote:
quoted
Commit 91c960b0056672 ("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: 91c960b0056672 ("bpf: Rename BPF_XADD and prepare to encode other atomics in .imm")
Reported-by: Jiri Olsa <redacted>
Tested-by: Jiri Olsa <redacted>
Signed-off-by: Naveen N. Rao <redacted>
---
Hi Jiri,
FYI: I made a small change in this patch -- using 'imm' directly, rather
than insn[i].imm. I've still added your Tested-by since this shouldn't
impact the fix in any way.

- Naveen
Excellent debugging! You guys are awesome.
Thanks. Jiri and Brendan did the bulk of the work :)
quoted
How do you want this fix routed? via bpf tree?
Michael has a few BPF patches queued up in powerpc tree for v5.14, so it
might be easier to take these patches through the powerpc tree unless he
feels otherwise. Michael?
Works for me. Thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help