From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: kkd@meta.com, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
kernel-team@fb.com
Subject: [PATCH bpf-next v1 0/3] Fix resource leak checks for tail calls
Date: Sun, 3 Nov 2024 14:59:37 -0800 [thread overview]
Message-ID: <20241103225940.1408302-1-memxor@gmail.com> (raw)
This set contains a fix for detecting unreleased RCU read locks or
unfinished preempt_disable sections when performing a tail call. Spin
locks are prevented by accident since they don't allow any function
calls, including tail calls (modelled as call instruction to a helper),
so we ensure they are checked as well, in preparation for relaxing
function call restricton for critical sections in the future.
Then, in the second patch, all the checks for reference leaks and locks
are unified into a single function that can be called from different
places. This unification patch is kept separate and placed after the fix
to allow independent backport of the fix to older kernels without a
depdendency on the clean up.
Naturally, this creates a divergence in the disparate error messages,
therefore selftests that rely on the exact error strings need to be
updated to match the new verifier log message.
A selftest is included to ensure no regressions occur wrt this behavior.
Kumar Kartikeya Dwivedi (3):
bpf: Tighten tail call checks for lingering locks, RCU,
preempt_disable
bpf: Unify resource leak checks
selftests/bpf: Add tests for tail calls with locks and refs
kernel/bpf/verifier.c | 75 +++++++++----------
.../selftests/bpf/prog_tests/tailcalls.c | 8 ++
.../selftests/bpf/progs/exceptions_fail.c | 4 +-
.../selftests/bpf/progs/preempt_lock.c | 14 ++--
.../selftests/bpf/progs/tailcall_fail.c | 64 ++++++++++++++++
.../bpf/progs/verifier_ref_tracking.c | 4 +-
.../selftests/bpf/progs/verifier_spin_lock.c | 2 +-
7 files changed, 118 insertions(+), 53 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/tailcall_fail.c
base-commit: 77017b9c46820d72596e50a3986bd0734c1340a9
--
2.43.5
next reply other threads:[~2024-11-03 22:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-03 22:59 Kumar Kartikeya Dwivedi [this message]
2024-11-03 22:59 ` [PATCH bpf-next v1 1/3] bpf: Tighten tail call checks for lingering locks, RCU, preempt_disable Kumar Kartikeya Dwivedi
2024-11-03 22:59 ` [PATCH bpf-next v1 2/3] bpf: Unify resource leak checks Kumar Kartikeya Dwivedi
2024-11-03 22:59 ` [PATCH bpf-next v1 3/3] selftests/bpf: Add tests for tail calls with locks and refs Kumar Kartikeya Dwivedi
2024-11-04 1:00 ` [PATCH bpf-next v1 0/3] Fix resource leak checks for tail calls 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=20241103225940.1408302-1-memxor@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@fb.com \
--cc=kkd@meta.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