From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Eduard Zingerman" <eddyz87@gmail.com>, <bpf@vger.kernel.org>,
<andrii@kernel.org>
Cc: <daniel@iogearbox.net>, <martin.lau@linux.dev>,
<kernel-team@fb.com>, <yonghong.song@linux.dev>,
<memxor@gmail.com>
Subject: Re: [PATCH bpf-next 1/2] bpf: reject pointer operands for 32-bit recurrences/latches
Date: Wed, 21 Oct 2026 00:08:37 +0000 [thread overview]
Message-ID: <DMA2V519LNME.1WWMR93G4S295@gmail.com> (raw)
In-Reply-To: <20261020234705.375067-1-eddyz87@gmail.com>
On Tue, Oct 20, 2026 at 04:47 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
> - if (ra && rb && bpf_same_memory_origin(ra, rb))
> + if (ra && rb && bpf_same_memory_origin(ra, rb) && !latch->zext32 && !latch->jmp32)
> return true;
This covers the latch only. A 32-bit recurrence on a pointer that
is not part of the latch is still widened and clamped, it seems:
r7 = map_value, r1 = 0
l: if r7 > 24 goto a
goto n
a: r0 = *(u8 *)(r7 + 0)
n: w7 = w7
w7 += 8
r1 += 1
if r1 != 4 goto l
r7 at the header is (zext32 (linear r7 8)) and is_widenable_reg_type()
is fine with map_value. 'w7 = w7' makes it a scalar. At the backedge
bpf_clamp_scev_regs() takes linear_bounds() of the entry reg, which is
the offset of map_value, and clamps that scalar to 0..24.
Then 'if r7 > 24' is never taken, so 'a:' is verified with
r7 == map_value only. At run time in the 2nd iteration r7 is the low
32 bits of the address + 8 and the prog reads from there.
Should bpf_compute_loop_iters() also have
(!coefs.zext32 || reg->type == SCALAR_VALUE)
next to is_widenable_reg_type() ?
pls follow up.
next prev parent reply other threads:[~2026-10-21 0:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 23:47 [PATCH bpf-next 1/2] bpf: reject pointer operands for 32-bit recurrences/latches Eduard Zingerman
2026-10-20 23:47 ` [PATCH bpf-next 2/2] selftests/bpf: " Eduard Zingerman
2026-10-21 0:21 ` sashiko-bot
2026-10-21 0:08 ` Alexei Starovoitov [this message]
2026-10-21 0:22 ` [PATCH bpf-next 1/2] bpf: reject " sashiko-bot
2026-10-21 0:22 ` bot+bpf-ci
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=DMA2V519LNME.1WWMR93G4S295@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@fb.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.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