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>,
Nicholas Carlini <npc@anthropic.com>,
kkd@meta.com, kernel-team@meta.com
Subject: [PATCH bpf v1 5/8] bpf: Mark faultable stack helpers as sleepable
Date: Thu, 3 Sep 2026 23:47:51 +0200 [thread overview]
Message-ID: <20260903214758.2727663-6-memxor@gmail.com> (raw)
In-Reply-To: <20260903214758.2727663-1-memxor@gmail.com>
The faultable variants of bpf_get_stack() and bpf_get_task_stack() pass
may_fault=true into the common stack collection code. Resolving user-space
build IDs may then call build_id_parse_file() and block on filesystem
reads.
Neither helper prototype sets might_sleep. Since prototype selection uses
the sleepability of the whole program, the verifier can still allow these
helpers from a non-sleepable region within that program, such as an
explicit RCU or preemption-disabled region. The task-stack helper can also
be called from a non-sleepable timer callback of a sleepable program.
Mark both faultable prototypes as sleepable. The existing helper context
check then rejects these calls while continuing to allow them in genuinely
sleepable contexts.
Fixes: d4dd9775ec24 ("bpf: wire up sleepable bpf_get_stack() and bpf_get_task_stack() helpers")
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
kernel/bpf/stackmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index a839041e0d00..d09d4c3fe547 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -875,6 +875,7 @@ BPF_CALL_4(bpf_get_stack_sleepable, struct pt_regs *, regs, void *, buf, u32, si
const struct bpf_func_proto bpf_get_stack_sleepable_proto = {
.func = bpf_get_stack_sleepable,
.gpl_only = true,
+ .might_sleep = true,
.ret_type = RET_INTEGER,
.arg1_type = ARG_PTR_TO_CTX,
.arg2_type = ARG_PTR_TO_UNINIT_MEM,
@@ -928,6 +929,7 @@ BPF_CALL_4(bpf_get_task_stack_sleepable, struct task_struct *, task, void *, buf
const struct bpf_func_proto bpf_get_task_stack_sleepable_proto = {
.func = bpf_get_task_stack_sleepable,
.gpl_only = false,
+ .might_sleep = true,
.ret_type = RET_INTEGER,
.arg1_type = ARG_PTR_TO_BTF_ID,
.arg1_btf_id = &btf_tracing_ids[BTF_TRACING_TYPE_TASK],
--
2.53.0
next prev parent reply other threads:[~2026-09-03 21:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 21:47 [PATCH bpf v1 0/8] Misc bug fixes - part 2 Kumar Kartikeya Dwivedi
2026-09-03 21:47 ` [PATCH bpf v1 1/8] bpf: Check ancestor frames for rbtree callbacks Kumar Kartikeya Dwivedi
2026-09-03 22:40 ` Eduard Zingerman
2026-09-03 22:56 ` bot+bpf-ci
2026-09-03 21:47 ` [PATCH bpf v1 2/8] selftests/bpf: Check rbtree callback restrictions in subprogs Kumar Kartikeya Dwivedi
2026-09-03 22:56 ` bot+bpf-ci
2026-09-03 21:47 ` [PATCH bpf v1 3/8] bpf: Mark bpf_btf_find_by_name_kind() as sleepable Kumar Kartikeya Dwivedi
2026-09-03 22:15 ` Eduard Zingerman
2026-09-03 21:47 ` [PATCH bpf v1 4/8] selftests/bpf: Test btf lookup helper sleepability Kumar Kartikeya Dwivedi
2026-09-03 21:47 ` Kumar Kartikeya Dwivedi [this message]
2026-09-03 22:00 ` [PATCH bpf v1 5/8] bpf: Mark faultable stack helpers as sleepable Eduard Zingerman
2026-09-03 22:56 ` bot+bpf-ci
2026-09-03 21:47 ` [PATCH bpf v1 6/8] selftests/bpf: Check faultable stack helper contexts Kumar Kartikeya Dwivedi
2026-09-03 22:56 ` bot+bpf-ci
2026-09-03 21:47 ` [PATCH bpf v1 7/8] bpf: Reject legacy packet loads from callbacks Kumar Kartikeya Dwivedi
2026-09-03 21:58 ` Eduard Zingerman
2026-09-04 2:22 ` Alexei Starovoitov
2026-09-03 21:47 ` [PATCH bpf v1 8/8] selftests/bpf: " Kumar Kartikeya Dwivedi
2026-09-04 2:30 ` [PATCH bpf v1 0/8] Misc bug fixes - part 2 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=20260903214758.2727663-6-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=npc@anthropic.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox