BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau	 <martin.lau@linux.dev>,
	Kernel Team <kernel-team@fb.com>,
	Yonghong Song	 <yonghong.song@linux.dev>
Subject: Re: [PATCH bpf-next 2/3] bpf: use reg->var_off instead of reg->off for pointers
Date: Wed, 11 Feb 2026 21:06:38 -0800	[thread overview]
Message-ID: <704f1950a3ab0a941fe673930086afeae0d6147d.camel@gmail.com> (raw)
In-Reply-To: <CAADnVQLZh4Bk++vEW97mL0mMCUJu075vQFS2Kkhf9zXP5b2zLw@mail.gmail.com>

On Wed, 2026-02-11 at 18:23 -0800, Alexei Starovoitov wrote:
> On Wed, Feb 11, 2026 at 2:32 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
> > 
> > - In mark_ptr_or_null_reg() WARN_ON_ONCE() checks were removed
> >   because in some cases helpers that return local kptrs can now
> >   return pointers with non-zero '.var_off' (e.g., a pointer to
> >   a spin lock inside a map entry).
> 
> ...
> 
> > @@ -17129,29 +17074,13 @@ static void mark_ptr_or_null_reg(struct bpf_func_state *state,
> >  {
> >         if (type_may_be_null(reg->type) && reg->id == id &&
> >             (is_rcu_reg(reg) || !WARN_ON_ONCE(!reg->id))) {
> > -               /* Old offset (both fixed and variable parts) should have been
> > -                * known-zero, because we don't allow pointer arithmetic on
> > -                * pointers that might be NULL. If we see this happening, don't
> > -                * convert the register.
> > -                *
> > -                * But in some cases, some helpers that return local kptrs
> > -                * advance offset for the returned pointer. In those cases, it
> > -                * is fine to expect to see reg->off.
> > -                */
> > -               if (WARN_ON_ONCE(reg->smin_value || reg->smax_value || !tnum_equals_const(reg-
> > >var_off, 0)))
> > -                       return;
> > -               if (!(type_is_ptr_alloc_obj(reg->type) || type_is_non_owning_ref(reg->type)) &&
> > -                   WARN_ON_ONCE(reg->off))
> > -                       return;
> > -
> 
> This part looks overly aggressive to me.
> I don't remember seeing these warns, so any known code or syzbot
> is not triggering it, but can we keep them?
> The first warn can stay as-is, no?
> And the 2nd can be converted to tnum_equals_const() too ?

I think it can be preserved as one warning:

               if (!(type_is_ptr_alloc_obj(reg->type) || type_is_non_owning_ref(reg->type)) &&
                   WARN_ON_ONCE(!tnum_equals_const(reg->var_off, 0)))
                       return;

I'll add this in v2.

  reply	other threads:[~2026-02-12  5:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 22:31 [PATCH bpf-next 0/3] bpf: consolidate pointer offset tracking in var_off Eduard Zingerman
2026-02-11 22:31 ` [PATCH bpf-next 1/3] bpf: split check_reg_sane_offset() in two parts Eduard Zingerman
2026-02-11 22:31 ` [PATCH bpf-next 2/3] bpf: use reg->var_off instead of reg->off for pointers Eduard Zingerman
2026-02-12  2:23   ` Alexei Starovoitov
2026-02-12  5:06     ` Eduard Zingerman [this message]
2026-02-11 22:31 ` [PATCH bpf-next 3/3] bpf: rename bpf_reg_state->off to bpf_reg_state->delta Eduard Zingerman
2026-02-11 23:08   ` bot+bpf-ci
2026-02-11 23:14     ` Eduard Zingerman
2026-02-12  3:06   ` kernel test robot
2026-02-12  8:15   ` kernel test robot
2026-02-12  8:15   ` kernel test robot

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=704f1950a3ab0a941fe673930086afeae0d6147d.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@linux.dev \
    --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