[PATCH] cfi: rust: pass -Zpatchable-function-entry on all architectures

Sami Tolvanen samitolvanen at google.com
Wed Oct 9 09:48:03 PDT 2024


On Tue, Oct 8, 2024 at 10:37 AM Alice Ryhl <aliceryhl at google.com> wrote:
>
> The KCFI sanitizer stores the CFI tag of a function just before its
> machine code. However, the patchable-function-entry flag can be used to
> introduce additional nop instructions before the machine code, taking up
> the space that normally holds the CFI tag. In this case, a backwards
> offset is applied to the CFI tag to move them out of the way of the nop
> instructions. To ensure that C and Rust agree on the offset used by CFI
> tags, pass the -Zpatchable-function-entry to rustc whenever it is passed
> to the C compiler.
>
> The required rustc version is bumped to 1.81.0 to ensure that the
> -Zpatchable-function-entry flag is available when CFI is used.
>
> Fixes: ca627e636551 ("rust: cfi: add support for CFI_CLANG with Rust")
> Signed-off-by: Alice Ryhl <aliceryhl at google.com>

Reviewed-by: Sami Tolvanen <samitolvanen at google.com>

Sami



More information about the linux-riscv mailing list