From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v1 09/10] bpf: Mark syscall helpers as sleepable
Date: Thu, 03 Sep 2026 15:51:50 +0000 [thread overview]
Message-ID: <20260903155150.D57251F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903144433.1716731-10-memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] bpf_btf_find_by_name_kind_proto lacks .might_sleep = true, allowing arbitrary FD injection via softirq.
--
commit 1d16e876066d61c09bcc6698ca694cdf8336d52c
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>
bpf: Mark syscall helpers as sleepable
This commit adds the .might_sleep = true constraint to the bpf_sys_bpf and
bpf_sys_close helper prototypes. This ensures the verifier rejects them from
non-sleepable contexts, such as bpf_timer callbacks registered within a
BPF_PROG_TYPE_SYSCALL program.
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 6874ba1424af0..c7bc9ba9b331f 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -6568,6 +6568,7 @@ EXPORT_SYMBOL_NS(kern_sys_bpf, "BPF_INTERNAL");
> static const struct bpf_func_proto bpf_sys_bpf_proto = {
> .func = bpf_sys_bpf,
> .gpl_only = false,
> + .might_sleep = true,
> .ret_type = RET_INTEGER,
> .arg1_type = ARG_ANYTHING,
> .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
> .arg3_type = ARG_MEM_SIZE,
> };
> @@ -6593,6 +6594,7 @@ BPF_CALL_1(bpf_sys_close, u32, fd)
> static const struct bpf_func_proto bpf_sys_close_proto = {
> .func = bpf_sys_close,
> .gpl_only = false,
> + .might_sleep = true,
> .ret_type = RET_INTEGER,
> .arg1_type = ARG_ANYTHING,
> };
[Severity: High]
This isn't a bug introduced by this patch, but does
bpf_btf_find_by_name_kind_proto also need to be marked as sleepable?
Looking at syscall_prog_func_proto() in kernel/bpf/syscall.c,
bpf_btf_find_by_name_kind is also exposed to syscall programs:
case BPF_FUNC_btf_find_by_name_kind:
return &bpf_btf_find_by_name_kind_proto;
Because bpf_btf_find_by_name_kind_proto in kernel/bpf/btf.c lacks the
.might_sleep = true constraint, the verifier will permit its use inside a
non-sleepable bpf_timer callback registered by a syscall program.
When the timer fires in softirq context, bpf_btf_find_by_name_kind() calls
__btf_new_fd(). This attempts to allocate a file descriptor with GFP_KERNEL
and injects the new file descriptor into the current->files struct of
whatever arbitrary process was interrupted by the timer.
Should bpf_btf_find_by_name_kind_proto be updated as well to prevent this
cross-process file descriptor injection and scheduling-while-atomic issue?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903144433.1716731-1-memxor@gmail.com?part=9
next prev parent reply other threads:[~2026-09-03 15:51 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 14:44 [PATCH bpf v1 00/10] Misc bug fixes - part 1 Kumar Kartikeya Dwivedi
2026-09-03 14:44 ` [PATCH bpf v1 01/10] bpf: Mark signal tracepoint siginfo arguments as scalar Kumar Kartikeya Dwivedi
2026-09-03 15:52 ` bot+bpf-ci
2026-09-03 16:47 ` Alexei Starovoitov
2026-09-03 14:44 ` [PATCH bpf v1 02/10] selftests/bpf: Cover signal tracepoint siginfo sentinels Kumar Kartikeya Dwivedi
2026-09-03 15:52 ` bot+bpf-ci
2026-09-03 14:44 ` [PATCH bpf v1 03/10] bpf: Reject tail calls directly from callback frames Kumar Kartikeya Dwivedi
2026-09-03 15:21 ` sashiko-bot
2026-09-03 15:36 ` Kumar Kartikeya Dwivedi
2026-09-03 14:44 ` [PATCH bpf v1 04/10] selftests/bpf: Test direct tail calls from callbacks Kumar Kartikeya Dwivedi
2026-09-03 14:44 ` [PATCH bpf v1 05/10] bpf: Reject resilient lock operations in rbtree callbacks Kumar Kartikeya Dwivedi
2026-09-03 15:31 ` sashiko-bot
2026-09-03 15:36 ` Kumar Kartikeya Dwivedi
2026-09-03 14:44 ` [PATCH bpf v1 06/10] selftests/bpf: Reject resilient unlock in rbtree callback Kumar Kartikeya Dwivedi
2026-09-03 15:52 ` bot+bpf-ci
2026-09-03 14:44 ` [PATCH bpf v1 07/10] bpf: Mark sched_process_wait argument as nullable Kumar Kartikeya Dwivedi
2026-09-03 15:52 ` bot+bpf-ci
2026-09-03 14:44 ` [PATCH bpf v1 08/10] selftests/bpf: Test sched_process_wait nullable argument Kumar Kartikeya Dwivedi
2026-09-03 14:44 ` [PATCH bpf v1 09/10] bpf: Mark syscall helpers as sleepable Kumar Kartikeya Dwivedi
2026-09-03 15:51 ` sashiko-bot [this message]
2026-09-03 15:54 ` Kumar Kartikeya Dwivedi
2026-09-03 15:52 ` bot+bpf-ci
2026-09-03 14:44 ` [PATCH bpf v1 10/10] selftests/bpf: Check syscall helpers in timer callbacks Kumar Kartikeya Dwivedi
2026-09-03 16:50 ` [PATCH bpf v1 00/10] Misc bug fixes - part 1 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=20260903155150.D57251F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.