[PATCH bpf-next v4 0/4] emit ENDBR/BTI instructions for indirect jump targets
Xu Kuohai
xukuohai at huaweicloud.com
Wed Jan 14 01:39:10 PST 2026
From: Xu Kuohai <xukuohai at huawei.com>
On x86 CPUs with CET/IBT and arm64 CPUs with BTI, missing landing pad instructions
at indirect jump targets triggers kernel panic. So emit ENDBR instructions for
indirect jump targets on x86 and BTI on arm64. Indirect jump targets are identified
based on the insn_aux_data created by the verifier.
Patch 1 fixes an off-by-one error that causes the last ENDBR/BTI instruction to be
omitted.
Patch 2 introduces a helper to determine whether an instruction is indirect jump target.
Patches 3 and 4 emit ENDBR and BTI instructions for indirect jump targets on x86 and
arm64, respectively.
v4:
- Switch to the approach proposed by Eduard, using insn_aux_data to indentify indirect
jump targets, and emit ENDBR on x86
v3: https://lore.kernel.org/bpf/20251227081033.240336-1-xukuohai@huaweicloud.com/
- Get rid of unnecessary enum definition (Yonghong Song, Anton Protopopov)
v2: https://lore.kernel.org/bpf/20251223085447.139301-1-xukuohai@huaweicloud.com/
- Exclude instruction arrays not used for indirect jumps (Anton Protopopov)
v1: https://lore.kernel.org/bpf/20251127140318.3944249-1-xukuohai@huaweicloud.com/
Xu Kuohai (4):
bpf: Fix an off-by-one error in check_indirect_jump
bpf: Add helper to detect indirect jump targets
bpf, x86: Emit ENDBR for indirect jump targets
bpf, arm64: Emit BTI for indirect jump target
arch/arm64/net/bpf_jit_comp.c | 3 ++
arch/x86/net/bpf_jit_comp.c | 15 ++++++----
include/linux/bpf.h | 2 ++
include/linux/bpf_verifier.h | 10 ++++---
kernel/bpf/core.c | 51 ++++++++++++++++++++++++++++++---
kernel/bpf/verifier.c | 53 +++++++++++++++++++++++++++++++++--
6 files changed, 119 insertions(+), 15 deletions(-)
--
2.47.3
More information about the linux-arm-kernel
mailing list