[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260114093914.2403982-1-xukuohai@huaweicloud.com>
Date: Wed, 14 Jan 2026 17:39:10 +0800
From: Xu Kuohai <xukuohai@...weicloud.com>
To: bpf@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>,
Yonghong Song <yonghong.song@...ux.dev>,
Puranjay Mohan <puranjay@...nel.org>,
Anton Protopopov <a.s.protopopov@...il.com>
Subject: [PATCH bpf-next v4 0/4] emit ENDBR/BTI instructions for indirect jump targets
From: Xu Kuohai <xukuohai@...wei.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
Powered by blists - more mailing lists