From: Greg Kroah-Hartman Date: Sun, 16 Mar 2025 16:32:44 +0000 (+0100) Subject: 6.6-stable patches X-Git-Tag: v6.6.84~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c15414aa27c56be1f371afed9e831f5be5133811;p=thirdparty%2Fkernel%2Fstable-queue.git 6.6-stable patches added patches: rust-init-fix-zeroable-implementation-for-option-nonnull-t-and-option-kbox-t.patch --- diff --git a/queue-6.6/rust-init-fix-zeroable-implementation-for-option-nonnull-t-and-option-kbox-t.patch b/queue-6.6/rust-init-fix-zeroable-implementation-for-option-nonnull-t-and-option-kbox-t.patch new file mode 100644 index 0000000000..1eda94d86c --- /dev/null +++ b/queue-6.6/rust-init-fix-zeroable-implementation-for-option-nonnull-t-and-option-kbox-t.patch @@ -0,0 +1,54 @@ +From df27cef153603b18a7d094b53cc3d5264ff32797 Mon Sep 17 00:00:00 2001 +From: Benno Lossin +Date: Wed, 5 Mar 2025 13:29:01 +0000 +Subject: rust: init: fix `Zeroable` implementation for `Option>` and `Option>` + +From: Benno Lossin + +commit df27cef153603b18a7d094b53cc3d5264ff32797 upstream. + +According to [1], `NonNull` and `#[repr(transparent)]` wrapper types +such as our custom `KBox` have the null pointer optimization only if +`T: Sized`. Thus remove the `Zeroable` implementation for the unsized +case. + +Link: https://doc.rust-lang.org/stable/std/option/index.html#representation [1] +Reported-by: Alice Ryhl +Closes: https://lore.kernel.org/rust-for-linux/CAH5fLghL+qzrD8KiCF1V3vf2YcC6aWySzkmaE2Zzrnh1gKj-hw@mail.gmail.com/ +Cc: stable@vger.kernel.org # v6.12+ (a custom patch will be needed for 6.6.y) +Fixes: 38cde0bd7b67 ("rust: init: add `Zeroable` trait and `init::zeroed` function") +Signed-off-by: Benno Lossin +Reviewed-by: Alice Ryhl +Reviewed-by: Andreas Hindborg +Link: https://lore.kernel.org/r/20250305132836.2145476-1-benno.lossin@proton.me +[ Added Closes tag and moved up the Reported-by one. - Miguel ] +Signed-off-by: Miguel Ojeda +Signed-off-by: Greg Kroah-Hartman +--- + rust/kernel/init.rs | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +--- a/rust/kernel/init.rs ++++ b/rust/kernel/init.rs +@@ -1310,17 +1310,14 @@ impl_zeroable! { + // SAFETY: `T: Zeroable` and `UnsafeCell` is `repr(transparent)`. + {} UnsafeCell, + +- // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee). ++ // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee: ++ // https://doc.rust-lang.org/stable/std/option/index.html#representation). + Option, Option, Option, Option, + Option, Option, + Option, Option, Option, Option, + Option, Option, +- +- // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee). +- // +- // In this case we are allowed to use `T: ?Sized`, since all zeros is the `None` variant. +- {} Option>, +- {} Option>, ++ {} Option>, ++ {} Option>, + + // SAFETY: `null` pointer is valid. + // diff --git a/queue-6.6/series b/queue-6.6/series index b754eeecd8..93e3a8a3fb 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -140,3 +140,4 @@ arm64-mm-populate-vmemmap-at-the-page-level-if-not-section-aligned.patch qlcnic-fix-memory-leak-issues-in-qlcnic_sriov_common.c.patch smb-client-fix-regression-with-guest-option.patch rust-disallow-btf-generation-with-rust-lto.patch +rust-init-fix-zeroable-implementation-for-option-nonnull-t-and-option-kbox-t.patch