Skip to content

Fix effective prog array indexing with BPF_F_PREORDER

Amery Hung bpf sashiko-reviews 2 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesApplied 2/2
  2. v12 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Also fix purge_effective_progs(), in addition to replace_effective_prog() (Sashiko).
- selftest: Set err on bpf_link_create() failure so the failure is reported to the caller (Sashiko).

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Fix effective prog array index with BPF_F_PREORDERkernel/bpf/cgroup.c+62 -462 repliesApplied
2/2selftests/bpf: Test cgroup link replace with BPF_F_PREORDERtools/testing/selftests/bpf/prog_tests/cgroup_preorder.c+77 -01 replyApplied

Reviews trailers per patch

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

PatchYonghong Song
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 v2 0/2] Fix effective prog array indexing with BPF_F_PREORDER

Hi,

This patchset fixes a cgroup effective-array indexing bug where replace_effective_prog() and purge_effective_progs() used a linear hlist position that doesn't match the array layout when BPF_F_PREORDER programs are present, corrupting the array on link update and risking a use-after-free in the detach fallback. It computes the slot via a shared effective_prog_pos() helper and adds a cgroup_preorder selftest.

Changelog

v1 -> v2:
- Also fix purge_effective_progs(), in addition to replace_effective_prog() (Sashiko).
- selftest: Set err on bpf_link_create() failure so the failure is reported to the caller (Sashiko).

---

Amery Hung (2):
bpf: Fix effective prog array index with BPF_F_PREORDER selftests/bpf: Test cgroup link replace with BPF_F_PREORDER

 kernel/bpf/cgroup.c                           | 108 ++++++++++--------
 .../bpf/prog_tests/cgroup_preorder.c          |  77 +++++++++++++
 2 files changed, 139 insertions(+), 46 deletions(-)
Signature · 1 line
2.53.0-Meta