From: sashiko-bot@kernel.org
To: "Daniel Borkmann" <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 08/24] arm64, insn: Reject invalid and unpredictable operands in the encoders
Date: Sun, 08 Nov 2026 19:38:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-203981@kernel.org> (raw)
In-Reply-To: <a039fe7efc077061852c80b14b6ebcc81cdef75d.1794165614.git.daniel@iogearbox.net>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] arm64, insn: s32 offset truncation in aarch64_insn_gen_adr() for
ADRP
--
commit cecf5be8cc096127beade0ea92a07c5f62e297a6
Author: Daniel Borkmann <daniel@iogearbox.net>
arm64, insn: Reject invalid and unpredictable operands in the encoders
This commit rejects out-of-range and CONSTRAINED UNPREDICTABLE operands in
several arm64 instruction encoders so they return AARCH64_BREAK_FAULT.
> diff --git a/arch/arm64/lib/insn.c b/arch/arm64/lib/insn.c
> index 48a481aa9656c..87a06bd088115 100644
> --- a/arch/arm64/lib/insn.c
> +++ b/arch/arm64/lib/insn.c
[ ... ]
> @@ -1293,6 +1320,9 @@ u32 aarch64_insn_gen_adr(unsigned long pc, unsigned long addr,
> switch (type) {
> case AARCH64_INSN_ADR_TYPE_ADR:
> insn = aarch64_insn_get_adr_value();
> + /* The s32 offset would truncate a difference beyond 4GB */
> + if ((long)(addr - pc) != (s32)(addr - pc))
> + return AARCH64_BREAK_FAULT;
> offset = addr - pc;
> break;
> case AARCH64_INSN_ADR_TYPE_ADRP:
[Severity: Low]
Can the AARCH64_INSN_ADR_TYPE_ADRP branch right below still truncate into
range when storing the shifted page difference into s32 offset?
arch/arm64/lib/insn.c:aarch64_insn_gen_adr() {
u32 insn;
s32 offset;
...
case AARCH64_INSN_ADR_TYPE_ADRP:
insn = aarch64_insn_get_adrp_value();
offset = (addr - ALIGN_DOWN(pc, SZ_4K)) >> 12;
break;
...
if (offset < -SZ_1M || offset >= SZ_1M)
return AARCH64_BREAK_FAULT;
}
When addr and pc are 16 TiB or more apart, bits [51:32] of the shifted page
offset are dropped before the [-SZ_1M, SZ_1M) range check. Declaring offset
as long (like label_imm_common()) and casting the difference to long before
shifting in the ADRP case would avoid 32-bit truncation in both branches
without needing the separate s32 comparison.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794165614.git.daniel@iogearbox.net?part=8
next prev parent reply other threads:[~2026-11-08 19:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 19:26 [PATCH bpf-next v3 00/24] bpf: Various arm64 BPF JIT improvements Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 01/24] bpf, arm64: Remove unused A64_BL, A64_BTI_C and A64_LDR32LIT Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 02/24] bpf, arm64: Free the offset table of a subprog in bpf_jit_free Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 03/24] bpf, arm64: Free the private stack when a pass over the image fails Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 04/24] bpf, arm64: Emit ISB SY in the speculation barriers Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 05/24] arm64, insn: Reject sign extending loads of 64 bits Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 06/24] bpf, arm64: Keep the ll/sc atomics address apart from the old value Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 07/24] bpf, arm64: Measure backward branches from the branch itself Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 08/24] arm64, insn: Reject invalid and unpredictable operands in the encoders Daniel Borkmann
2026-11-08 19:38 ` sashiko-bot [this message]
2026-11-08 19:53 ` Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 09/24] bpf, arm64: Widen the branch offsets before scaling them to bytes Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 10/24] arm64, insn: Add the LDUR/STUR and TBZ/TBNZ encodings Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 11/24] bpf: Divide by constants via uhmul and shmul in the verifier Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 12/24] bpf, arm64: Consolidate the load and store emission into a helper Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 13/24] bpf, arm64: Use the unscaled forms for negative and unaligned offsets Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 14/24] bpf, arm64: Store zero immediates from the zero register Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 15/24] bpf, arm64: Zero extend the arena offset in register offset accesses Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 16/24] bpf, arm64: Adjust compares with unencodable immediates by one Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 17/24] bpf, arm64: Materialize immediates with fewer instructions Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 18/24] bpf, arm64: Shorten the tail call sequence Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 19/24] bpf, arm64: Use mov or mvn for AND, OR and XOR with all ones Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 20/24] bpf, arm64: Use cbz, cbnz, tbz and tbnz for zero, sign and bit tests Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 21/24] bpf, arm64: Multiply by constants with shifts, adds and subs Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 22/24] selftests/bpf: Let the arm64 private stack check skip the BTI pad Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 23/24] selftests/bpf: Test the verifier's division by constants Daniel Borkmann
2026-11-08 19:26 ` [PATCH bpf-next v3 24/24] selftests/bpf: Extend the JIT instruction tests for arm64 encodings Daniel Borkmann
2026-11-08 19:45 ` sashiko-bot
2026-11-08 19:47 ` Daniel Borkmann
2026-11-09 1:26 ` [PATCH bpf-next v3 00/24] bpf: Various arm64 BPF JIT improvements patchwork-bot+netdevbpf
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=sashiko-outbox-203981@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=sashiko-reviews@lists.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