From: Eduard Zingerman <eddyz87@gmail.com>
To: Shung-Hsi Yu <shung-hsi.yu@suse.com>,
Paul Chaignon <paul.chaignon@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
Subject: Re: [PATCH v2 bpf-next 1/2] bpf: Avoid one round of bounds deduction
Date: Thu, 12 Mar 2026 21:54:19 -0700 [thread overview]
Message-ID: <72d8c8ab082d67c75bfd3d47f3a57f4b25a837db.camel@gmail.com> (raw)
In-Reply-To: <wficveatl5cscfiaasqanow72ejlzifrcatj7z3r4dtu6nul77@bpfukkbrhml6>
On Fri, 2026-03-13 at 10:17 +0800, Shung-Hsi Yu wrote:
[...]
> The problem is that I'm operating on a simplified assumption of "not
> being able to converage to a fix-point is bad because it could lead to
> bound invariant violation". So taking this chance to ask, does that all
> ties back to is_scalar_branch_taken and reg_set_min_max (or was it
> regs_refine_cond_op) difference?
>
> Also, when we fail to reach a fix-point, it does not become a problem
> immediately, but only becomes a invariant violation some where down the
> line when we again do bound deduction?
>
> I haven't actually look into an invariant violation myself, so details
> are rather hazy.
I don't think failing to reach fixed point causes invariant violation.
The root cause for invariant violation is that decisions in
is_scalar_branch_taken() for e.g. >=, <= are taken based on ranges,
but additional information in tnum is not taken into account.
Later reg_set_min_max() will call reg_bounds_sync() and it might turn
out that updated ranges do not intersect with tnums.
The inverse might happen for tnum based decisions in
is_scalar_branch_taken().
So, if we don't reach fixed point in reg_bounds_sync() we just leave
some precision on the table w/o other negative consequences,
as far as I understand.
One solution for invariants violation looks as follows:
- Adjust is_scalar_branch_taken():
- Do not make predictions directly, instead apply range and tnum
changes corresponding to the operation (e.g. for true branch of
the `rX <= 0` operation intersect `rX` range with [-∞, 0]).
- Call reg_set_min_max() and check if resulting registers are in a
valid state. If they are for some branch but not another a
prediction can be made.
- Adjust check_cond_jmp_op() to use registers computed by
is_scalar_branch_taken() for true and false verifier states.
- Adjust reg_bounds_sync() to consistently bail out if invariants
violation is encountered. I think it has a few places with implicit
assumption that ranges/tnums must overlap.
I have a stale branch with these changes, need to pull my act together
and finish with those changes.
next prev parent reply other threads:[~2026-03-13 4:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 0:01 [PATCH v2 bpf-next 1/2] bpf: Avoid one round of bounds deduction Paul Chaignon
2026-03-07 0:03 ` [PATCH v2 bpf-next 2/2] selftests/bpf: Test case for refinement improvement using 64b bounds Paul Chaignon
2026-03-10 1:07 ` [PATCH v2 bpf-next 1/2] bpf: Avoid one round of bounds deduction Eduard Zingerman
2026-03-10 1:30 ` Eduard Zingerman
2026-03-10 5:53 ` Eduard Zingerman
2026-03-10 7:56 ` Shung-Hsi Yu
2026-03-10 19:45 ` Eduard Zingerman
2026-03-12 18:35 ` Paul Chaignon
2026-03-13 2:17 ` Shung-Hsi Yu
2026-03-13 4:54 ` Eduard Zingerman [this message]
2026-03-17 5:52 ` Shung-Hsi Yu
2026-03-13 10:45 ` Paul Chaignon
2026-03-17 6:03 ` Shung-Hsi Yu
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=72d8c8ab082d67c75bfd3d47f3a57f4b25a837db.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=harishankar.vishwanathan@gmail.com \
--cc=paul.chaignon@gmail.com \
--cc=shung-hsi.yu@suse.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 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.