From: sashiko-bot@kernel.org
To: "Leon Hwang" <leon.hwang@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 1/2] bpf: Fix sleepable check for tracing prog
Date: Tue, 04 Aug 2026 15:43:22 +0000 [thread overview]
Message-ID: <20260804154323.3478C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804145710.43062-2-leon.hwang@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Bypass of `bpf_d_path_allowed` allowlist using forged BTF IDs allows non-sleepable tracing programs to call `bpf_d_path`, leading to kernel deadlocks.
--
--- Patch [1]: [PATCH bpf-next v3 1/2] bpf: Fix sleepable check for tracing prog ---
commit bd029887d83c0773bad79aca8216a06849cdbd32
Author: Leon Hwang <leon.hwang@linux.dev>
bpf: Fix sleepable check for tracing prog
When CONFIG_FUNCTION_ERROR_INJECTION is disabled, a sleepable tracing prog
is allowed to attach to '__x64_'-alike prefix symbols.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 7439afdc851a7..d4541cca7180e 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -19024,6 +19024,9 @@ static int btf_id_allow_sleepable(u32 btf_id, unsigned long addr, const struct b
>
> switch (prog->type) {
> case BPF_PROG_TYPE_TRACING:
> + if (!btf_is_kernel(btf))
> + return -EINVAL;
> +
[Severity: High]
This is a pre-existing issue, but does the same bypass exist for
non-sleepable tracing programs calling bpf_d_path()?
Looking at bpf_d_path_allowed() in kernel/trace/bpf_trace.c:
kernel/trace/bpf_trace.c:bpf_d_path_allowed() {
...
return btf_id_set_contains(&btf_allowlist_d_path,
prog->aux->attach_btf_id);
}
This check relies entirely on the integer attach_btf_id and fails to verify
if attach_btf is the kernel's vmlinux BTF.
Can a user load a dummy BPF program with a crafted BTF where a function's
BTF ID exactly matches an ID in btf_allowlist_d_path, and then attach a
non-sleepable tracing program to it?
If this dummy program is triggered in softirq context by network traffic,
and the tracing program extracts a valid path and calls bpf_d_path(),
this would invoke d_path() which attempts to acquire rename_lock (a seqlock).
If the softirq interrupts a process holding the seqlock writer spinlock,
wouldn't read_seqbegin_or_lock() retry and fall back to taking the spinlock,
causing a deadlock on the same CPU?
> t = btf_type_by_id(btf, btf_id);
> if (!t)
> return -EINVAL;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804145710.43062-1-leon.hwang@linux.dev?part=1
next prev parent reply other threads:[~2026-08-04 15:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 14:57 [PATCH bpf-next v3 0/2] bpf: Fix sleepable check for tracing prog Leon Hwang
2026-08-04 14:57 ` [PATCH bpf-next v3 1/2] " Leon Hwang
2026-08-04 15:43 ` sashiko-bot [this message]
2026-08-04 23:39 ` Andrii Nakryiko
[not found] ` <20260804145710.43062-3-leon.hwang@linux.dev>
2026-08-04 15:49 ` [PATCH bpf-next v3 2/2] selftests/bpf: Verify rejection of sleepable " 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=20260804154323.3478C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=leon.hwang@linux.dev \
--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 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).