* FAILED: patch "[PATCH] rust: lockdep: Remove support for dynamically allocated" failed to apply to 6.6-stable tree
@ 2025-03-16 7:15 gregkh
2025-03-18 17:59 ` Boqun Feng
2025-03-18 18:04 ` [PATCH 6.6.y] rust: lockdep: Remove support for dynamically allocated LockClassKeys Boqun Feng
0 siblings, 2 replies; 5+ messages in thread
From: gregkh @ 2025-03-16 7:15 UTC (permalink / raw)
To: levymitchell0, aliceryhl, benno.lossin, boqun.feng, mingo; +Cc: stable
The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 966944f3711665db13e214fef6d02982c49bb972
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025031632-divorcee-duly-868e@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 966944f3711665db13e214fef6d02982c49bb972 Mon Sep 17 00:00:00 2001
From: Mitchell Levy <levymitchell0@gmail.com>
Date: Fri, 7 Mar 2025 15:27:00 -0800
Subject: [PATCH] rust: lockdep: Remove support for dynamically allocated
LockClassKeys
Currently, dynamically allocated LockCLassKeys can be used from the Rust
side without having them registered. This is a soundness issue, so
remove them.
Fixes: 6ea5aa08857a ("rust: sync: introduce `LockClassKey`")
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Mitchell Levy <levymitchell0@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250307232717.1759087-11-boqun.feng@gmail.com
diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
index 3498fb344dc9..16eab9138b2b 100644
--- a/rust/kernel/sync.rs
+++ b/rust/kernel/sync.rs
@@ -30,28 +30,20 @@
unsafe impl Sync for LockClassKey {}
impl LockClassKey {
- /// Creates a new lock class key.
- pub const fn new() -> Self {
- Self(Opaque::uninit())
- }
-
pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
self.0.get()
}
}
-impl Default for LockClassKey {
- fn default() -> Self {
- Self::new()
- }
-}
-
/// Defines a new static lock class and returns a pointer to it.
#[doc(hidden)]
#[macro_export]
macro_rules! static_lock_class {
() => {{
- static CLASS: $crate::sync::LockClassKey = $crate::sync::LockClassKey::new();
+ static CLASS: $crate::sync::LockClassKey =
+ // SAFETY: lockdep expects uninitialized memory when it's handed a statically allocated
+ // lock_class_key
+ unsafe { ::core::mem::MaybeUninit::uninit().assume_init() };
&CLASS
}};
}
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: FAILED: patch "[PATCH] rust: lockdep: Remove support for dynamically allocated" failed to apply to 6.6-stable tree
2025-03-16 7:15 FAILED: patch "[PATCH] rust: lockdep: Remove support for dynamically allocated" failed to apply to 6.6-stable tree gregkh
@ 2025-03-18 17:59 ` Boqun Feng
2025-03-18 19:59 ` Greg KH
2025-03-18 18:04 ` [PATCH 6.6.y] rust: lockdep: Remove support for dynamically allocated LockClassKeys Boqun Feng
1 sibling, 1 reply; 5+ messages in thread
From: Boqun Feng @ 2025-03-18 17:59 UTC (permalink / raw)
To: gregkh; +Cc: levymitchell0, aliceryhl, benno.lossin, mingo, stable
Hi Greg,
On Sun, Mar 16, 2025 at 08:15:32AM +0100, gregkh@linuxfoundation.org wrote:
>
> The patch below does not apply to the 6.6-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
>
> To reproduce the conflict and resubmit, you may use the following commands:
>
> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
> git checkout FETCH_HEAD
> git cherry-pick -x 966944f3711665db13e214fef6d02982c49bb972
It's weird because `cherry-pick` works for me:
$ git cherry-pick -x 966944f3711665db13e214fef6d02982c49bb972
Auto-merging rust/kernel/sync.rs
[stable-6.6 f5771e91eac3] rust: lockdep: Remove support for dynamically allocated LockClassKeys
Author: Mitchell Levy <levymitchell0@gmail.com>
Date: Fri Mar 7 15:27:00 2025 -0800
1 file changed, 4 insertions(+), 6 deletions(-)
my base is 594a1dd5138a ("Linux 6.6.83").
I checked the original commit in Linus' tree, it removes the `impl
Default` which doesn't exist in 6.6, however it seems my `cherry-pick`
can realise and fix this! Anyway I will send the fixed patch soon.
Regards,
Boqun
> # <resolve conflicts, build, test, etc.>
> git commit -s
> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025031632-divorcee-duly-868e@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
>
> Possible dependencies:
>
>
>
> thanks,
>
> greg k-h
>
> ------------------ original commit in Linus's tree ------------------
>
> From 966944f3711665db13e214fef6d02982c49bb972 Mon Sep 17 00:00:00 2001
> From: Mitchell Levy <levymitchell0@gmail.com>
> Date: Fri, 7 Mar 2025 15:27:00 -0800
> Subject: [PATCH] rust: lockdep: Remove support for dynamically allocated
> LockClassKeys
>
> Currently, dynamically allocated LockCLassKeys can be used from the Rust
> side without having them registered. This is a soundness issue, so
> remove them.
>
> Fixes: 6ea5aa08857a ("rust: sync: introduce `LockClassKey`")
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Mitchell Levy <levymitchell0@gmail.com>
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Reviewed-by: Benno Lossin <benno.lossin@proton.me>
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/r/20250307232717.1759087-11-boqun.feng@gmail.com
>
> diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
> index 3498fb344dc9..16eab9138b2b 100644
> --- a/rust/kernel/sync.rs
> +++ b/rust/kernel/sync.rs
> @@ -30,28 +30,20 @@
> unsafe impl Sync for LockClassKey {}
>
> impl LockClassKey {
> - /// Creates a new lock class key.
> - pub const fn new() -> Self {
> - Self(Opaque::uninit())
> - }
> -
> pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
> self.0.get()
> }
> }
>
> -impl Default for LockClassKey {
> - fn default() -> Self {
> - Self::new()
> - }
> -}
> -
> /// Defines a new static lock class and returns a pointer to it.
> #[doc(hidden)]
> #[macro_export]
> macro_rules! static_lock_class {
> () => {{
> - static CLASS: $crate::sync::LockClassKey = $crate::sync::LockClassKey::new();
> + static CLASS: $crate::sync::LockClassKey =
> + // SAFETY: lockdep expects uninitialized memory when it's handed a statically allocated
> + // lock_class_key
> + unsafe { ::core::mem::MaybeUninit::uninit().assume_init() };
> &CLASS
> }};
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: FAILED: patch "[PATCH] rust: lockdep: Remove support for dynamically allocated" failed to apply to 6.6-stable tree
2025-03-18 17:59 ` Boqun Feng
@ 2025-03-18 19:59 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2025-03-18 19:59 UTC (permalink / raw)
To: Boqun Feng; +Cc: levymitchell0, aliceryhl, benno.lossin, mingo, stable
On Tue, Mar 18, 2025 at 10:59:58AM -0700, Boqun Feng wrote:
> Hi Greg,
>
> On Sun, Mar 16, 2025 at 08:15:32AM +0100, gregkh@linuxfoundation.org wrote:
> >
> > The patch below does not apply to the 6.6-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> >
> > To reproduce the conflict and resubmit, you may use the following commands:
> >
> > git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
> > git checkout FETCH_HEAD
> > git cherry-pick -x 966944f3711665db13e214fef6d02982c49bb972
>
> It's weird because `cherry-pick` works for me:
>
> $ git cherry-pick -x 966944f3711665db13e214fef6d02982c49bb972
> Auto-merging rust/kernel/sync.rs
> [stable-6.6 f5771e91eac3] rust: lockdep: Remove support for dynamically allocated LockClassKeys
> Author: Mitchell Levy <levymitchell0@gmail.com>
> Date: Fri Mar 7 15:27:00 2025 -0800
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> my base is 594a1dd5138a ("Linux 6.6.83").
>
> I checked the original commit in Linus' tree, it removes the `impl
> Default` which doesn't exist in 6.6, however it seems my `cherry-pick`
> can realise and fix this! Anyway I will send the fixed patch soon.
Yeah, git is smart, patch is not:
patching file rust/kernel/sync.rs
Hunk #1 FAILED at 30.
1 out of 1 hunk FAILED -- rejects in file rust/kernel/sync.rs
:(
thanks for the fixup.
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 6.6.y] rust: lockdep: Remove support for dynamically allocated LockClassKeys
2025-03-16 7:15 FAILED: patch "[PATCH] rust: lockdep: Remove support for dynamically allocated" failed to apply to 6.6-stable tree gregkh
2025-03-18 17:59 ` Boqun Feng
@ 2025-03-18 18:04 ` Boqun Feng
2025-03-18 20:12 ` Sasha Levin
1 sibling, 1 reply; 5+ messages in thread
From: Boqun Feng @ 2025-03-18 18:04 UTC (permalink / raw)
To: stable
Cc: gregkh, levymitchell0, aliceryhl, benno.lossin, boqun.feng, mingo,
ojeda
From: Mitchell Levy <levymitchell0@gmail.com>
Currently, dynamically allocated LockCLassKeys can be used from the Rust
side without having them registered. This is a soundness issue, so
remove them.
Fixes: 6ea5aa08857a ("rust: sync: introduce `LockClassKey`")
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Mitchell Levy <levymitchell0@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250307232717.1759087-11-boqun.feng@gmail.com
(cherry picked from commit 966944f3711665db13e214fef6d02982c49bb972)
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
rust/kernel/sync.rs | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
index d219ee518eff..8b40589b1028 100644
--- a/rust/kernel/sync.rs
+++ b/rust/kernel/sync.rs
@@ -26,11 +26,6 @@
unsafe impl Sync for LockClassKey {}
impl LockClassKey {
- /// Creates a new lock class key.
- pub const fn new() -> Self {
- Self(Opaque::uninit())
- }
-
pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
self.0.get()
}
@@ -41,7 +36,10 @@ pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
#[macro_export]
macro_rules! static_lock_class {
() => {{
- static CLASS: $crate::sync::LockClassKey = $crate::sync::LockClassKey::new();
+ static CLASS: $crate::sync::LockClassKey =
+ // SAFETY: lockdep expects uninitialized memory when it's handed a statically allocated
+ // lock_class_key
+ unsafe { ::core::mem::MaybeUninit::uninit().assume_init() };
&CLASS
}};
}
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 6.6.y] rust: lockdep: Remove support for dynamically allocated LockClassKeys
2025-03-18 18:04 ` [PATCH 6.6.y] rust: lockdep: Remove support for dynamically allocated LockClassKeys Boqun Feng
@ 2025-03-18 20:12 ` Sasha Levin
0 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2025-03-18 20:12 UTC (permalink / raw)
To: stable, boqun.feng; +Cc: Sasha Levin
[ Sasha's backport helper bot ]
Hi,
Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it
Found matching upstream commit: 966944f3711665db13e214fef6d02982c49bb972
WARNING: Author mismatch between patch and found commit:
Backport author: Boqun Feng<boqun.feng@gmail.com>
Commit author: Mitchell Levy<levymitchell0@gmail.com>
Status in newer kernel trees:
6.13.y | Present (different SHA1: 3e5d366aabae)
6.12.y | Present (different SHA1: c5b195dd9564)
Note: The patch differs from the upstream commit:
---
1: 966944f371166 ! 1: b037a70e0eccb rust: lockdep: Remove support for dynamically allocated LockClassKeys
@@ Commit message
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250307232717.1759087-11-boqun.feng@gmail.com
+ (cherry picked from commit 966944f3711665db13e214fef6d02982c49bb972)
+ Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
## rust/kernel/sync.rs ##
@@
@@ rust/kernel/sync.rs
pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
self.0.get()
}
- }
-
--impl Default for LockClassKey {
-- fn default() -> Self {
-- Self::new()
-- }
--}
--
- /// Defines a new static lock class and returns a pointer to it.
- #[doc(hidden)]
+@@ rust/kernel/sync.rs: pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
#[macro_export]
macro_rules! static_lock_class {
() => {{
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.6.y | Success | Success |
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-18 20:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-16 7:15 FAILED: patch "[PATCH] rust: lockdep: Remove support for dynamically allocated" failed to apply to 6.6-stable tree gregkh
2025-03-18 17:59 ` Boqun Feng
2025-03-18 19:59 ` Greg KH
2025-03-18 18:04 ` [PATCH 6.6.y] rust: lockdep: Remove support for dynamically allocated LockClassKeys Boqun Feng
2025-03-18 20:12 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox