Skip to content

bpf: Handle MEM_RCU type properly

Yonghong Song 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]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 0 repliesApplied 3/3
  2. v11 patch 5 repliesSuperseded

Changes in v2 from the cover letter

- rcu ptr could be NULL.
- non_null_rcu_ptr->rcu_field can be marked as MEM_RCU as well.
- Adjust the code to avoid existing error message change.

Patches in v2 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpf: Handle MEM_RCU type properlyinclude/linux/bpf_verifier.h include/linux/btf.h kernel/bpf/helpers.c +1 more+48 -140 repliesApplied
2/3selftests/bpf: Fix rcu_read_lock test with new MEM_RCU semanticstools/testing/selftests/bpf/progs/rcu_read_lock.c+45 -100 repliesApplied
3/3docs/bpf: Add KF_RCU documentationDocumentation/bpf/kfuncs.rst+9 -00 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH bpf-next v2 0/3] bpf: Handle MEM_RCU type properly

Patch set [1] added rcu support for bpf programs. In [1], a rcu pointer is considered to be trusted and not null. This is actually not true in some cases. The rcu pointer could be null, and for non-null rcu pointer, it may have reference count of 0. This small patch set fixed this problem. Patch 1 is the kernel fix. Patch 2 adjusted selftests properly. Patch 3 added documentation for newly-introduced KF_RCU flag.

[1] https://lore.kernel.org/all/[email protected]/

Changelogs:
v1 -> v2:
- rcu ptr could be NULL.
- non_null_rcu_ptr->rcu_field can be marked as MEM_RCU as well.
- Adjust the code to avoid existing error message change.

Yonghong Song (3):
bpf: Handle MEM_RCU type properly
selftests/bpf: Fix rcu_read_lock test with new MEM_RCU semantics docs/bpf: Add KF_RCU documentation

 Documentation/bpf/kfuncs.rst                  |  9 +++
 include/linux/bpf_verifier.h                  |  2 +-
 include/linux/btf.h                           |  1 +
 kernel/bpf/helpers.c                          | 14 +++++
 kernel/bpf/verifier.c                         | 45 ++++++++++-----
 .../selftests/bpf/progs/rcu_read_lock.c       | 55 +++++++++++++++----
 6 files changed, 102 insertions(+), 24 deletions(-)
Signature · 1 line
2.30.2