Re: [PATCH] x86/Kconfig: make CFI_AUTO_DEFAULT depend on !RUST

From: Peter Zijlstra
Date: Thu Apr 10 2025 - 09:16:46 EST


On Thu, Apr 10, 2025 at 02:45:26PM +0200, Peter Zijlstra wrote:
> On Thu, Apr 10, 2025 at 02:36:02PM +0200, Peter Zijlstra wrote:
> > On Thu, Apr 10, 2025 at 11:54:20AM +0000, Paweł Anikiel wrote:
> > > Calling core::fmt::write() from rust code while FineIBT is enabled
> > > results in a kernel panic:

> > > This happens because core::fmt::write() calls
> > > core::fmt::rt::Argument::fmt(), which currently has CFI disabled:
> > >
> > > library/core/src/fmt/rt.rs:
> > > 171 // FIXME: Transmuting formatter in new and indirectly branching to/calling
> > > 172 // it here is an explicit CFI violation.
> > > 173 #[allow(inline_no_sanitize)]
> > > 174 #[no_sanitize(cfi, kcfi)]
> > > 175 #[inline]
> > > 176 pub(super) unsafe fn fmt(&self, f: &mut Formatter<'_>) -> Result {
> > >

Miguel, I cannot find this code in the kernel tree. Is this again
because Rust is not free-standing and relies on external code?

Can you please fix that. Building against external code that is not
under our control is a problem.