]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: cpumask: Mark CpumaskVar as transparent
authorBaptiste Lepers <baptiste.lepers@gmail.com>
Tue, 12 Aug 2025 14:42:11 +0000 (16:42 +0200)
committerViresh Kumar <viresh.kumar@linaro.org>
Thu, 14 Aug 2025 04:25:47 +0000 (09:55 +0530)
Unsafe code in CpumaskVar's methods assumes that the type has the same
layout as `bindings::cpumask_var_t`. This is not guaranteed by
the default struct representation in Rust, but requires specifying the
`transparent` representation.

Fixes: 8961b8cb3099a ("rust: cpumask: Add initial abstractions")
Signed-off-by: Baptiste Lepers <baptiste.lepers@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
rust/kernel/cpumask.rs

index e311ab9038dfdac01cdbfe5a7303caf5922813fd..c1d17826ae7bb58f5a1e681db43f05c9e4c93894 100644 (file)
@@ -212,6 +212,7 @@ impl Cpumask {
 /// }
 /// assert_eq!(mask2.weight(), count);
 /// ```
+#[repr(transparent)]
 pub struct CpumaskVar {
     #[cfg(CONFIG_CPUMASK_OFFSTACK)]
     ptr: NonNull<Cpumask>,