rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sami Tolvanen <samitolvanen@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Paweł Anikiel" <panikiel@google.com>,
	"Kees Cook" <kees@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	rust-for-linux@vger.kernel.org,
	"Josh Poimboeuf" <jpoimboe@redhat.com>
Subject: Re: [PATCH] objtool: Detect __nocfi calls
Date: Thu, 10 Apr 2025 19:43:34 +0000	[thread overview]
Message-ID: <20250410194334.GA3248459@google.com> (raw)
In-Reply-To: <20250410154556.GB9003@noisy.programming.kicks-ass.net>

Hi Peter,

On Thu, Apr 10, 2025 at 05:45:56PM +0200, Peter Zijlstra wrote:
> On Thu, Apr 10, 2025 at 03:25:22PM +0200, Peter Zijlstra wrote:
> 
> > I should get objtool to warn about those. They undermine the point of
> > CFI.
> 
> ---
> Subject: objtool: Detect __nocfi calls
> 
> Detect and WARN about no_sanitize(kcfi) indirect calls.
> 
> Apparently there were a few in some Rust 'core' that got included in the
> kernel and things went *bang*.
> 
> This is not a supported form for kernel code. So detect and warn about
> it.

Cool, this looks useful!

> Adds an annotation for the two cases where we have to live with them:
> 
>  - EFI stubs;
>  - kexec handover.
> 
> Notably, EFI calls fully disable IBT, as such using runtime EFI services
> is a significant security issue. If you can exploit the kexec handover,
> you get to keep it.

OK, with this applied I now see a warning about the __nocfi call in
Rust code:

vmlinux.o: warning: objtool: _RNvNtCsjWi3sh0wSlE_4core3fmt5write+0x170: no-cfi indirect call!

But an allmodconfig build reveals a few more warnings:

arch/x86/kvm/kvm.o: warning: objtool: x86_emulate_insn+0xaf7: no-cfi indirect call!
arch/x86/kvm/kvm.o: warning: objtool: em_das+0x290: no-cfi indirect call!
arch/x86/kvm/kvm.o: warning: objtool: em_imul_3op+0x15f: no-cfi indirect call!
arch/x86/kvm/kvm.o: warning: objtool: em_aam+0x21c: no-cfi indirect call!
arch/x86/kvm/kvm.o: warning: objtool: em_aad+0x1dc: no-cfi indirect call!
arch/x86/kvm/kvm.o: warning: objtool: em_loop+0x312: no-cfi indirect call!
arch/x86/kvm/kvm.o: warning: objtool: em_cmpxchg+0x329: no-cfi indirect call!
arch/x86/kvm/kvm.o: warning: objtool: em_bsf_c+0x1b7: no-cfi indirect call!
arch/x86/kvm/kvm.o: warning: objtool: em_bsr_c+0x1b7: no-cfi indirect call!
arch/x86/kvm/kvm-intel.o: warning: objtool: vmx_do_interrupt_irqoff+0xe: no-cfi indirect call!
drivers/misc/lkdtm/lkdtm.o: warning: objtool: execute_location+0x5a: no-cfi indirect call!
drivers/pci/controller/pci-hyperv.o: warning: objtool: hv_do_hypercall+0x150: no-cfi indirect call!
drivers/hv/hv_balloon.o: warning: objtool: hv_free_page_report+0x5da: no-cfi indirect call!
drivers/hv/hv_vmbus.o: warning: objtool: hv_post_message+0x457: no-cfi indirect call!
drivers/hv/hv_vmbus.o: warning: objtool: vmbus_set_event+0x2a2: no-cfi indirect call!
vmlinux.o: warning: objtool: hyperv_flush_tlb_multi+0xe96: no-cfi indirect call!
vmlinux.o: warning: objtool: hv_do_hypercall+0x12b: no-cfi indirect call!
vmlinux.o: warning: objtool: hyperv_flush_guest_mapping+0x2e3: no-cfi indirect call!
vmlinux.o: warning: objtool: hyperv_flush_guest_mapping_range+0x36a: no-cfi indirect call!
vmlinux.o: warning: objtool: hv_do_hypercall+0x150: no-cfi indirect call!
vmlinux.o: warning: objtool: hv_snp_boot_ap+0xb08: no-cfi indirect call!
vmlinux.o: warning: objtool: hv_vtom_set_host_visibility+0x54a: no-cfi indirect call!
vmlinux.o: warning: objtool: __send_ipi_one+0x362: no-cfi indirect call!
vmlinux.o: warning: objtool: __send_ipi_mask_ex+0x655: no-cfi indirect call!
vmlinux.o: warning: objtool: __send_ipi_mask+0x635: no-cfi indirect call!
vmlinux.o: warning: objtool: hv_do_hypercall+0x150: no-cfi indirect call!
vmlinux.o: warning: objtool: hv_query_ext_cap+0x175: no-cfi indirect call!
vmlinux.o: warning: objtool: get_vtl+0x38c: no-cfi indirect call!
vmlinux.o: warning: objtool: hv_get_partition_id+0x224: no-cfi indirect call!

Sami

  parent reply	other threads:[~2025-04-10 19:43 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 11:54 [PATCH] x86/Kconfig: make CFI_AUTO_DEFAULT depend on !RUST Paweł Anikiel
2025-04-10 12:36 ` Peter Zijlstra
2025-04-10 12:45   ` Peter Zijlstra
2025-04-10 13:09     ` Peter Zijlstra
2025-04-10 13:18       ` Paweł Anikiel
2025-04-10 13:20       ` Alice Ryhl
2025-04-10 13:21       ` Miguel Ojeda
2025-04-10 13:26         ` Peter Zijlstra
2025-04-10 13:27           ` Miguel Ojeda
2025-04-10 13:34             ` Peter Zijlstra
2025-04-10 13:54               ` Miguel Ojeda
2025-04-10 13:57                 ` Peter Zijlstra
2025-04-10 14:05                   ` Miguel Ojeda
2025-04-10 14:15                     ` Peter Zijlstra
2025-04-10 15:04                       ` Alice Ryhl
2025-04-10 13:59               ` Alice Ryhl
2025-04-10 14:08                 ` Peter Zijlstra
2025-04-10 14:54                   ` Miguel Ojeda
2025-04-10 15:14                     ` Peter Zijlstra
2025-04-10 18:01                       ` Miguel Ojeda
2025-04-10 15:02                   ` Alice Ryhl
2025-04-15 15:15                 ` Miguel Ojeda
2025-04-16 10:38                   ` Alice Ryhl
2025-04-16 20:20                   ` Peter Zijlstra
2025-04-16 21:51                     ` Kees Cook
2025-04-17  8:18                       ` Peter Zijlstra
2025-04-17 18:40                         ` Miguel Ojeda
2025-04-18  9:45                           ` Peter Zijlstra
2025-05-06 22:19                           ` Miguel Ojeda
2025-05-09  8:46                             ` Alice Ryhl
2025-05-09  9:04                               ` Miguel Ojeda
2025-05-09  9:11                                 ` Paweł Anikiel
2025-05-09  9:39                                   ` Alice Ryhl
2025-05-09 16:34                                     ` Kees Cook
2025-05-09 19:33                                   ` Miguel Ojeda
2025-04-10 13:12     ` Paweł Anikiel
2025-04-10 13:25       ` Peter Zijlstra
2025-04-10 15:45         ` [PATCH] objtool: Detect __nocfi calls Peter Zijlstra
2025-04-10 19:09           ` Josh Poimboeuf
2025-04-11  6:46             ` Peter Zijlstra
2025-04-10 19:32           ` Miguel Ojeda
2025-04-10 19:43           ` Sami Tolvanen [this message]
2025-04-11  6:44             ` Peter Zijlstra
2025-04-12 12:31               ` Peter Zijlstra
2025-04-10 13:50       ` [PATCH] x86/Kconfig: make CFI_AUTO_DEFAULT depend on !RUST Miguel Ojeda

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=20250410194334.GA3248459@google.com \
    --to=samitolvanen@google.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=jpoimboe@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=panikiel@google.com \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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;
as well as URLs for NNTP newsgroup(s).