Skip to content

Remove use of current->cgns in bpf_cgroup_from_id

Kumar Kartikeya Dwivedi bpf 3 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. v3 Latest2 patches 3 repliesApplied 2/2
  2. v22 patches 4 repliesSuperseded
  3. v12 patches 3 repliesSuperseded

Changes in v3 from the cover letter

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

* Refactor cgroup_get_from_id into non-ns version. (Andrii)
* Address nits from Eduard.

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Do not limit bpf_cgroup_from_id to current's namespaceinclude/linux/cgroup.h kernel/bpf/helpers.c kernel/cgroup/cgroup.c+22 -53 repliesApplied
2/2selftests/bpf: Add a test for bpf_cgroup_from_id lookup in non-root cgnstools/testing/selftests/bpf/cgroup_helpers.c tools/testing/selftests/bpf/cgroup_helpers.h tools/testing/selftests/bpf/prog_tests/cgrp_kfunc.c +1 more+104 -00 repliesApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchTejun Heo
1/2A-b
2/2

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

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/2] Remove use of current->cgns in bpf_cgroup_from_id

bpf_cgroup_from_id currently ends up doing a check on whether the cgroup being looked up is a descendant of the root cgroup of the current task's cgroup namespace. This leads to unreliable results since this kfunc can be invoked from any arbitrary context, for any arbitrary value of current. Fix this by removing namespace-awarness in the kfunc, and include a test that detects such a case and fails without the fix.

Changelog:
----------
v2 -> v3
v2: https://lore.kernel.org/bpf/[email protected]

* Refactor cgroup_get_from_id into non-ns version. (Andrii)
* Address nits from Eduard.

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

* Add Ack from Tejun.
* Fix selftest to perform namespace migration and cgroup setup in a child process to avoid changing test_progs namespace.

Kumar Kartikeya Dwivedi (2):
bpf: Do not limit bpf_cgroup_from_id to current's namespace selftests/bpf: Add a test for bpf_cgroup_from_id lookup in non-root
cgns

 include/linux/cgroup.h                        |  1 +
 kernel/bpf/helpers.c                          |  2 +-
 kernel/cgroup/cgroup.c                        | 24 +++++--
 tools/testing/selftests/bpf/cgroup_helpers.c  | 20 ++++++
 tools/testing/selftests/bpf/cgroup_helpers.h  |  1 +
 .../selftests/bpf/prog_tests/cgrp_kfunc.c     | 71 +++++++++++++++++++
 .../selftests/bpf/progs/cgrp_kfunc_success.c  | 12 ++++
 7 files changed, 126 insertions(+), 5 deletions(-)

base-commit: a578b54a8ad282dd739e4d1f4e8352fc8ac1c4a0

Signature · 1 line
2.51.0