summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMykyta Yatsenko <yatsenko@meta.com>2026-10-22 05:04:55 -0700
committerAlexei Starovoitov <ast@kernel.org>2026-10-24 03:58:06 +0000
commitebf0ab370bcdcd17f4faa204e1d2cc8e817ca6b1 (patch)
treece2aac7fd50007f16763613dc9b19ef791765a20 /include
parentfb2b27d214c3b88d926a303267dd83cfdb428b13 (diff)
bpf: Size backward jumps by the insns they jump over
A backward jump is sized from its target's current-pass address and its own previous-pass address, so it can grow while other jumps shrink. Two passes may then give the same image length with jumps still changing, which ends in "bpf_jit: fatal error", and a jump growing in a padding pass ends in "unexpected jmp_cond padding". Shift the jump's previous-pass address by how far the current pass has moved it, so a backward jump is sized by the insns it jumps over, like a forward one. Also start every insn at BPF_MAX_INSN_SIZE instead of 64, so none can grow in the first pass. Then no insn grows from one pass to the next, and a repeated image length means nothing moved. The 123 limit on imm8 offsets worked around that growth and is dropped. The ja -1 special case is subsumed, such a jump is now imm8 from the first pass. Suggested-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://patch.msgid.link/20261022-jit_size_fix-v2-1-4bee6921b218@meta.com
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions