bpf: Fix tracing of kfuncs with implicit args
Status from this message: This series was applied to bpf/bpf.git (master)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 0 repliesApplied 2/2
- v22 patches 6 repliesSuperseded
- v12 patches 5 repliesSuperseded
Changes in v3 from the cover letter
* Replace btf_kfunc_accumulated_flags() with btf_kfunc_check_flag() following a discussion with Eduard. Inlining the hook walk is a worse option than a helper, because BTF_KFUNC_HOOK_MAX and co are internal to btf.c and exposing them is uglier.
* remove reduntant btf_is_func check (Jiri)
* formatting nit (Eduard)
v2: https://lore.kernel.org/bpf/[email protected]/
Patches in v3 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf: Fix tracing of kfuncs with implicit argsinclude/ kernel/ kernel/ | +83 | 0 replies | Applied |
| 2/2 | selftests/bpf: Cover tracing implicit kfunc argstools/ tools/ | +113 | 0 replies | Applied |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH bpf v3 0/2] bpf: Fix tracing of kfuncs with implicit args
Tejun reported an issue where a BPF program tracing a kfunc with KF_IMPLICIT_ARGS can crash the kernel [1]. This is caused by a bug in bpf_check_attach_target(): the btf_func_model for such a kfunc is computed from a wrong BTF prototype. For more details see the commit message of patch #1.
The second patch adds a selftest that can catch this situation.
The fix is a candidate for 7.1 backport.
[1] https://github.com/sched-ext/scx/issues/3687#issuecomment-4906694106
---
v2->v3:
* Replace btf_kfunc_accumulated_flags() with btf_kfunc_check_flag() following a discussion with Eduard. Inlining the hook walk is a worse option than a helper, because BTF_KFUNC_HOOK_MAX and co are internal to btf.c and exposing them is uglier.
* remove reduntant btf_is_func check (Jiri)
* formatting nit (Eduard)
v2: https://lore.kernel.org/bpf/[email protected]/
v1->v2:
* Take a module reference in btf_attach_func_proto() around the btf_kfunc_accumulated_flags() call (sashiko)
v1: https://lore.kernel.org/bpf/[email protected]/
---
Ihor Solodrai (1):
bpf: Fix tracing of kfuncs with implicit args
Kumar Kartikeya Dwivedi (1):
selftests/bpf: Cover tracing implicit kfunc args
include/linux/btf.h | 1 + kernel/bpf/btf.c | 29 +++++++ kernel/bpf/verifier.c | 66 ++++++++++++---- .../prog_tests/kfunc_implicit_args_tracing.c | 36 +++++++++ .../bpf/progs/kfunc_implicit_args_tracing.c | 77 +++++++++++++++++++ 5 files changed, 196 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/kfunc_implicit_args_tracing.c create mode 100644 tools/testing/selftests/bpf/progs/kfunc_implicit_args_tracing.c
Signature · 1 line
2.55.0