-
Notifications
You must be signed in to change notification settings - Fork 112
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
Add fd_array_cnt attribute for BPF_PROG_LOAD #8148
Conversation
Upstream branch: c8d02b5 |
789c0d4
to
b87df96
Compare
Upstream branch: 45e04eb |
fb2399d
to
f425c0b
Compare
b87df96
to
767031f
Compare
Upstream branch: 3bfb49d |
f425c0b
to
0f5b2c8
Compare
767031f
to
953be85
Compare
Upstream branch: c721d8f |
0f5b2c8
to
cff4715
Compare
953be85
to
e5644e7
Compare
Upstream branch: c721d8f |
cff4715
to
9d749eb
Compare
e5644e7
to
5d3ed6f
Compare
Add a new helper to get a pointer to a struct btf from a file descriptor. This helper doesn't increase a refcnt. Add a comment explaining this and pointing to a corresponding function which does take a reference. Signed-off-by: Anton Protopopov <[email protected]>
Move some inlined map/prog compatibility checks from the resolve_pseudo_ldimm64() function to the dedicated check_map_prog_compatibility() function. Call the latter function from the add_used_map_from_fd() function directly. This simplifies code and optimizes logic a bit, as before these changes the check_map_prog_compatibility() function was executed on every map usage, which doesn't make sense, as it doesn't include any per-instruction checks, only map type vs. prog type. (This patch also simplifies a consequent patch which will call the add_used_map_from_fd() function from another code path.) Signed-off-by: Anton Protopopov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]>
The fd_array attribute of the BPF_PROG_LOAD syscall may contain a set of file descriptors: maps or btfs. This field was introduced as a sparse array. Introduce a new attribute, fd_array_cnt, which, if present, indicates that the fd_array is a continuous array of the corresponding length. If fd_array_cnt is non-zero, then every map in the fd_array will be bound to the program, as if it was used by the program. This functionality is similar to the BPF_PROG_BIND_MAP syscall, but such maps can be used by the verifier during the program load. Signed-off-by: Anton Protopopov <[email protected]>
Add new fd_array_cnt field to bpf_prog_load_opts and pass it in bpf_attr, if set. Signed-off-by: Anton Protopopov <[email protected]>
Add a new set of tests to test the new field in PROG_LOAD-related part of bpf_attr: fd_array_cnt. Add the following test cases: * fd_array_cnt/no-fd-array: program is loaded in a normal way, without any fd_array present * fd_array_cnt/fd-array-ok: pass two extra non-used maps, check that they're bound to the program * fd_array_cnt/fd-array-dup-input: pass a few extra maps, only two of which are unique * fd_array_cnt/fd-array-ref-maps-in-array: pass a map in fd_array which is also referenced from within the program * fd_array_cnt/fd-array-trash-input: pass array with some trash * fd_array_cnt/fd-array-with-holes: pass an array with holes (fd=0) * fd_array_cnt/fd-array-2big: pass too large array All the tests above are using the bpf(2) syscall directly, no libbpf involved. Signed-off-by: Anton Protopopov <[email protected]>
The bpf_remove_insns() function returns WARN_ON_ONCE(error), where error is a result of bpf_adj_branches(), and thus should be always 0 However, if for any reason it is not 0, then it will be converted to boolean by WARN_ON_ONCE and returned to user space as 1, not an actual error value. Fix this by returning the original err after the WARN check. Signed-off-by: Anton Protopopov <[email protected]> Acked-by: Jiri Olsa <[email protected]>
Replace magic constants in a BTF structure initialization code by proper macros, as is done in other similar selftests. Signed-off-by: Anton Protopopov <[email protected]> Suggested-by: Eduard Zingerman <[email protected]>
Upstream branch: c721d8f |
9d749eb
to
81dba58
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=913320 expired. Closing PR. |
Pull request for series with
subject: Add fd_array_cnt attribute for BPF_PROG_LOAD
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=913320