From: Naveen N. Rao <hidden> Date: 2021-07-01 15:09:46
The first patch fixes an issue that causes a soft lockup on ppc64 with
the BPF_ATOMIC bounds propagation verifier test. The second one updates
ppc32 JIT to reject atomic operations properly.
- Naveen
Naveen N. Rao (2):
powerpc/bpf: Fix detecting BPF atomic instructions
powerpc/bpf: Reject atomic ops in ppc32 JIT
arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
arch/powerpc/net/bpf_jit_comp64.c | 4 ++--
2 files changed, 13 insertions(+), 5 deletions(-)
base-commit: 086d9878e1092e7e69a69676ee9ec792690abb1d
--
2.31.1
From: Naveen N. Rao <hidden> Date: 2021-07-01 15:09:48
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
arch/powerpc/net/bpf_jit_comp64.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
On Thu, Jul 1, 2021 at 8:09 AM Naveen N. Rao
[off-list ref] wrote:
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.
How do you want this fix routed? via bpf tree?
From: Naveen N. Rao <hidden> Date: 2021-07-01 19:32:32
Alexei Starovoitov wrote:
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 :)
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?
This also needs to be tagged for stable:
Cc: stable@vger.kernel.org # 5.12+
- Naveen
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?
From: Jiri Olsa <hidden> Date: 2021-07-02 10:26:18
On Thu, Jul 01, 2021 at 08:38:58PM +0530, Naveen N. Rao wrote:
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.
From: Naveen N. Rao <hidden> Date: 2021-07-01 15:10:15
Commit 91c960b0056672 ("bpf: Rename BPF_XADD and prepare to encode other
atomics in .imm") converted BPF_XADD to BPF_ATOMIC and updated all JIT
implementations to reject JIT'ing instructions with an immediate value
different from BPF_ADD. However, ppc32 BPF JIT was implemented around
the same time and didn't include the same change. Update the ppc32 JIT
accordingly.
Signed-off-by: Naveen N. Rao <redacted>
---
arch/powerpc/net/bpf_jit_comp32.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
Commit 91c960b0056672 ("bpf: Rename BPF_XADD and prepare to encode other
atomics in .imm") converted BPF_XADD to BPF_ATOMIC and updated all JIT
implementations to reject JIT'ing instructions with an immediate value
different from BPF_ADD. However, ppc32 BPF JIT was implemented around
the same time and didn't include the same change. Update the ppc32 JIT
accordingly.
Signed-off-by: Naveen N. Rao <redacted>
Shouldn't it also include a Fixes tag and stable Cc as PPC32 eBPF was added in 5.13 ?
Fixes: 51c66ad849a7 ("powerpc/bpf: Implement extended BPF on PPC32")
Cc: stable@vger.kernel.org
From: Naveen N. Rao <hidden> Date: 2021-07-01 19:36:54
Christophe Leroy wrote:
Le 01/07/2021 à 17:08, Naveen N. Rao a écrit :
quoted
Commit 91c960b0056672 ("bpf: Rename BPF_XADD and prepare to encode other
atomics in .imm") converted BPF_XADD to BPF_ATOMIC and updated all JIT
implementations to reject JIT'ing instructions with an immediate value
different from BPF_ADD. However, ppc32 BPF JIT was implemented around
the same time and didn't include the same change. Update the ppc32 JIT
accordingly.
Signed-off-by: Naveen N. Rao <redacted>
Shouldn't it also include a Fixes tag and stable Cc as PPC32 eBPF was added in 5.13 ?
Yes, I wasn't sure which patch to actually blame. But you're right, this
should have the below fixes tag since this affects the ppc32 eBPF JIT.
Fixes: 51c66ad849a7 ("powerpc/bpf: Implement extended BPF on PPC32")
Cc: stable@vger.kernel.org
From: Michael Ellerman <hidden> Date: 2021-07-06 10:52:57
On Thu, 1 Jul 2021 20:38:57 +0530, Naveen N. Rao wrote:
The first patch fixes an issue that causes a soft lockup on ppc64 with
the BPF_ATOMIC bounds propagation verifier test. The second one updates
ppc32 JIT to reject atomic operations properly.
- Naveen
Naveen N. Rao (2):
powerpc/bpf: Fix detecting BPF atomic instructions
powerpc/bpf: Reject atomic ops in ppc32 JIT
[...]