Re: [PATCH v2 bpf-next 1/6] bpf: Refactor reg_bounds_sanity_check

Shung-Hsi Yu
2026-03-23T08:01:19Z

On Fri, Mar 20, 2026 at 05:47:45PM +0100, Paul Chaignon wrote:
> From: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
>
> This commit refactors reg_bounds_sanity_check to factor out the logic
> that performs the sanity check from the logic that does the reporting.
>
> Signed-off-by: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
> Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>

Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>

> ---
> kernel/bpf/verifier.c | 50 ++++++++++++++++++++++++++++++-------------
> 1 file changed, 35 insertions(+), 15 deletions(-)
...
> +static bool const_tnum_out_of_sync_with_range_bounds(struct bpf_reg_state *reg)
> +{
> if (tnum_is_const(reg->var_off)) {
> u64 uval = reg->var_off.value;
> s64 sval = (s64)uval;
>
> if (reg->umin_value != uval || reg->umax_value != uval ||
> reg->smin_value != sval || reg->smax_value != sval) {
> - msg = "const tnum out of sync with range bounds";
> - goto out;
> + return true;

Off topic: despite I acked the addition of these check, I can no longer
recall the exact rational. This now just seems to me to report when the
bounds have not converge (in reg_bounds_sync?).

Anyway, good to keep it as-is for now.

...