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

From: Paweł Anikiel
Date: Thu Apr 10 2025 - 09:22:05 EST


On Thu, Apr 10, 2025 at 3:09 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> 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?

The code I referenced is from here:
https://github.com/rust-lang/rust/blob/master/library/core/src/fmt/rt.rs#L139