Skip to content

Use correct destructor kfunc types

Sami Tolvanen bpf lkml netdev oe-kbuild-all 5 versions – Applied

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

  1. v5 Latest4 patches 1 replyApplied 4/4
  2. v44 patches 3 repliesSuperseded
  3. v34 patches 7 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v24 patches5 repliesSuperseded
v14 patches6 repliesSuperseded

Changes in v5 from the cover letter

- Rebased on bpf-next/master again.

Patches in v5 All 4 applied

#Subject and filesSizeRepliesApplied
1/4bpf: crypto: Use the correct destructor kfunc typekernel/bpf/crypto.c+7 -10 repliesApplied
2/4bpf: net_sched: Use the correct destructor kfunc typenet/sched/bpf_qdisc.c+7 -10 repliesApplied
3/4selftests/bpf: Use the correct destructor kfunc typetools/testing/selftests/bpf/test_kmods/bpf_testmod.c+7 -10 repliesApplied
4/4bpf, btf: Enforce destructor kfunc type with CFIkernel/bpf/btf.c+7 -00 repliesApplied

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchYonghong SongViktor MalikMartin KaFai Lau
SeriesA-b
1/4A-b T-b
2/4A-b
3/4A-b
4/4A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v5 thread

Cover letter [PATCH bpf-next v5 0/4] Use correct destructor kfunc types

Hi folks,

While running BPF self-tests with CONFIG_CFI (Control Flow Integrity) enabled, I ran into a couple of 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.

Sami

---
v5:
- Rebased on bpf-next/master again.

v4: https://lore.kernel.org/bpf/[email protected]/
- Rebased on bpf-next/master.
- Renamed CONFIG_CFI_CLANG to CONFIG_CFI.
- Picked up Acked/Tested-by tags.

v3: https://lore.kernel.org/bpf/[email protected]/
- Renamed the functions and went back to __bpf_kfunc based
on review feedback.

v2: https://lore.kernel.org/bpf/[email protected]/
- Annotated the stubs with CFI_NOSEAL to fix issues with IBT
sealing on x86.
- Changed __bpf_kfunc to explicit __used __retain.

v1: https://lore.kernel.org/bpf/[email protected]/

---
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                                  | 8 +++++++-
 net/sched/bpf_qdisc.c                                | 8 +++++++-
 tools/testing/selftests/bpf/test_kmods/bpf_testmod.c | 8 +++++++-
 4 files changed, 28 insertions(+), 3 deletions(-)

base-commit: 5714ca8cba5ed736f3733663c446cbee63a10a64

Signature · 1 line
2.52.0.457.g6b5491de43-goog