From: "Ömer Mete Kaya" <omermetekaya0@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net
Cc: john.fastabend@gmail.com, andrii@kernel.org, eddyz87@gmail.com,
memxor@gmail.com, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com,
ihor.solodrai@linux.dev, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Ömer Mete Kaya" <omermetekaya0@gmail.com>
Subject: [RFC PATCH bpf-next 1/1] bpf: Remove redundant second __reg_deduce_bounds() call in reg_bounds_sync()
Date: Sat, 26 Sep 2026 23:02:32 +0300 [thread overview]
Message-ID: <20260926200313.281893-2-omermetekaya0@gmail.com> (raw)
In-Reply-To: <20260926200313.281893-1-omermetekaya0@gmail.com>
reg_bounds_sync() calls __reg_deduce_bounds() twice in a row.
With the current cnum implementation, the second call is now redundant.
__reg_deduce_bounds() first intersects r32 with the 32-bit values
representable by r64, then intersects r64 with the values allowed by
r32. After one call, cnum64_cnum32_intersect() guarantees that every
value in r64 has its corresponding u32 value in r32. So, a
second call cannot further restrict either view.
The old tnum + min/max representation could require multiple passes:
tightening one of the 32-bit or 64-bit views could allow the other to
be tightened further. The double call ensured that the bounds reached
a fixpoint. With cnum, the first call already reaches the fixpoint.
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
kernel/bpf/verifier.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 8d8923ad5..1cd923363 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2180,7 +2180,6 @@ static void reg_bounds_sync(struct bpf_reg_state *reg)
__update_reg_bounds(reg);
/* We might have learned something about the sign bit. */
__reg_deduce_bounds(reg);
- __reg_deduce_bounds(reg);
/* We might have learned some bits from the bounds. */
__reg_bound_offset(reg);
/* Intersecting with the old var_off might have improved our bounds
--
2.55.0
prev parent reply other threads:[~2026-09-26 20:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-26 20:02 [RFC PATCH bpf-next 0/1] bpf: Remove redundant " Ömer Mete Kaya
2026-09-26 20:02 ` Ömer Mete Kaya [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=20260926200313.281893-2-omermetekaya0@gmail.com \
--to=omermetekaya0@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--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
all inboxes | Powered by JetHome®