[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250724223225.1481960-6-samitolvanen@google.com>
Date: Thu, 24 Jul 2025 22:32:26 +0000
From: Sami Tolvanen <samitolvanen@...gle.com>
To: bpf@...r.kernel.org
Cc: Vadim Fedorenko <vadim.fedorenko@...ux.dev>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Sami Tolvanen <samitolvanen@...gle.com>
Subject: [PATCH bpf-next 0/4] Use correct destructor kfunc types
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
Powered by blists - more mailing lists