[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174139249455.14745.13816550054744263008.tip-bot2@tip-bot2>
Date: Sat, 08 Mar 2025 00:08:14 -0000
From: "tip-bot2 for Mitchell Levy" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Alice Ryhl <aliceryhl@...gle.com>, Mitchell Levy <levymitchell0@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Ingo Molnar <mingo@...nel.org>,
Benno Lossin <benno.lossin@...ton.me>, stable@...r.kernel.org, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: locking/core] rust: lockdep: Remove support for dynamically
allocated LockClassKeys
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 966944f3711665db13e214fef6d02982c49bb972
Gitweb: https://git.kernel.org/tip/966944f3711665db13e214fef6d02982c49bb972
Author: Mitchell Levy <levymitchell0@...il.com>
AuthorDate: Fri, 07 Mar 2025 15:27:00 -08:00
Committer: Ingo Molnar <mingo@...nel.org>
CommitterDate: Sat, 08 Mar 2025 00:52:00 +01:00
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@...gle.com>
Signed-off-by: Mitchell Levy <levymitchell0@...il.com>
Signed-off-by: Boqun Feng <boqun.feng@...il.com>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
Cc: stable@...r.kernel.org
Link: https://lore.kernel.org/r/20250307232717.1759087-11-boqun.feng@gmail.com
---
rust/kernel/sync.rs | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/rust/kernel/sync.rs b/rust/kernel/sync.rs
index 3498fb3..16eab91 100644
--- a/rust/kernel/sync.rs
+++ b/rust/kernel/sync.rs
@@ -30,28 +30,20 @@ pub struct LockClassKey(Opaque<bindings::lock_class_key>);
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
}};
}
Powered by blists - more mailing lists