Re: [PATCH] x86: Enable IBT in Rust if enabled in C

From: Miguel Ojeda
Date: Wed Oct 11 2023 - 13:44:42 EST


On Tue, Oct 10, 2023 at 12:43 AM Matthew Maurer <mmaurer@xxxxxxxxxx> wrote:
>
> These flags are not made conditional on compiler support because at the
> moment exactly one version of rustc supported, and that one supports
> these flags.
>
> Building without these additional flags will manifest as objtool
> printing a large number of errors about missing ENDBR and if CFI is
> enabled (not currently possible) will result in incorrectly structured
> function prefixes.
>
> Signed-off-by: Matthew Maurer <mmaurer@xxxxxxxxxx>
> ---
>
> Split out the IBT additions as per
> https://lkml.kernel.org/linux-fsdevel/CANiq72kK6ppBE7j=z7uua1cJMKaLoR5U3NUAZXT5MrNEs9ZhfQ@xxxxxxxxxxxxxx/

Thanks a lot Matthew for this! It is great to see those warnings
finally go away.

I have added the `objtool` pass to the intermediate Rust object files
and, with that + this patch applied + IBT enabled (but not
rethunk/retpoline), the only thing I see is:

samples/rust/rust_print.o: warning: objtool: init_module(): not an
indirect call target
samples/rust/rust_print.o: warning: objtool: cleanup_module(): not
an indirect call target

But we can fix those independently of this (ideally we want to reuse
the C macros, rather than putting more complexity in `module!`), so:

Acked-by: Miguel Ojeda <ojeda@xxxxxxxxxx>

I will send the patch for adding `objtool`.

Cheers,
Miguel