Re: [PATCH v2 13/13] objtool: Validate kCFI calls

Josh Poimboeuf
2025-04-30T15:59:56Z

On Wed, Apr 30, 2025 at 01:07:47PM +0200, Peter Zijlstra wrote:
> + case ANNOTYPE_NOCFI:
> + sym = insn->sym;
> + if (!sym) {
> + ERROR_INSN(insn, "dodgy NOCFI annotation");
> + break;

return -1;

> + /*
> + * kCFI call sites look like:
> + *
> + * movl $(-0x12345678), %r10d
> + * addl -4(%r11), %r10d
> + * jz 1f
> + * ud2
> + * 1: cs call __x86_indirect_thunk_r11
> + *
> + * Verify all indirect calls are kCFI adorned by checking for the
> + * UD2. Notably, doing __nocfi calls to regular (cfi) functions is
> + * broken.
> + */
> + list_for_each_entry(insn, &file->retpoline_call_list, call_node) {
> + struct symbol *sym = insn->sym;
> +
> + if (sym && sym->type == STT_FUNC && !sym->nocfi) {
> + struct instruction *prev =
> + prev_insn_same_sym(file, insn);
> +
> + if (!prev || prev->type != INSN_BUG) {
> + WARN_INSN(insn, "no-cfi indirect call!");
> + warnings++;

Do we not care about indirect calls from !STT_FUNC?

--
Josh