From: Dave Marchevsky <davemarchevsky@fb.com>
To: <bpf@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
Kernel Team <kernel-team@fb.com>,
Dave Marchevsky <davemarchevsky@fb.com>
Subject: [PATCH v2 bpf-next 0/6] BPF Refcount followups 2: owner field
Date: Tue, 18 Jul 2023 01:38:07 -0700 [thread overview]
Message-ID: <20230718083813.3416104-1-davemarchevsky@fb.com> (raw)
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(-)
--
2.34.1
next reply other threads:[~2023-07-18 8:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 8:38 Dave Marchevsky [this message]
2023-07-18 8:38 ` [PATCH v2 bpf-next 1/6] [DONOTAPPLY] Revert "bpf: Disable bpf_refcount_acquire kfunc calls until race conditions are fixed" Dave Marchevsky
2023-07-18 8:38 ` [PATCH v2 bpf-next 2/6] bpf: Introduce internal definitions for UAPI-opaque bpf_{rb,list}_node Dave Marchevsky
2023-07-18 8:38 ` [PATCH v2 bpf-next 3/6] bpf: Add 'owner' field to bpf_{list,rb}_node Dave Marchevsky
2023-07-18 8:38 ` [PATCH v2 bpf-next 4/6] selftests/bpf: Add rbtree test exercising race which 'owner' field prevents Dave Marchevsky
2023-07-18 8:38 ` [PATCH v2 bpf-next 5/6] selftests/bpf: Disable newly-added 'owner' field test until refcount re-enabled Dave Marchevsky
2023-07-18 8:38 ` [PATCH v2 bpf-next 6/6] [DONOTAPPLY] Revert "selftests/bpf: Disable newly-added 'owner' field test until refcount re-enabled" Dave Marchevsky
2023-07-19 0:30 ` [PATCH v2 bpf-next 0/6] BPF Refcount followups 2: owner field patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230718083813.3416104-1-davemarchevsky@fb.com \
--to=davemarchevsky@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).