mbox series

[v2,bpf-next,0/6] BPF Refcount followups 2: owner field

Message ID 20230718083813.3416104-1-davemarchevsky@fb.com (mailing list archive)
Headers show
Series BPF Refcount followups 2: owner field | expand

Message

Dave Marchevsky July 18, 2023, 8:38 a.m. UTC
This series adds an 'owner' field to bpf_{list,rb}_node structs, to be
used by the runtime to determine whether insertion or removal operations
are valid in shared ownership scenarios. Both the races which the series
fixes and the fix itself are inspired by Kumar's suggestions in [0].

Aside from insertion and removal having more reasons to fail, there are
no user-facing changes as a result of this series.

* Patch 1 reverts disabling of bpf_refcount_acquire so that the fixed
logic can be exercised by CI. It should _not_ be applied.
* Patch 2 adds internal definitions of bpf_{rb,list}_node so that
their fields are easier to access.
* Patch 3 is the meat of the series - it adds 'owner' field and
enforcement of correct owner to insertion and removal helpers.
* Patch 4 adds a test based on Kumar's examples.
* Patch 5 disables the test until bpf_refcount_acquire is re-enabled.
* Patch 6 reverts disabling of test added in this series
logic can be exercised by CI. It should _not_ be applied.

  [0]: https://lore.kernel.org/bpf/d7hyspcow5wtjcmw4fugdgyp3fwhljwuscp3xyut5qnwivyeru@ysdq543otzv2/

Changelog:

v1 -> v2: lore.kernel.org/bpf/20230711175945.3298231-1-davemarchevsky@fb.com/

Patch 2 ("Introduce internal definitions for UAPI-opaque bpf_{rb,list}_node")
  * Rename bpf_{rb,list}_node_internal -> bpf_{list,rb}_node_kern (Alexei)

Patch 3 ("bpf: Add 'owner' field to bpf_{list,rb}_node")
  * WARN_ON_ONCE in __bpf_list_del when node has wrong owner. This shouldn't
    happen, but worth checking regardless (Alexei, offline convo)
  * Continue previous patch's renaming changes

Dave Marchevsky (6):
  [DONOTAPPLY] Revert "bpf: Disable bpf_refcount_acquire kfunc calls
    until race conditions are fixed"
  bpf: Introduce internal definitions for UAPI-opaque bpf_{rb,list}_node
  bpf: Add 'owner' field to bpf_{list,rb}_node
  selftests/bpf: Add rbtree test exercising race which 'owner' field
    prevents
  selftests/bpf: Disable newly-added 'owner' field test until refcount
    re-enabled
  [DONOTAPPLY] Revert "selftests/bpf: Disable newly-added 'owner' field
    test until refcount re-enabled"

 include/linux/bpf.h                           | 12 +++
 include/uapi/linux/bpf.h                      |  2 +
 kernel/bpf/helpers.c                          | 50 +++++++---
 kernel/bpf/verifier.c                         |  5 +-
 .../selftests/bpf/prog_tests/linked_list.c    | 78 +++++++--------
 .../bpf/prog_tests/refcounted_kptr.c          | 30 ++++++
 .../selftests/bpf/progs/refcounted_kptr.c     | 94 ++++++++++++++++++-
 7 files changed, 214 insertions(+), 57 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org July 19, 2023, 12:30 a.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue, 18 Jul 2023 01:38:07 -0700 you wrote:
> This series adds an 'owner' field to bpf_{list,rb}_node structs, to be
> used by the runtime to determine whether insertion or removal operations
> are valid in shared ownership scenarios. Both the races which the series
> fixes and the fix itself are inspired by Kumar's suggestions in [0].
> 
> Aside from insertion and removal having more reasons to fail, there are
> no user-facing changes as a result of this series.
> 
> [...]

Here is the summary with links:
  - [v2,bpf-next,1/6,DONOTAPPLY] Revert "bpf: Disable bpf_refcount_acquire kfunc calls until race conditions are fixed"
    (no matching commit)
  - [v2,bpf-next,2/6] bpf: Introduce internal definitions for UAPI-opaque bpf_{rb,list}_node
    https://git.kernel.org/bpf/bpf-next/c/0a1f7bfe35a3
  - [v2,bpf-next,3/6] bpf: Add 'owner' field to bpf_{list,rb}_node
    https://git.kernel.org/bpf/bpf-next/c/c3c510ce431c
  - [v2,bpf-next,4/6] selftests/bpf: Add rbtree test exercising race which 'owner' field prevents
    https://git.kernel.org/bpf/bpf-next/c/fdf48dc2d054
  - [v2,bpf-next,5/6] selftests/bpf: Disable newly-added 'owner' field test until refcount re-enabled
    https://git.kernel.org/bpf/bpf-next/c/f3514a5d6740
  - [v2,bpf-next,6/6,DONOTAPPLY] Revert "selftests/bpf: Disable newly-added 'owner' field test until refcount re-enabled"
    (no matching commit)

You are awesome, thank you!