Skip to content

test_bpf.ko blinding fixes

Mathias Krause bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3bpf/tests: Make max jump tests constant blinding compatiblelib/test_bpf.c+1 -10 replies
2/3bpf: Allow calling bpf_jit_blinding_enabled() with a NULL programinclude/linux/filter.h+3 -20 replies
3/3bpf/tests: Make staggered jump tests constant blinding compatiblekernel/bpf/core.c kernel/bpf/token.c lib/test_bpf.c+23 -21 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/3] test_bpf.ko blinding fixes

With BPF constant blinding enabled, various tests exercising jump offset limits currently fail because size assumptions in the code no longer apply. The created BPF program will be expanded through BPF constant blinding, pushing jump target offsets over the limit.

This small series fixes these by either avoiding the use of instructions with immediate values (patch 1) or accounting for the expansion (patch 3).

Before:

root@box:~# sysctl net.core.bpf_jit_harden=2
root@box:~# insmod test_bpf.ko
insmod: ERROR: could not insert module test_bpf.ko: Invalid parameters
root@box:~# dmesg | grep Summary
[  177.628099] test_bpf: Summary: 1000 PASSED, 49 FAILED, [988/988 JIT'ed]

After:

root@box:~# sysctl net.core.bpf_jit_harden=2
root@box:~# insmod test_bpf.ko
root@box:~# dmesg | grep Summary
[  220.437597] test_bpf: Summary: 1049 PASSED, 0 FAILED, [1037/1037 JIT'ed]
[  220.477987] test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
[  220.480525] test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED

Please apply!

Thanks,
Mathias

Mathias Krause (3):
bpf/tests: Make max jump tests constant blinding compatible
bpf: Allow calling bpf_jit_blinding_enabled() with a NULL program bpf/tests: Make staggered jump tests constant blinding compatible

 include/linux/filter.h |  5 +++--
 kernel/bpf/core.c      |  3 +++
 kernel/bpf/token.c     |  3 +++
 lib/test_bpf.c         | 21 ++++++++++++++++++---
 4 files changed, 27 insertions(+), 5 deletions(-)
Signature · 1 line
2.30.2