From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
<bpf@vger.kernel.org>
Cc: <daniel@iogearbox.net>, <andrii@kernel.org>, <memxor@gmail.com>,
<eddyz87@gmail.com>
Subject: Re: [PATCH bpf-next] bpf: Emit verbose message when prog-specific btf_struct_access rejects a write
Date: Mon, 15 Jun 2026 21:23:53 -0400 [thread overview]
Message-ID: <DJA2XL0AL5VW.XDNYFNSCBML0@etsalapatis.com> (raw)
In-Reply-To: <20260615232146.5491-1-alexei.starovoitov@gmail.com>
On Mon Jun 15, 2026 at 7:21 PM EDT, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@kernel.org>
>
> When BPF_WRITE goes through a PTR_TO_BTF_ID register, check_ptr_to_btf_access()
> delegates to env->ops->btf_struct_access(). Most implementations
> (bpf_scx_btf_struct_access, tc_cls_act_btf_struct_access, etc.) return
> -EACCES for disallowed fields without logging anything, so the verifier
> rejects the program with an empty message. For example a scx program doing
>
> 1: R1=trusted_ptr_task_struct()
> ...
> 4: (7b) *(u64 *)(r1 +0) = r2
> verification time 83 usec
> the program is rejected
>
> leaves the user guessing which field is off-limits.
> Emit verbose message.
>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
> ---
> kernel/bpf/verifier.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 2abc79dbf281..030505c8f3e2 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -5786,6 +5786,10 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env,
> return -EFAULT;
> }
> ret = env->ops->btf_struct_access(&env->log, reg, off, size);
> + if (ret < 0)
> + verbose(env,
> + "%s cannot write into ptr_%s at off=%d size=%d\n",
> + reg_arg_name(env, argno), tname, off, size);
> } else {
> /* Writes are permitted with default btf_struct_access for
> * program allocated objects (which always have id > 0),
prev parent reply other threads:[~2026-06-16 1:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 23:21 [PATCH bpf-next] bpf: Emit verbose message when prog-specific btf_struct_access rejects a write Alexei Starovoitov
2026-06-16 1:23 ` Emil Tsalapatis [this message]
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=DJA2XL0AL5VW.XDNYFNSCBML0@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox