From: Kees Cook <kees@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Kees Cook <kees@kernel.org>, Josh Poimboeuf <jpoimboe@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: [PATCH 3/3] objtool: Skip jump table jumps in the kCFI indirect call check
Date: Mon, 12 Oct 2026 02:04:26 -0700 [thread overview]
Message-ID: <20261012090436.1676525-3-kees@kernel.org> (raw)
In-Reply-To: <20261012090424.i.497-kees@kernel.org>
With MITIGATION_RETPOLINE=y, GCC lowers the computed goto in
___bpf_prog_run() to a jump through __x86_indirect_thunk_rdx. objtool
puts that jump on the retpoline call list along with the indirect calls,
so with CONFIG_CFI=y the kCFI check wants a UD2 before it:
vmlinux.o: warning: objtool: ___bpf_prog_run+0x1e: no-cfi indirect call!
The jump goes through the "jumptable" array, which objtool already reads
from .data.rel.ro.c_jump_table, so its targets stay inside the function
and need no kCFI check. Skip jump table jumps in the check. Clang does
not emit this jump: with retpolines, it lowers the computed goto without
an indirect jump.
Build tested ARCH=x86_64 defconfig with CONFIG_LKDTM=y and CONFIG_CFI=y,
with GCC 17.0.0 (experimental, with the kCFI series).
Assisted-by: LLM
Signed-off-by: Kees Cook <kees@kernel.org>
---
tools/objtool/check.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 464f6c9d9ff0..d35c5305075f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4199,6 +4199,14 @@ static int validate_retpoline(struct objtool_file *file)
list_for_each_entry(insn, &file->retpoline_call_list, call_node) {
struct symbol *sym = insn_sym(insn);
+ /*
+ * A jump through a jump table stays inside the function, so
+ * it has no kCFI check. GCC turns the computed goto in
+ * ___bpf_prog_run() into one under MITIGATION_RETPOLINE.
+ */
+ if (is_jump_table_jump(insn))
+ continue;
+
if (sym && (is_notype_sym(sym) ||
is_func_sym(sym)) && !sym->nocfi) {
struct instruction *prev =
--
2.55.0
next prev parent reply other threads:[~2026-10-12 9:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 9:04 [PATCH 0/3] x86/cfi: Fix a few kCFI issues found with GCC Kees Cook
2026-10-12 9:04 ` [PATCH 1/3] x86/kcfi: Decode the kCFI check from the trap address Kees Cook
2026-10-12 9:59 ` [tip: x86/urgent] " tip-bot2 for Kees Cook
2026-10-12 9:04 ` [PATCH 2/3] x86/kcfi: Emit the FineIBT paranoid "cs" prefix as a byte Kees Cook
2026-10-12 9:16 ` Peter Zijlstra
2026-10-12 9:59 ` [tip: x86/core] " tip-bot2 for Kees Cook
2026-10-12 9:04 ` Kees Cook [this message]
2026-10-12 9:22 ` [PATCH 3/3] objtool: Skip jump table jumps in the kCFI indirect call check Peter Zijlstra
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=20261012090436.1676525-3-kees@kernel.org \
--to=kees@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=samitolvanen@google.com \
/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
all inboxes | Powered by JetHome®