From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
Emil Tsalapatis <emil@etsalapatis.com>,
Justin Suess <utilityemal77@gmail.com>,
kkd@meta.com, kernel-team@meta.com
Subject: [PATCH bpf-next v2 0/4] Fix kptr dtor deadlock
Date: Tue, 9 Jun 2026 11:37:13 +0200 [thread overview]
Message-ID: <20260609093719.2858096-1-memxor@gmail.com> (raw)
Referenced kptr destruction can run from tracing/NMI contexts through
bpf_obj_drop() and map value update/delete paths, reaching NMI-unsafe
special field teardown and deadlocks. Justin reported the issue and
iterated on fixes in [0]-[2], and also confirmed the bpf_obj_drop()
reproducer in [3].
This series rejects unsafe obj drops from non-iterator tracing programs,
limits map value recycle to NMI-safe field cancellation, and adds
focused selftests for the obj_drop(), NMI delete, and recycle teardown
cases.
See patches for details.
[0]: https://lore.kernel.org/bpf/20260505150851.3090688-1-utilityemal77@gmail.com
[1]: https://lore.kernel.org/bpf/20260507175453.1140400-1-utilityemal77@gmail.com
[2]: https://lore.kernel.org/bpf/20260519011450.1144935-1-utilityemal77@gmail.com
[3]: https://lore.kernel.org/bpf/agyG3eQwgmoJwmj2@suesslenovo
Changelog:
----------
v1 -> v2
v1: https://lore.kernel.org/bpf/20260608144841.1732406-1-memxor@gmail.com
* Drop is_tracing_prog_type() fix due to compat breakage, revisit separately.
* Rework bpf_obj_drop() fix to additionally reject non-iter tracing progs.
Justin Suess (2):
bpf: Reject bpf_obj_drop() from tracing progs
bpf: Cancel special fields on map value recycle
Kumar Kartikeya Dwivedi (2):
selftests/bpf: Exercise unsafe obj drops from tracing progs
selftests/bpf: Exercise kptr map update lifetime
include/linux/bpf.h | 30 +++++++
kernel/bpf/arraymap.c | 8 +-
kernel/bpf/hashtab.c | 32 ++++---
kernel/bpf/syscall.c | 27 ++++++
kernel/bpf/verifier.c | 16 ++++
.../selftests/bpf/prog_tests/htab_update.c | 4 +-
.../selftests/bpf/prog_tests/map_kptr.c | 66 ++++++++++++--
.../selftests/bpf/prog_tests/task_kfunc.c | 42 ++++++++-
.../testing/selftests/bpf/progs/htab_update.c | 4 +-
tools/testing/selftests/bpf/progs/map_kptr.c | 89 ++++++++++++++++++-
.../selftests/bpf/progs/task_kfunc_failure.c | 43 +++++++++
.../selftests/bpf/progs/task_kfunc_success.c | 13 ++-
12 files changed, 332 insertions(+), 42 deletions(-)
base-commit: b9452b594fd3aecbfd4aa0a6a1f741330a37dab7
--
2.53.0
next reply other threads:[~2026-06-09 9:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 9:37 Kumar Kartikeya Dwivedi [this message]
2026-06-09 9:37 ` [PATCH bpf-next v2 1/4] bpf: Reject bpf_obj_drop() from tracing progs Kumar Kartikeya Dwivedi
2026-06-09 10:05 ` bot+bpf-ci
2026-06-09 13:31 ` Mykyta Yatsenko
2026-06-09 14:08 ` Kumar Kartikeya Dwivedi
2026-06-09 16:14 ` Justin Suess
2026-06-09 18:17 ` Alexei Starovoitov
2026-06-09 9:37 ` [PATCH bpf-next v2 2/4] bpf: Cancel special fields on map value recycle Kumar Kartikeya Dwivedi
2026-06-09 9:55 ` sashiko-bot
2026-06-09 10:51 ` Mykyta Yatsenko
2026-06-09 9:37 ` [PATCH bpf-next v2 3/4] selftests/bpf: Exercise unsafe obj drops from tracing progs Kumar Kartikeya Dwivedi
2026-06-09 10:02 ` sashiko-bot
2026-06-09 9:37 ` [PATCH bpf-next v2 4/4] selftests/bpf: Exercise kptr map update lifetime Kumar Kartikeya Dwivedi
2026-06-09 10:20 ` sashiko-bot
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=20260609093719.2858096-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=emil@etsalapatis.com \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=utilityemal77@gmail.com \
/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 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.