BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: bot+bpf-ci@kernel.org, chenyy23@mails.tsinghua.edu.cn,
	ast@kernel.org,  daniel@iogearbox.net, andrii@kernel.org,
	memxor@gmail.com
Cc: john.fastabend@gmail.com, martin.lau@linux.dev, song@kernel.org,
	 yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com,
	 bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	sashiko-bot@kernel.org,  martin.lau@kernel.org, clm@meta.com,
	ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf] bpf: Fix sanitize_err() register selection for BPF_K
Date: Thu, 06 Aug 2026 10:52:38 -0700	[thread overview]
Message-ID: <9bcb8e2b7d4fa998f4811e77fb6920edd3dced18.camel@gmail.com> (raw)
In-Reply-To: <18e8ba9303a6041520433c7bad9187e29a756908385e6b2607de1ae82db67beb@mail.kernel.org>

On Mon, 2026-08-03 at 15:25 +0000, bot+bpf-ci@kernel.org wrote:
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> > index fdc5fbb1f78c..e5a8547ad723 100644
> > --- a/kernel/bpf/verifier.c
> > +++ b/kernel/bpf/verifier.c
> > @@ -13562,6 +13562,7 @@ static int sanitize_err(struct bpf_verifier_env *env, const struct bpf_insn *ins
> >  	static const char *err = "pointer arithmetic with it prohibited for !root";
> >  	const char *op = BPF_OP(insn->code) == BPF_ADD ? "add" : "sub";
> >  	u32 dst = insn->dst_reg, src = insn->src_reg;
> > +	bool src_is_imm = BPF_SRC(insn->code) == BPF_K;
> >  	struct bpf_reg_state *regs = cur_regs(env);
> > 
> >  	switch (reason) {
> > @@ -13571,7 +13572,7 @@ static int sanitize_err(struct bpf_verifier_env *env, const struct bpf_insn *ins
> >  		break;
> >  	case REASON_TYPE:
> >  		verbose(env, "R%d has pointer with unsupported alu operation, %s\n",
> > -			regs[src].type == SCALAR_VALUE ? dst : src, err);
> > +			src_is_imm || regs[src].type == SCALAR_VALUE ? dst : src, err);
> >  		break;
> >  	case REASON_PATHS:
> >  		verbose(env, "R%d tried to %s from different maps, paths or scalars, %s\n",
> 
> Can this code path be reached for BPF_K instructions? The new src_is_imm
> check appears to be unreachable.
>
> All three call sites of sanitize_err() (at verifier.c:13765, :13858 and
> :14610) fire only when sanitize_ptr_alu() or sanitize_val_alu() return a
> negative REASON_* code. Both of those functions begin with:
> 
> static bool can_skip_alu_sanitation(const struct bpf_verifier_env *env,
>                                     const struct bpf_insn *insn)
> {
>         return env->bypass_spec_v1 ||
>                 BPF_SRC(insn->code) == BPF_K ||
>                 cur_aux(env)->nospec;
> }
> 
> and check this at their entry:
> 
>   sanitize_val_alu()  verifier.c:13415:  if (can_skip_alu_sanitation(env, insn)) return 0;
>   sanitize_ptr_alu()  verifier.c:13469:  if (can_skip_alu_sanitation(env, insn)) return 0;

Hi Yiyang,

Thank you for the follow-up. I double-checked what bot is saying,
and it correct. The original report from Sashiko was a false positive.
Given this, let's keep the code as-is for now.

...

      reply	other threads:[~2026-08-06 17:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 14:44 [PATCH bpf] bpf: Fix sanitize_err() register selection for BPF_K Yiyang Chen
2026-08-03 14:57 ` sashiko-bot
2026-08-03 15:25 ` bot+bpf-ci
2026-08-06 17:52   ` Eduard Zingerman [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=9bcb8e2b7d4fa998f4811e77fb6920edd3dced18.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chenyy23@mails.tsinghua.edu.cn \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=sashiko-bot@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@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