From: Peter Zijlstra <peterz@infradead.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, x86@kernel.org,
Ingo Molnar <mingo@kernel.org>, Kees Cook <kees@kernel.org>,
kernel test robot <lkp@intel.com>,
Josh Poimboeuf <jpoimboe@redhat.com>
Subject: Re: [tip:x86/core 1/1] vmlinux.o: warning: objtool: rcar_pcie_probe+0x13e: no-cfi indirect call!
Date: Mon, 13 Oct 2025 22:08:51 +0200 [thread overview]
Message-ID: <20251013200851.GA2969753@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20251013185011.GA2734756@noisy.programming.kicks-ass.net>
On Mon, Oct 13, 2025 at 08:50:12PM +0200, Peter Zijlstra wrote:
> On Mon, Oct 13, 2025 at 11:30:59AM -0700, Nathan Chancellor wrote:
>
> > Is there any way for objtool to detect these instances and emit a
> > slightly differently worded message? Figured it was worth asking ;)
>
> Objtool doesn't really do value tracking, but I'll see if I can hack
> something together.
>
> That is, as long as its always:
>
> xor %r11, %r11
> cs call __x86_indirect_thunk_r11
>
> without any instructions in between, it should be relatively straight
> forward. But the moment there can be anything in between we need to
> track the value of r11 back from the call or something.
vmlinux.o: warning: objtool: rcar_pcie_probe+0x13e: (*NULL)() FTW!
---
diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 0ad5cc70ecbe..2fb92d944d8c 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -236,6 +236,19 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
}
break;
+ case 0x31: /* XOR */
+ if (!opts.cfi)
+ break;
+
+ /* kCFI requires all indirect calls through r11 */
+
+ if (modrm_mod == 3 && modrm_reg == modrm_rm) {
+ /* XOR %reg, %reg */
+ if (modrm_reg == 11)
+ insn->type = INSN_ZERO_INDIRECT;
+ }
+ break;
+
case 0x50 ... 0x57:
/* push reg */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a5770570b106..9382d5d18885 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4029,7 +4029,13 @@ static int validate_retpoline(struct objtool_file *file)
struct instruction *prev =
prev_insn_same_sym(file, insn);
- if (!prev || prev->type != INSN_BUG) {
+ if (!prev) {
+ WARN_INSN(insn, "indirect call as first instruction!");
+ warnings++;
+ } else if (prev->type == INSN_ZERO_INDIRECT) {
+ WARN_INSN(insn, "(*NULL)() FTW!");
+ warnings++;
+ } else if (prev->type != INSN_BUG) {
WARN_INSN(insn, "no-cfi indirect call!");
warnings++;
}
diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h
index be33c7b43180..d9fea571a455 100644
--- a/tools/objtool/include/objtool/arch.h
+++ b/tools/objtool/include/objtool/arch.h
@@ -30,6 +30,7 @@ enum insn_type {
INSN_TRAP,
INSN_ENDBR,
INSN_LEA_RIP,
+ INSN_ZERO_INDIRECT,
INSN_OTHER,
};
prev parent reply other threads:[~2025-10-13 20:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 13:07 [tip:x86/core 1/1] vmlinux.o: warning: objtool: rcar_pcie_probe+0x13e: no-cfi indirect call! kernel test robot
2025-10-10 3:20 ` Nathan Chancellor
2025-10-10 7:10 ` Peter Zijlstra
2025-10-10 7:44 ` Peter Zijlstra
2025-10-10 22:30 ` Nathan Chancellor
2025-10-10 22:53 ` Kees Cook
2025-10-13 8:26 ` Peter Zijlstra
2025-10-13 18:30 ` Nathan Chancellor
2025-10-13 18:50 ` Peter Zijlstra
2025-10-13 20:08 ` Peter Zijlstra [this message]
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=20251013200851.GA2969753@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=jpoimboe@redhat.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=mingo@kernel.org \
--cc=nathan@kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=x86@kernel.org \
/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