libbpf: Skip host /proc/kallsyms for typeless ksyms in gen_loader
Status from this message: This series was applied to bpf/bpf-next.git (master)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 0 repliesApplied 2/2
- v12 patches 1 replySuperseded
Changes in v2 from the cover letter
- Patch 1: Short-circuit all EXT_KSYM entries directly in bpf_object__resolve_externs() (removing the redundant check in bpf_object__resolve_ksyms_btf_id() and avoiding renaming bpf_object__read_kallsyms_file()), per Alexei's suggestion.
- Patch 1: Drop the Fixes: tag.
Patches in v2 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | libbpf: Skip reading /proc/kallsyms for typeless ksyms in gen_loadertools/ tools/ | +8 | 0 replies | Applied |
| 2/2 | selftests/bpf: Test missing strong typeless ksym in light skeletontools/ tools/ tools/ | +37 | 0 replies | Applied |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH bpf-next v2 0/2] libbpf: Skip host /proc/kallsyms for typeless ksyms in gen_loader
When generating a light skeleton / loader program via bpf_object__gen_loader(), libbpf is supposed to defer kernel symbol resolution to the target kernel at load time rather than consulting the build host. Typed ksyms and kfuncs already short-circuit on obj->gen_loader in bpf_object__resolve_ksyms_btf_id(), but bpf_object__resolve_externs() still reads the build host's /proc/kallsyms for typeless ksyms.
This breaks offline loader generation in sandboxed environments, rejects strong typeless ksyms that exist only on the target kernel, and leaks host symbol addresses into the generated loader data blob even though emit_relo_ksym_typeless() overwrites them at load time via bpf_kallsyms_lookup_name().
Patch 1 short-circuits all EXT_KSYM entries in bpf_object__resolve_externs() when obj->gen_loader is set (dropping the now redundant obj->gen_loader check in bpf_object__resolve_ksyms_btf_id()), and makes emit_relo_ksym_typeless() ignore -ENOENT only for weak ksyms so missing strong typeless ksyms still fail at load time on the target kernel.
Patch 2 adds a test_ksyms_strong_typeless light skeleton and ksyms_btf/strong_typeless_lskel selftest verifying that light skeleton generation succeeds for a missing strong typeless ksym and loading it fails with -ENOENT on the target kernel.
Changes in v2:
- Patch 1: Short-circuit all EXT_KSYM entries directly in bpf_object__resolve_externs() (removing the redundant check in bpf_object__resolve_ksyms_btf_id() and avoiding renaming bpf_object__read_kallsyms_file()), per Alexei's suggestion.
- Patch 1: Drop the Fixes: tag.
Thiébaud Weksteen (2):
libbpf: Skip reading /proc/kallsyms for typeless ksyms in gen_loader selftests/bpf: Test missing strong typeless ksym in light skeleton
tools/lib/bpf/gen_loader.c | 6 ++++-- tools/lib/bpf/libbpf.c | 11 ++++------- tools/testing/selftests/bpf/Makefile.skel | 3 ++- .../selftests/bpf/prog_tests/ksyms_btf.c | 19 +++++++++++++++++++ .../bpf/progs/test_ksyms_strong_typeless.c | 16 ++++++++++++++++ 5 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/test_ksyms_strong_typeless.c
base-commit: ac69c149f965b55e85798e516cb66e2bceb63f00
Signature · 1 line
2.56.1.987.g2ec0ab4260-goog