Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_bpf.ko blinding fixes #8015

Open
wants to merge 3 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: test_bpf.ko blinding fixes
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=906240

Constant blinding may expand instructions that make use of immediate
values into multiple, resulting in preceding jump instructions to get a
bigger target offset. The "max jump" tests specifically attempt to test
the biggest possible jump offset, requiring to take special care about
the final (after blinding) offset while crafting the input program.

To make these tests independent of constant blinding's instruction
expansion, use a register-only operation to load R0 with the intended
value.

This fixes the "Long conditional jump" tests with enabled blinding.

Fixes: f1517eb ("bpf/tests: Expand branch conversion JIT test")
Cc: Johan Almbladh <[email protected]>
Signed-off-by: Mathias Krause <[email protected]>
To allow probing if constant blinding will be applied, support calling
bpf_jit_blinding_enabled() with a NULL program.

This allows to tailor the creation of a BPF program accordingly.

Signed-off-by: Mathias Krause <[email protected]>
The "staggered jumps" tests currently fail with constant blinding
enabled as the increased program size makes jump offsets overflow.

Fix that by decreasing the number of jumps depending on the expected
size increase caused by blinding the program.

As the test for JIT blinding makes use of bpf_jit_blinding_enabled(NULL)
and test_bpf.ko is a kernel modules, 'bpf_token_capable' and
'bpf_jit_harden' need to be exported.

Fixes: a7d2e75 ("bpf/tests: Add staggered JMP and JMP32 tests")
Cc: Johan Almbladh <[email protected]>
Signed-off-by: Mathias Krause <[email protected]>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 1850ce1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=906240
version: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant