From: Eduard Zingerman <eddyz87@gmail.com>
To: Helen Koike <koike@igalia.com>,
andrii@kernel.org, shung-hsi.yu@suse.com,
yonghong.song@linux.dev, ast@kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-dev@igalia.com
Subject: Re: [PATCH 1/2] bpf: deduce_bounds_64_from_32 tightening with circular range logic
Date: Wed, 15 Apr 2026 11:12:55 -0700 [thread overview]
Message-ID: <c948fe66d53d09eed5c72d33abc54ed25b463c09.camel@gmail.com> (raw)
In-Reply-To: <20260410124035.297632-1-koike@igalia.com>
On Fri, 2026-04-10 at 09:40 -0300, Helen Koike wrote:
> Unify handling of signed and unsigned using circular range logic.
>
> Signed and unsigned numbers follows the same order in bit
> representation. We can think of it as a clock, were 12h is
> 0x0000_0000 and 11h is 0xFFFF_FFFF, regardless of its sign.
>
> Then, instead of dealing with max and min, we deal with a base and len,
> where len = max - min.
>
> Example:
> range [-1, 3] is represented by base=0xFFFF_FFFF len=4
> since (u32)3 - (u32)-1 is 4.
>
> And we can verify if a value v is in range if:
> (u32)(v - base) <= len
> which is true if v is signed -1 or v is unsigned 0xFFFF_FFFF.
>
> This automatically handles the wrapping case, discarding the need to
> check if it crosses the signed range or not and handle each case.
>
> It also fixes the following current issues:
> * [(u32)umin, (u32)umax] falling outside of [u32_min_value, u32_max_value]
> * [(u32)umin, (u32)umax] falling in the gap [(u32)s32_max_value, (u32)s32_min_value]
>
> Fixes: c51d5ad6543c ("bpf: improve deduction of 64-bit bounds from 32-bit bounds")
> [Circular representation]
> Suggested-by: Eduard Zingerman <eddyz87@gmail.com>
> Signed-off-by: Helen Koike <koike@igalia.com>
>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
[...]
prev parent reply other threads:[~2026-04-15 18:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-10 12:40 [PATCH 1/2] bpf: deduce_bounds_64_from_32 tightening with circular range logic Helen Koike
2026-04-10 12:40 ` [PATCH 2/2] selftests/bpf: new cases handled by 32->64 range refinements Helen Koike
2026-04-14 8:26 ` [PATCH 1/2] bpf: deduce_bounds_64_from_32 tightening with circular range logic Shung-Hsi Yu
2026-04-14 16:25 ` Helen Koike
2026-04-14 18:32 ` Eduard Zingerman
2026-04-15 7:12 ` Eduard Zingerman
2026-04-15 16:19 ` Harishankar Vishwanathan
2026-04-15 18:12 ` Eduard Zingerman
2026-04-16 3:52 ` Shung-Hsi Yu
2026-04-16 7:43 ` Eduard Zingerman
2026-04-16 13:45 ` Paul Chaignon
2026-04-15 18:12 ` Eduard Zingerman [this message]
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=c948fe66d53d09eed5c72d33abc54ed25b463c09.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kernel-dev@igalia.com \
--cc=koike@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shung-hsi.yu@suse.com \
--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