bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/4] Use correct destructor kfunc types
@ 2025-07-24 22:32 Sami Tolvanen
  2025-07-24 22:32 ` [PATCH bpf-next 1/4] bpf: crypto: Use the correct destructor kfunc type Sami Tolvanen
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Sami Tolvanen @ 2025-07-24 22:32 UTC (permalink / raw)
  To: bpf
  Cc: Vadim Fedorenko, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
	netdev, linux-kernel, Sami Tolvanen

Hi folks,

While running BPF self-tests with CONFIG_CFI_CLANG (Clang Control
Flow Integrity) enabled, I ran into a couple of CFI failures
in bpf_obj_free_fields() caused by type mismatches between
the btf_dtor_kfunc_t function pointer type and the registered
destructor functions.

It looks like we can't change the argument type for these
functions to match btf_dtor_kfunc_t because the verifier doesn't
like void pointer arguments for functions used in BPF programs,
so this series fixes the issue by adding stubs with correct types
to use as destructors for each instance of this I found in the
kernel tree.

The last patch changes btf_check_dtor_kfuncs() to enforce the
function type when CFI is enabled, so we don't end up registering
destructors that panic the kernel. Perhaps this is something we
could enforce even without CONFIG_CFI_CLANG?

Sami

---

Sami Tolvanen (4):
  bpf: crypto: Use the correct destructor kfunc type
  bpf: net_sched: Use the correct destructor kfunc type
  selftests/bpf: Use the correct destructor kfunc type
  bpf, btf: Enforce destructor kfunc type with CFI

 kernel/bpf/btf.c                                     | 7 +++++++
 kernel/bpf/crypto.c                                  | 7 ++++++-
 net/sched/bpf_qdisc.c                                | 7 ++++++-
 tools/testing/selftests/bpf/test_kmods/bpf_testmod.c | 7 ++++++-
 4 files changed, 25 insertions(+), 3 deletions(-)


base-commit: 95993dc3039e29dabb9a50d074145d4cb757b08b
-- 
2.50.1.470.g6ba607880d-goog


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

end of thread, other threads:[~2025-07-25 17:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 22:32 [PATCH bpf-next 0/4] Use correct destructor kfunc types Sami Tolvanen
2025-07-24 22:32 ` [PATCH bpf-next 1/4] bpf: crypto: Use the correct destructor kfunc type Sami Tolvanen
2025-07-25 16:13   ` Yonghong Song
2025-07-24 22:32 ` [PATCH bpf-next 2/4] bpf: net_sched: " Sami Tolvanen
2025-07-24 22:32 ` [PATCH bpf-next 3/4] selftests/bpf: " Sami Tolvanen
2025-07-24 22:32 ` [PATCH bpf-next 4/4] bpf, btf: Enforce destructor kfunc type with CFI Sami Tolvanen
2025-07-25 16:05 ` [PATCH bpf-next 0/4] Use correct destructor kfunc types Yonghong Song
2025-07-25 16:22   ` Sami Tolvanen
2025-07-25 16:54     ` Yonghong Song
2025-07-25 17:20       ` Sami Tolvanen
2025-07-25 17:48         ` Yonghong Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).