Skip to content

bpf: Unify special map field validation in verifier

Mykyta Yatsenko bpf 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected] change-id 20260129-verif_special_fields-599a67d10425

Versions newest first

  1. v2 Latest2 patches 0 repliesApplied 2/2
  2. v12 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- Added Signed-off-by to the top commit.
- Link to v1: https://lore.kernel.org/r/[email protected]

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Introduce struct bpf_map_desc in verifierkernel/bpf/verifier.c+40 -390 repliesApplied
2/2bpf: Consolidate special map field validation in verifierkernel/bpf/verifier.c+11 -590 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchEduard Zingerman
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH bpf-next v2 0/2] bpf: Unify special map field validation in verifier

The BPF verifier validates pointers to special map fields (timers, workqueues, task_work) through separate functions that share nearly identical logic. This creates code duplication because of the inconsistent data structure layout in struct bpf_call_arg_meta struct bpf_kfunc_call_arg_meta.

This series contains 2 commits:

1. Introduces struct bpf_map_desc to provide a unified representation for map pointer and uid tracking. Previously, bpf_call_arg_meta used separate map_ptr and map_uid fields while bpf_kfunc_call_arg_metaused an anonymous inline struct. This inconsistency made it harder to share validation code between the two paths.

2. Consolidates the validation logic for BPF_TIMER, BPF_WORKQUEUE, and BPF_TASK_WORK field types into a single check_map_field_pointer() function. This eliminates process_wq_func() and process_task_work_func() entirely, and simplifies process_timer_func() to just the PREEMPT_RT check before calling the unified validation. The result is fewer lines of code with clearer structure for future maintenance.

---
Changes in v2:
- Added Signed-off-by to the top commit.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Mykyta Yatsenko (2):
bpf: Introduce struct bpf_map_desc in verifier
bpf: Consolidate special map field validation in verifier

 kernel/bpf/verifier.c | 143 +++++++++++++++++---------------------------------
 1 file changed, 48 insertions(+), 95 deletions(-)

---
base-commit: ae23bc81ddf7c17b663c4ed1b21e35527b0a7131
change-id: 20260129-verif_special_fields-599a67d10425

Best regards,

Signature · 1 line
Mykyta Yatsenko <[email protected]>