From: Greg Kroah-Hartman Date: Thu, 2 Apr 2026 12:00:02 +0000 (+0200) Subject: 6.6-stable patches X-Git-Tag: v6.6.132~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73e9b5c72b95ea1bc67e2e247731ad2b4b528cce;p=thirdparty%2Fkernel%2Fstable-queue.git 6.6-stable patches added patches: revert-rust-pin-init-add-references-to-previously-initialized-fields.patch revert-rust-pin-init-internal-init-document-load-bearing-fact-of-field-accessors.patch series --- diff --git a/queue-6.6/revert-rust-pin-init-add-references-to-previously-initialized-fields.patch b/queue-6.6/revert-rust-pin-init-add-references-to-previously-initialized-fields.patch new file mode 100644 index 0000000000..52d20c6732 --- /dev/null +++ b/queue-6.6/revert-rust-pin-init-add-references-to-previously-initialized-fields.patch @@ -0,0 +1,210 @@ +From e7c2a38219274d704b6eb02c44fb5ed32b9ecdbe Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Thu, 2 Apr 2026 13:59:13 +0200 +Subject: Revert "rust: pin-init: add references to previously initialized fields" + +From: Greg Kroah-Hartman + +This reverts commit c28fc9b0dbc7ae5426689cde4f47c5e32dbf80fc which is +commit 42415d163e5df6db799c7de6262d707e402c2c7e upstream. + +It breaks the build at this time. + +Link: https://lore.kernel.org/r/20260402112712.110869-1-ojeda@kernel.org +Reported-by: Miguel Ojeda +Cc: Benno Lossin +Cc: Gary Guo +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Greg Kroah-Hartman +--- + rust/kernel/init/macros.rs | 144 +++++++++------------------------------------ + 1 file changed, 31 insertions(+), 113 deletions(-) + +--- a/rust/kernel/init/macros.rs ++++ b/rust/kernel/init/macros.rs +@@ -964,54 +964,35 @@ macro_rules! __pin_data { + @pinned($($(#[$($p_attr:tt)*])* $pvis:vis $p_field:ident : $p_type:ty),* $(,)?), + @not_pinned($($(#[$($attr:tt)*])* $fvis:vis $field:ident : $type:ty),* $(,)?), + ) => { +- $crate::macros::paste! { +- // For every field, we create a projection function according to its projection type. If a +- // field is structurally pinned, then it must be initialized via `PinInit`, if it is not +- // structurally pinned, then it can be initialized via `Init`. +- // +- // The functions are `unsafe` to prevent accidentally calling them. +- #[allow(dead_code, non_snake_case)] +- #[expect(clippy::missing_safety_doc)] +- impl<$($impl_generics)*> $pin_data<$($ty_generics)*> +- where $($whr)* +- { +- $( +- $(#[$($p_attr)*])* +- $pvis unsafe fn $p_field( +- self, +- slot: *mut $p_type, +- init: impl $crate::init::PinInit<$p_type, E>, +- ) -> ::core::result::Result<(), E> { +- unsafe { $crate::init::PinInit::__pinned_init(init, slot) } +- } +- +- $(#[$($p_attr)*])* +- $pvis unsafe fn [<__project_ $p_field>]<'__slot>( +- self, +- slot: &'__slot mut $p_type, +- ) -> ::core::pin::Pin<&'__slot mut $p_type> { +- unsafe { ::core::pin::Pin::new_unchecked(slot) } +- } +- )* +- $( +- $(#[$($attr)*])* +- $fvis unsafe fn $field( +- self, +- slot: *mut $type, +- init: impl $crate::init::Init<$type, E>, +- ) -> ::core::result::Result<(), E> { +- unsafe { $crate::init::Init::__init(init, slot) } +- } +- +- $(#[$($attr)*])* +- $fvis unsafe fn [<__project_ $field>]<'__slot>( +- self, +- slot: &'__slot mut $type, +- ) -> &'__slot mut $type { +- slot +- } +- )* +- } ++ // For every field, we create a projection function according to its projection type. If a ++ // field is structurally pinned, then it must be initialized via `PinInit`, if it is not ++ // structurally pinned, then it can be initialized via `Init`. ++ // ++ // The functions are `unsafe` to prevent accidentally calling them. ++ #[allow(dead_code)] ++ impl<$($impl_generics)*> $pin_data<$($ty_generics)*> ++ where $($whr)* ++ { ++ $( ++ $(#[$($p_attr)*])* ++ $pvis unsafe fn $p_field( ++ self, ++ slot: *mut $p_type, ++ init: impl $crate::init::PinInit<$p_type, E>, ++ ) -> ::core::result::Result<(), E> { ++ unsafe { $crate::init::PinInit::__pinned_init(init, slot) } ++ } ++ )* ++ $( ++ $(#[$($attr)*])* ++ $fvis unsafe fn $field( ++ self, ++ slot: *mut $type, ++ init: impl $crate::init::Init<$type, E>, ++ ) -> ::core::result::Result<(), E> { ++ unsafe { $crate::init::Init::__init(init, slot) } ++ } ++ )* + } + }; + } +@@ -1205,13 +1186,6 @@ macro_rules! __init_internal { + // return when an error/panic occurs. + // We also use the `data` to require the correct trait (`Init` or `PinInit`) for `$field`. + unsafe { $data.$field(::core::ptr::addr_of_mut!((*$slot).$field), init)? }; +- // SAFETY: +- // - the project function does the correct field projection, +- // - the field has been initialized, +- // - the reference is only valid until the end of the initializer. +- #[allow(unused_variables, unused_assignments)] +- let $field = $crate::macros::paste!(unsafe { $data.[< __project_ $field >](&mut (*$slot).$field) }); +- + // Create the drop guard: + // + // We rely on macro hygiene to make it impossible for users to access this local variable. +@@ -1243,14 +1217,6 @@ macro_rules! __init_internal { + // SAFETY: `slot` is valid, because we are inside of an initializer closure, we + // return when an error/panic occurs. + unsafe { $crate::init::Init::__init(init, ::core::ptr::addr_of_mut!((*$slot).$field))? }; +- +- // SAFETY: +- // - the field is not structurally pinned, since the line above must compile, +- // - the field has been initialized, +- // - the reference is only valid until the end of the initializer. +- #[allow(unused_variables, unused_assignments)] +- let $field = unsafe { &mut (*$slot).$field }; +- + // Create the drop guard: + // + // We rely on macro hygiene to make it impossible for users to access this local variable. +@@ -1269,7 +1235,7 @@ macro_rules! __init_internal { + ); + } + }; +- (init_slot(): // No `use_data`, so all fields are not structurally pinned ++ (init_slot($($use_data:ident)?): + @data($data:ident), + @slot($slot:ident), + @guards($($guards:ident,)*), +@@ -1283,15 +1249,6 @@ macro_rules! __init_internal { + // SAFETY: The memory at `slot` is uninitialized. + unsafe { ::core::ptr::write(::core::ptr::addr_of_mut!((*$slot).$field), $field) }; + } +- +- #[allow(unused_variables, unused_assignments)] +- // SAFETY: +- // - the field is not structurally pinned, since no `use_data` was required to create this +- // initializer, +- // - the field has been initialized, +- // - the reference is only valid until the end of the initializer. +- let $field = unsafe { &mut (*$slot).$field }; +- + // Create the drop guard: + // + // We rely on macro hygiene to make it impossible for users to access this local variable. +@@ -1302,46 +1259,7 @@ macro_rules! __init_internal { + $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) + }; + +- $crate::__init_internal!(init_slot(): +- @data($data), +- @slot($slot), +- @guards([< __ $field _guard >], $($guards,)*), +- @munch_fields($($rest)*), +- ); +- } +- }; +- (init_slot($use_data:ident): +- @data($data:ident), +- @slot($slot:ident), +- @guards($($guards:ident,)*), +- // Init by-value. +- @munch_fields($field:ident $(: $val:expr)?, $($rest:tt)*), +- ) => { +- { +- $(let $field = $val;)? +- // Initialize the field. +- // +- // SAFETY: The memory at `slot` is uninitialized. +- unsafe { ::core::ptr::write(::core::ptr::addr_of_mut!((*$slot).$field), $field) }; +- } +- // SAFETY: +- // - the project function does the correct field projection, +- // - the field has been initialized, +- // - the reference is only valid until the end of the initializer. +- #[allow(unused_variables, unused_assignments)] +- let $field = $crate::macros::paste!(unsafe { $data.[< __project_ $field >](&mut (*$slot).$field) }); +- +- // Create the drop guard: +- // +- // We rely on macro hygiene to make it impossible for users to access this local variable. +- // We use `paste!` to create new hygiene for `$field`. +- $crate::macros::paste! { +- // SAFETY: We forget the guard later when initialization has succeeded. +- let [< __ $field _guard >] = unsafe { +- $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) +- }; +- +- $crate::__init_internal!(init_slot($use_data): ++ $crate::__init_internal!(init_slot($($use_data)?): + @data($data), + @slot($slot), + @guards([<$field>], $($guards,)*), diff --git a/queue-6.6/revert-rust-pin-init-internal-init-document-load-bearing-fact-of-field-accessors.patch b/queue-6.6/revert-rust-pin-init-internal-init-document-load-bearing-fact-of-field-accessors.patch new file mode 100644 index 0000000000..ec5e3d76d4 --- /dev/null +++ b/queue-6.6/revert-rust-pin-init-internal-init-document-load-bearing-fact-of-field-accessors.patch @@ -0,0 +1,68 @@ +From a48a8a91704ffa94dbe0140ea987809e1c50e6ca Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Thu, 2 Apr 2026 13:57:54 +0200 +Subject: Revert "rust: pin-init: internal: init: document load-bearing fact of field accessors" + +From: Greg Kroah-Hartman + +This reverts commit 0890fba6129dc244bd6d61756dda1ec69b24f60b which is +commit 580cc37b1de4fcd9997c48d7080e744533f09f36 upstream. + +It breaks the build at this time. + +Link: https://lore.kernel.org/r/20260402112712.110869-1-ojeda@kernel.org +Reported-by: Miguel Ojeda +Cc: Benno Lossin +Cc: Gary Guo +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Greg Kroah-Hartman +--- + rust/kernel/init/macros.rs | 16 ---------------- + 1 file changed, 16 deletions(-) + +--- a/rust/kernel/init/macros.rs ++++ b/rust/kernel/init/macros.rs +@@ -1205,10 +1205,6 @@ macro_rules! __init_internal { + // return when an error/panic occurs. + // We also use the `data` to require the correct trait (`Init` or `PinInit`) for `$field`. + unsafe { $data.$field(::core::ptr::addr_of_mut!((*$slot).$field), init)? }; +- // NOTE: the field accessor ensures that the initialized field is properly aligned. +- // Unaligned fields will cause the compiler to emit E0793. We do not support +- // unaligned fields since `Init::__init` requires an aligned pointer; the call to +- // `ptr::write` below has the same requirement. + // SAFETY: + // - the project function does the correct field projection, + // - the field has been initialized, +@@ -1248,10 +1244,6 @@ macro_rules! __init_internal { + // return when an error/panic occurs. + unsafe { $crate::init::Init::__init(init, ::core::ptr::addr_of_mut!((*$slot).$field))? }; + +- // NOTE: the field accessor ensures that the initialized field is properly aligned. +- // Unaligned fields will cause the compiler to emit E0793. We do not support +- // unaligned fields since `Init::__init` requires an aligned pointer; the call to +- // `ptr::write` below has the same requirement. + // SAFETY: + // - the field is not structurally pinned, since the line above must compile, + // - the field has been initialized, +@@ -1292,10 +1284,6 @@ macro_rules! __init_internal { + unsafe { ::core::ptr::write(::core::ptr::addr_of_mut!((*$slot).$field), $field) }; + } + +- // NOTE: the field accessor ensures that the initialized field is properly aligned. +- // Unaligned fields will cause the compiler to emit E0793. We do not support +- // unaligned fields since `Init::__init` requires an aligned pointer; the call to +- // `ptr::write` below has the same requirement. + #[allow(unused_variables, unused_assignments)] + // SAFETY: + // - the field is not structurally pinned, since no `use_data` was required to create this +@@ -1336,10 +1324,6 @@ macro_rules! __init_internal { + // SAFETY: The memory at `slot` is uninitialized. + unsafe { ::core::ptr::write(::core::ptr::addr_of_mut!((*$slot).$field), $field) }; + } +- // NOTE: the field accessor ensures that the initialized field is properly aligned. +- // Unaligned fields will cause the compiler to emit E0793. We do not support +- // unaligned fields since `Init::__init` requires an aligned pointer; the call to +- // `ptr::write` below has the same requirement. + // SAFETY: + // - the project function does the correct field projection, + // - the field has been initialized, diff --git a/queue-6.6/series b/queue-6.6/series new file mode 100644 index 0000000000..e4f64515b8 --- /dev/null +++ b/queue-6.6/series @@ -0,0 +1,2 @@ +revert-rust-pin-init-internal-init-document-load-bearing-fact-of-field-accessors.patch +revert-rust-pin-init-add-references-to-previously-initialized-fields.patch