From: sashiko-bot@kernel.org
To: "Aaron Tomlin" <atomlin@atomlin.com>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC PATCH v4] bpf: introduce TAINT_UNSAFE_BPF for mutating helpers
Date: Sun, 03 May 2026 19:18:36 +0000 [thread overview]
Message-ID: <20260503191837.70727C2BCB4@smtp.kernel.org> (raw)
In-Reply-To: <20260503190119.559696-1-atomlin@atomlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Race condition allows an unsafe BPF program to execute and potentially crash the kernel before the taint is applied.
--
commit e1d80dc0708bef39b15f2ef93cbdb5c71cbc352e
Author: Aaron Tomlin <atomlin@atomlin.com>
bpf: introduce TAINT_UNSAFE_BPF for mutating helpers
This patch introduces a new kernel taint flag, TAINT_UNSAFE_BPF, which is
set when an eBPF program utilizing destructive or mutating helpers is loaded.
This provides an auditable indicator that the kernel's execution flow or
memory may have been compromised by eBPF.
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -3109,6 +3109,13 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size)
> perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0);
> bpf_audit_prog(prog, BPF_AUDIT_LOAD);
>
> + /*
> + * The program has passed the verifier and is now publicly exposed.
> + * If it utilises unsafe helpers, formally taint the kernel now.
> + */
> + if (prog->aux->taints_kernel)
> + add_taint(TAINT_UNSAFE_BPF, LOCKDEP_STILL_OK);
Could this leave a small race window where an unsafe program executes before
the taint is applied?
Looking earlier in bpf_prog_load(), the program is added to the IDR via
bpf_prog_alloc_id(prog). If a concurrent thread polls for this new ID using
bpf_prog_get_fd_by_id(), could it attach and execute the program before this
thread reaches add_taint()?
If the unsafe program causes a crash during this window, the resulting dump
might not have the TAINT_UNSAFE_BPF flag set. Should the taint be applied
before the program is placed in the IDR?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260503190119.559696-1-atomlin@atomlin.com?part=1
next prev parent reply other threads:[~2026-05-03 19:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 19:01 [RFC PATCH v4] bpf: introduce TAINT_UNSAFE_BPF for mutating helpers Aaron Tomlin
2026-05-03 19:18 ` sashiko-bot [this message]
2026-05-03 19:52 ` Alexei Starovoitov
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=20260503191837.70727C2BCB4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atomlin@atomlin.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko@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