bpftool: Reject non-autoload programs for light skeletons
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | selftests/bpf: Move verifier failure tests out of test_global_percpu_datatools/ tools/ tools/ | +32 | 0 replies | |
| 2/3 | bpftool: Reject non-autoload programs for light skeletonstools/ tools/ | +44 | 0 replies | |
| 3/3 | selftests/bpf: Test non-autoload rejection in light skeletonstools/ | +30 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf 0/3] bpftool: Reject non-autoload programs for light skeletons
When generating a light skeleton (bpftool gen skeleton -L), bpf_object__load() skips non-autoload programs (e.g. SEC("?...")), but bpftool still emits struct bpf_prog_desc and link fields for all programs. This causes the loader program to store subsequent program FDs into preceding struct fields and leave trailing prog_fd fields unpopulated (0).
Following the discussion on the earlier "skip non-autoload programs" series [1] and Andrii's feedback [2], this series returns to the initial approach [3] of rejecting non-autoload programs when generating light skeletons, while incorporating the prior review feedback (moving bpf_object__gen_loader()/bpf_object__load() earlier in do_skeleton() so post-load autoload adjustments are observed and documenting the restriction in bpftool-gen.rst).
Supporting runtime toggling of non-autoload programs in light skeletons was considered, but does not fit cleanly with signed light skeletons where the attested loader blob should remain authoritative.
Patch 1 splits the two SEC("?kprobe") verifier failure tests out of test_global_percpu_data.c (which is in LSKELS_EXTRA) before Patch 2 rejects them, so selftests continue to build at every commit. Patch 2 implements the rejection in bpftool. Patch 3 adds a selftest verifying the rejection.
[1] https://lore.kernel.org/bpf/[email protected]/
[2] https://lore.kernel.org/bpf/CAEf4BzaeKXEC-gBbxo36wdAGwwZxqkL6pV=oo0dke4S2BmuRmg@mail.gmail.com/
[3] https://lore.kernel.org/bpf/[email protected]/
Thiébaud Weksteen (3):
selftests/bpf: Move verifier failure tests out of
test_global_percpu_data
bpftool: Reject non-autoload programs for light skeletons selftests/bpf: Test non-autoload rejection in light skeletons
.../bpf/bpftool/Documentation/bpftool-gen.rst | 4 +- tools/bpf/bpftool/gen.c | 68 +++++++++++-------- .../selftests/bpf/prog_tests/bpftool_gen.c | 30 ++++++++ .../bpf/prog_tests/global_data_init.c | 3 +- .../bpf/progs/test_global_percpu_data.c | 23 ------- .../progs/test_global_percpu_data_failure.c | 30 ++++++++ 6 files changed, 106 insertions(+), 52 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/bpftool_gen.c create mode 100644 tools/testing/selftests/bpf/progs/test_global_percpu_data_failure.c
base-commit: 84afebd853437e44cb71f718be11d90e4c1a59dd
Signature · 1 line
2.56.1.831.g720f3f5937-goog