Re: [PATCH bpf-next 02/13] bpf: generalize is_scalar_branch_taken() logic

Andrii Nakryiko
2023-11-03T21:07:22Z

On Fri, Nov 3, 2023 at 1:59 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Fri, Nov 3, 2023 at 9:47 AM Eduard Zingerman <eddyz87@gmail.com> wrote:
> >
> > On Thu, 2023-11-02 at 17:08 -0700, Andrii Nakryiko wrote:
> > > Generalize is_branch_taken logic for SCALAR_VALUE register to handle
> > > cases when both registers are not constants. Previously supported
> > > <range> vs <scalar> cases are a natural subset of more generic <range>
> > > vs <range> set of cases.
> > >
> > > Generalized logic relies on straightforward segment intersection checks.
> > >
> > > Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> >
> > Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> >
> > (With the same nitpick that '<' cases could be converted to '>' cases).
> >
>
> Ok.

Actually, this one is more annoying because of all the umin1/umin2/etc
initialization at the beginning. The conditions are very
straightforward, so I'm inclined to keep it as is for simplicity.

>
>
> > > ---
> > > kernel/bpf/verifier.c | 103 ++++++++++++++++++++++++++----------------
> > > 1 file changed, 63 insertions(+), 40 deletions(-)
> > >
>
> …