[PATCH v2] arm64: bpf: Fix UBSAN misaligned access in BPF JIT

Fuad Tabba posted 1 patch 1 month, 2 weeks ago
arch/arm64/net/bpf_jit_comp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] arm64: bpf: Fix UBSAN misaligned access in BPF JIT
Posted by Fuad Tabba 1 month, 2 weeks ago
struct bpf_plt contains a u64 'target' field, but the struct itself is
often placed at 4-byte aligned offsets in the BPF JIT buffer. This
causes UBSAN to report misaligned-access warnings when dereferencing the
structure.

To pacify UBSAN and signal the compiler about the layout without
over-aligning the entire JIT buffer allocation, mark struct bpf_plt as
__packed.

No functional change intended.

Suggested-by: Will Deacon <will@kernel.org>
Fixes: b2ad54e1533e9 ("bpf, arm64: Build branch-target-identification-enabled BPF trampolines")
Signed-off-by: Fuad Tabba <tabba@google.com>
---
 arch/arm64/net/bpf_jit_comp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 356d33c7a4ae..fc8c74c29bd6 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -98,7 +98,7 @@ struct bpf_plt {
 	u32 insn_ldr; /* load target */
 	u32 insn_br;  /* branch to target */
 	u64 target;   /* target value */
-};
+} __packed;
 
 #define PLT_TARGET_SIZE   sizeof_field(struct bpf_plt, target)
 #define PLT_TARGET_OFFSET offsetof(struct bpf_plt, target)
-- 
2.53.0.473.g4a7958ca14-goog
Re: [PATCH v2] arm64: bpf: Fix UBSAN misaligned access in BPF JIT
Posted by bot+bpf-ci@kernel.org 1 month, 2 weeks ago
> Fixes: b2ad54e1533e9 ("bpf, arm64: Build branch-target-identification-enabled BPF trampolines")

The subject in this Fixes tag does not match the referenced commit.
Commit b2ad54e1533e has subject:

    "bpf, arm64: Implement bpf_arch_text_poke() for arm64"

The v1 of this patch had the correct subject, but it appears the
subject was inadvertently changed when respinning to v2.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/22390726005

AI-authorship-score: low
AI-authorship-explanation: Natural patch evolution through mailing list review with v1 rejected and v2 adopting reviewer suggestion; minor human error in Fixes tag subject change is typical of manual respins.
issues-found: 1
issue-severity-score: low
issue-severity-explanation: Wrong commit subject in Fixes tag; the SHA is correct so tooling is unaffected, but the human-readable reference is inaccurate.