All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 0/3] Update KF_RCU_PROTECTED, add KF_RET_RCU
@ 2025-09-15  2:47 Kumar Kartikeya Dwivedi
  2025-09-15  2:47 ` [PATCH bpf-next v1 1/3] bpf: Enforce RCU protection for KF_RCU_PROTECTED Kumar Kartikeya Dwivedi
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2025-09-15  2:47 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Martin KaFai Lau, Eduard Zingerman, Tejun Heo, Andrea Righi, kkd,
	kernel-team

Currently, KF_RCU_PROTECTED only applies to iterator APIs and that too
in a convoluted fashion: the presence of this flag on the kfunc is used
to set MEM_RCU in iterator type, and the lack of RCU protection results
in an error only later, once next() or destroy() methods are invoked on
the iterator. While there is no bug, this is certainly a bit unintuitive,
and makes the enforcement of the flag iterator specific.

In the interest of making this flag useful for other upcoming kfuncs,
e.g. scx_bpf_cpu_curr() [0][1], add enforcement for invoking the kfunc
in an RCU critical section in general.

In addition to this, the aforementioned kfunc also needs to return an
RCU protected pointer, which currently has no generic kfunc flag or
annotation. Add such a flag as well while we are at it.

  [0]: https://lore.kernel.org/all/20250903212311.369697-3-christian.loehle@arm.com
  [1]: https://lore.kernel.org/all/20250909195709.92669-1-arighi@nvidia.com

Kumar Kartikeya Dwivedi (3):
  bpf: Enforce RCU protection for KF_RCU_PROTECTED
  bpf: Add support for KF_RET_RCU flag
  selftests/bpf: Add tests for KF_RET_RCU

 Documentation/bpf/kfuncs.rst                  | 24 +++++++++++++++++--
 include/linux/btf.h                           |  1 +
 kernel/bpf/verifier.c                         | 12 ++++++++++
 .../selftests/bpf/progs/cgroup_read_xattr.c   |  2 +-
 .../selftests/bpf/progs/iters_task_failure.c  |  4 ++--
 .../selftests/bpf/progs/iters_testmod.c       | 23 ++++++++++++++++++
 .../selftests/bpf/test_kmods/bpf_testmod.c    |  6 +++++
 .../bpf/test_kmods/bpf_testmod_kfunc.h        |  1 +
 8 files changed, 68 insertions(+), 5 deletions(-)


base-commit: a578b54a8ad282dd739e4d1f4e8352fc8ac1c4a0
-- 
2.51.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-09-17  2:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15  2:47 [PATCH bpf-next v1 0/3] Update KF_RCU_PROTECTED, add KF_RET_RCU Kumar Kartikeya Dwivedi
2025-09-15  2:47 ` [PATCH bpf-next v1 1/3] bpf: Enforce RCU protection for KF_RCU_PROTECTED Kumar Kartikeya Dwivedi
2025-09-15  2:47 ` [PATCH bpf-next v1 2/3] bpf: Add support for KF_RET_RCU flag Kumar Kartikeya Dwivedi
2025-09-15  6:14   ` Andrea Righi
2025-09-15  7:13     ` Kumar Kartikeya Dwivedi
2025-09-15  8:02       ` Andrea Righi
2025-09-15 17:55         ` Alexei Starovoitov
2025-09-17  2:18           ` Kumar Kartikeya Dwivedi
2025-09-15  2:47 ` [PATCH bpf-next v1 3/3] selftests/bpf: Add tests for KF_RET_RCU Kumar Kartikeya Dwivedi
2025-09-15 12:20 ` [PATCH bpf-next v1 0/3] Update KF_RCU_PROTECTED, add KF_RET_RCU Andrea Righi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.