BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v7 0/2] bpf: Fix kfunc implicit arg injection and add selftest
@ 2026-11-23  5:57 chenyuan_fl
  2026-11-23  5:57 ` [PATCH bpf-next v7 1/2] bpf: Fix kfunc implicit arg inject type detection to prevent invalid pointer deref chenyuan_fl
  2026-11-23  5:57 ` [PATCH bpf-next v7 2/2] selftests/bpf: strengthen bpf_kfunc_implicit_arg to verify aux injection chenyuan_fl
  0 siblings, 2 replies; 6+ messages in thread
From: chenyuan_fl @ 2026-11-23  5:57 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, martin.lau, eddyz87, yonghong.song,
	ihor.solodrai, memxor, nirmoyd, Yuan Chen

From: Yuan Chen <chenyuan@kylinos.cn>

v6: https://lore.kernel.org/bpf/20260609125214.3096351-1-chenyuan_fl@163.com/

v1 made btf_types_are_same() cross-BTF aware by comparing kind, size
and name.  Alan Maguire pointed out that this would be too permissive
since two different structs can share the same name and size.

v2 used a name-based classifier (get_kfunc_arg_inject_type).

v3 splits the combined is_kfunc_arg_ignore || is_kfunc_arg_implicit
check in check_kfunc_args(), so that an implicit argument reaching
is_kfunc_arg_implicit() without any prior handler is rejected with
-EFAULT instead of silently skipped (Eduard Zingerman).  This prevents
the silent fallthrough that occurred when module BTF was inconsistent
with vmlinux (e.g. pahole 1.30 breaking distilled base dedup).

v4: fix a build error in the selftest.

v5 changes:
- Patch 1: extend the kfunc allow-list to cover all KF_IMPLICIT_ARGS
  kfuncs handled in bpf_fixup_kfunc_call(): obj_new, percpu_obj_new,
  obj_drop, percpu_obj_drop, refcount_acquire, list_push, rbtree_add.
- Patch 2: simplify the selftest by verifying aux->name in
  bpf_kfunc_implicit_arg() instead of adding a separate struct_ops
  test program with inline assembly.

v6 changes:
- Patch 1: fix comment formatting to follow kernel style (Eduard
  Zingerman).

v7 changes:
- Rebase onto bpf-next.  The argument check now lives in
  get_kfunc_arg_type(), so the fix is applied there.
- Restore the Acked-by tag from Eduard Zingerman that was dropped in
  v6.
- Patch 2: verify the aux->prog backlink instead of matching aux->name.
  The tracing selftest added in 0af15f30 calls the same kfunc from
  programs named trace_implicit_arg_*, so a name prefix check would
  make it fail.

The v6 CI build errors came from applying the series to the bpf tree:
argno and reg_arg_name() were introduced by bpf-next 9b9f0b42703c,
on which this series is based.

v6 was tested by Nirmoy Das on a kernel with a module BTF mismatch:
the unpatched kernel oopsed and v6 rejected the program at load time.

Yuan Chen (2):
  bpf: Fix kfunc implicit arg inject type detection to prevent invalid
    pointer deref
  selftests/bpf: strengthen bpf_kfunc_implicit_arg to verify aux injection

 kernel/bpf/verifier.c                              | 20 +++++++++++++++++++-
 .../testing/selftests/bpf/test_kmods/bpf_testmod.c |  8 +++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-23  6:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  5:57 [PATCH bpf-next v7 0/2] bpf: Fix kfunc implicit arg injection and add selftest chenyuan_fl
2026-11-23  5:57 ` [PATCH bpf-next v7 1/2] bpf: Fix kfunc implicit arg inject type detection to prevent invalid pointer deref chenyuan_fl
2026-11-23  6:09   ` sashiko-bot
2026-11-23  6:34   ` bot+bpf-ci
2026-11-23  5:57 ` [PATCH bpf-next v7 2/2] selftests/bpf: strengthen bpf_kfunc_implicit_arg to verify aux injection chenyuan_fl
2026-11-23  6:10   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox