All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Chaignon <paul.chaignon@gmail.com>
To: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>,
	bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Srinivas Narayana <srinivas.narayana@rutgers.edu>,
	Santosh Nagarakatte <santosh.nagarakatte@rutgers.edu>
Subject: Re: [PATCH bpf 2/4] bpf: Improve bounds when tnum has a single possible value
Date: Fri, 20 Feb 2026 15:02:20 +0100	[thread overview]
Message-ID: <aZhpbEF7h1kDLb-N@Tunnel> (raw)
In-Reply-To: <CAM=Ch04aEBi0eCtemGRBO0xFcPs5Av5T=AqQwQxGcNSJ2nAQ9Q@mail.gmail.com>

On Fri, Feb 20, 2026 at 01:34:26AM -0500, Harishankar Vishwanathan wrote:
> On Thu, Feb 19, 2026 at 8:29 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
> [...]
> > >     tnum_next = tnum_step(reg->var_off, reg->umin_value);
> > >     umin_in_tnum = (reg->umin_value & ~reg->var_off.mask) == reg->var_off.value;
> > >     tmax = reg->var_off.value | reg->var_off.mask;
> > >     if (tnum_next > reg->umax_value) {
> > >         /* The u64 range and the tnum only overlap in umin.
> > >          * u64:  ---[xxxxxx]-----
> > >          * tnum: --xx----------x-
> > >          */        ^
> > >         ___mark_reg_known(reg, reg->umin_value);
> > >     } else if (!umin_in_tnum && tnum_next == tmax) {
> > >         /* The u64 range and the tnum only overlap in the maximum value
> > >          * represented by the tnum, called tmax.
> > >          * u64:  ---[xxxxxx]-----
> > >          * tnum: xx-----x--------
> > >          */
> > >         ___mark_reg_known(reg, tmax);
> > >     } else if (!umin_in_tnum && tnum_next <= reg->umax_value &&
> > >        tnum_step(reg->var_off, tnum_next) > reg->umax_value) {
> > >         /* The u64 range and the tnum only overlap once in between umin
> > >          * (excluded) and umax.
> > >          * u64:  ---[xxxxxx]-----
> > >          * tnum: xx----x-------x-
> > >          */
> > >         ___mark_reg_known(reg, tnum_next);
> > >     }
> > >
> > > Wdyt?
> >
> > This makes sense, I missed this nuance in the original patch.
> > Maybe keep the first check as 'umin_in_tnum && tnum_next > reg->umax_value',
> > then?
> 
> I too think Eduard's suggestion makes sense. We will be explicit in
> the code that
> we want umin to be part of the tnum.

Agree, it helps readability. I've sent the v2 with that change.

Thanks everyone!

  reply	other threads:[~2026-02-20 14:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-17  8:53 [PATCH bpf 0/4] Fix invariant violation for single-value tnums Paul Chaignon
2026-02-17  8:59 ` [PATCH bpf 1/4] bpf: Introduce tnum_step to step through tnum's members Paul Chaignon
2026-02-17  9:44   ` bot+bpf-ci
2026-02-18  2:36     ` Harishankar Vishwanathan
2026-02-18  2:51       ` Alexei Starovoitov
2026-02-18  6:17         ` Harishankar Vishwanathan
2026-02-17  9:01 ` [PATCH bpf 2/4] bpf: Improve bounds when tnum has a single possible value Paul Chaignon
2026-02-17 18:58   ` Alexei Starovoitov
2026-02-17 22:57   ` Eduard Zingerman
2026-02-18  6:06     ` Harishankar Vishwanathan
2026-02-19 18:32       ` Eduard Zingerman
2026-02-19 18:55         ` Paul Chaignon
2026-02-20  0:13           ` Paul Chaignon
2026-02-20  1:29             ` Eduard Zingerman
2026-02-20  6:34               ` Harishankar Vishwanathan
2026-02-20 14:02                 ` Paul Chaignon [this message]
2026-02-17  9:04 ` [PATCH bpf 3/4] selftests/bpf: Test refinement of single-value tnum Paul Chaignon
2026-02-17  9:06 ` [PATCH bpf 4/4] selftests/bpf: Avoid simplification of crafted bounds test Paul Chaignon

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=aZhpbEF7h1kDLb-N@Tunnel \
    --to=paul.chaignon@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=harishankar.vishwanathan@gmail.com \
    --cc=santosh.nagarakatte@rutgers.edu \
    --cc=srinivas.narayana@rutgers.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.