Commit 0c559323 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'rust-fixes-6.12' of https://github.com/Rust-for-Linux/linux

Pull Rust fixes from Miguel Ojeda:
 "Toolchain and infrastructure:

   - Fix/improve a couple 'depends on' on the newly added CFI/KASAN
     suppport to avoid build errors/warnings

   - Fix ARCH_SLAB_MINALIGN multiple definition error for RISC-V under
     !CONFIG_MMU

   - Clean upcoming (Rust 1.83.0) Clippy warnings

  'kernel' crate:

   - 'sync' module: fix soundness issue by requiring 'T: Sync' for
     'LockedBy::access'; and fix helpers build error under PREEMPT_RT

   - Fix trivial sorting issue ('rustfmtcheck') on the v6.12 Rust merge"

* tag 'rust-fixes-6.12' of https://github.com/Rust-for-Linux/linux:
  rust: kunit: use C-string literals to clean warning
  cfi: encode cfi normalized integers + kasan/gcov bug in Kconfig
  rust: KASAN+RETHUNK requires rustc 1.83.0
  rust: cfi: fix `patchable-function-entry` starting version
  rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT
  rust: fix `ARCH_SLAB_MINALIGN` multiple definition error
  rust: sync: require `T: Sync` for `LockedBy::access`
  rust: kernel: sort Rust modules
parents 263a25de 05cef2c4
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -838,7 +838,7 @@ config CFI_CLANG
config CFI_ICALL_NORMALIZE_INTEGERS
	bool "Normalize CFI tags for integers"
	depends on CFI_CLANG
	depends on $(cc-option,-fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers)
	depends on HAVE_CFI_ICALL_NORMALIZE_INTEGERS
	help
	  This option normalizes the CFI tags for integer types so that all
	  integer types of the same size and signedness receive the same CFI
@@ -851,6 +851,22 @@ config CFI_ICALL_NORMALIZE_INTEGERS

	  This option is necessary for using CFI with Rust. If unsure, say N.

config HAVE_CFI_ICALL_NORMALIZE_INTEGERS
	def_bool !GCOV_KERNEL && !KASAN
	depends on CFI_CLANG
	depends on $(cc-option,-fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers)
	help
	  Is CFI_ICALL_NORMALIZE_INTEGERS supported with the set of compilers
	  currently in use?

	  This option defaults to false if GCOV or KASAN is enabled, as there is
	  an LLVM bug that makes normalized integers tags incompatible with
	  KASAN and GCOV. Kconfig currently does not have the infrastructure to
	  detect whether your rustc compiler contains the fix for this bug, so
	  it is assumed that it doesn't. If your compiler has the fix, you can
	  explicitly enable this option in your config file. The Kconfig logic
	  needed to detect this will be added in a future kernel release.

config CFI_PERMISSIVE
	bool "Use CFI in permissive mode"
	depends on CFI_CLANG
+3 −2
Original line number Diff line number Diff line
@@ -1946,10 +1946,11 @@ config RUST
	depends on !GCC_PLUGIN_RANDSTRUCT
	depends on !RANDSTRUCT
	depends on !DEBUG_INFO_BTF || PAHOLE_HAS_LANG_EXCLUDE
	depends on !CFI_CLANG || RUSTC_VERSION >= 107900 && $(cc-option,-fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers)
	depends on !CFI_CLANG || RUSTC_VERSION >= 107900 && HAVE_CFI_ICALL_NORMALIZE_INTEGERS
	select CFI_ICALL_NORMALIZE_INTEGERS if CFI_CLANG
	depends on !CALL_PADDING || RUSTC_VERSION >= 108000
	depends on !CALL_PADDING || RUSTC_VERSION >= 108100
	depends on !KASAN_SW_TAGS
	depends on !(MITIGATION_RETHUNK && KASAN) || RUSTC_VERSION >= 108300
	help
	  Enables Rust support in the kernel.

+5 −0
Original line number Diff line number Diff line
@@ -24,3 +24,8 @@
# These functions use the `__preserve_most` calling convention, which neither bindgen
# nor Rust currently understand, and which Clang currently declares to be unstable.
--blocklist-function __list_.*_report

# These constants are sometimes not recognized by bindgen depending on config.
# We use const helpers to aid bindgen, to avoid conflicts when constants are
# recognized, block generation of the non-helper constants.
--blocklist-item ARCH_SLAB_MINALIGN
+6 −0
Original line number Diff line number Diff line
@@ -7,3 +7,9 @@ void rust_helper_mutex_lock(struct mutex *lock)
{
	mutex_lock(lock);
}

void rust_helper___mutex_init(struct mutex *mutex, const char *name,
			      struct lock_class_key *key)
{
	__mutex_init(mutex, name, key);
}
+2 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ pub fn err(args: fmt::Arguments<'_>) {
    #[cfg(CONFIG_PRINTK)]
    unsafe {
        bindings::_printk(
            b"\x013%pA\0".as_ptr() as _,
            c"\x013%pA".as_ptr() as _,
            &args as *const _ as *const c_void,
        );
    }
@@ -34,7 +34,7 @@ pub fn info(args: fmt::Arguments<'_>) {
    #[cfg(CONFIG_PRINTK)]
    unsafe {
        bindings::_printk(
            b"\x016%pA\0".as_ptr() as _,
            c"\x016%pA".as_ptr() as _,
            &args as *const _ as *const c_void,
        );
    }
Loading