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

Fix "BPF program too large" error in kernel release 6.4 and greater #1908

Merged
merged 1 commit into from
Aug 3, 2023

Conversation

javierhonduco
Copy link
Contributor

Fixes #1880, which contains more details, but the summary is that this commit and greater prevent our code to load.

Author: Eduard Zingerman <eddyz87@gmail.com>
Date:   Tue Jun 13 18:38:23 2023 +0300

bpf: Verify scalar ids mapping in regsafe() using check_ids()

I am not super sure of all the effects of that commit above, but it seems that perhaps the verifier is accounting for more execution paths, increasing the number of instructions that's analysing, making it go over the threshold.

This is remediated by reducing the number of instructions we have per program. Before we packed as many iterations of the main loop as we could, which now we have to reduce.

A possible side-effect is that for very large stacks we'll have to run more tail-calls, which while they are cheap, they aren't zero-cost. There might be some other performance implications, but we need to make this change for newer kernels, so let's benchmark this later on, but I don't expect the performance impact to be huge.

Test Plan

Compiled a custom kernel 6.4.7 off 4e382c2b468348d6208e5a18dbf1591a18170889 0 and run our cpu tests without any issues, while before we were seeing a failure.

Will add this kernel to our kernel tests in some weeks.

Fixes #1880, which
contains more details, but the summary is that this commit and greater
prevent our code to load.

```
Author: Eduard Zingerman <eddyz87@gmail.com>
Date:   Tue Jun 13 18:38:23 2023 +0300

bpf: Verify scalar ids mapping in regsafe() using check_ids()
```

I am not super sure of all the effects of that commit above, but it
seems that perhaps the verifier is accounting for more execution paths,
increasing the number of instructions that's analysing, making it go
over the threshold.

This is remediated by reducing the number of instructions we have per
program. Before we packed as many iterations of the main loop as we
could, which now we have to reduce.

A possible side-effect is that for very large stacks we'll have to run
more tail-calls, which while they are cheap, they aren't zero-cost.
There might be some other performance implications, but we need to make
this change for newer kernels, so let's benchmark this later on, but I
don't expect the performance impact to be huge.

Test Plan
=========

Compiled a custom kernel 6.4.7 off 4e382c2b468348d6208e5a18dbf1591a18170889 [0]
and run our cpu tests without any issues, while before we were seeing
a failure.

[0]: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.4.7

Signed-off-by: Francisco Javier Honduvilla Coto <javierhonduco@gmail.com>
@javierhonduco javierhonduco requested a review from a team as a code owner August 3, 2023 18:00
@javierhonduco javierhonduco merged commit f2aa11f into main Aug 3, 2023
22 checks passed
@javierhonduco javierhonduco deleted the fix-bpf-program-too-large-in-kernel-v6.4 branch August 3, 2023 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BPF program fails to load with BPF program is too large in Linux 6.4
2 participants