From: "tip-bot2 for Mitchell Levy" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Alice Ryhl <aliceryhl@google.com>,
Mitchell Levy <levymitchell0@gmail.com>,
Boqun Feng <boqun.feng@gmail.com>, Ingo Molnar <mingo@kernel.org>,
Benno Lossin <benno.lossin@proton.me>,
stable@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org
Subject: [tip: locking/core] rust: lockdep: Remove support for dynamically allocated LockClassKeys
Date: Sat, 08 Mar 2025 00:08:14 -0000 [thread overview]
Message-ID: <174139249455.14745.13816550054744263008.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250307232717.1759087-11-boqun.feng@gmail.com>
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@gmail.com>
AuthorDate: Fri, 07 Mar 2025 15:27:00 -08:00
Committer: Ingo Molnar <mingo@kernel.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@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
---
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
}};
}
next prev parent reply other threads:[~2025-03-08 0:08 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 4:12 [GIT PULL] LOCKDEP and Rust locking changes for v6.15 Boqun Feng
2025-02-28 18:57 ` Boqun Feng
2025-03-03 16:52 ` Waiman Long
2025-03-03 18:42 ` Peter Zijlstra
2025-03-07 23:26 ` [PATCH locking 00/11] " Boqun Feng
2025-03-07 23:26 ` [PATCH locking 01/11] locking/rtmutex: Use struct keyword in kernel-doc comment Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] locking/rtmutex: Use the 'struct' " tip-bot2 for Randy Dunlap
2025-03-07 23:26 ` [PATCH locking 02/11] locking/semaphore: Use wake_q to wake up processes outside lock critical section Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] " tip-bot2 for Waiman Long
2025-03-07 23:26 ` [PATCH locking 03/11] locking/lock_events: Add locking events for rtmutex slow paths Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] " tip-bot2 for Waiman Long
2025-03-07 23:26 ` [PATCH locking 04/11] locking/lock_events: Add locking events for lockdep Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] " tip-bot2 for Waiman Long
2025-03-07 23:26 ` [PATCH locking 05/11] locking/lockdep: Disable KASAN instrumentation of lockdep.c Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] " tip-bot2 for Waiman Long
2025-03-07 23:26 ` [PATCH locking 06/11] locking/lockdep: Add kasan_check_byte() check in lock_acquire() Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] " tip-bot2 for Waiman Long
2025-03-07 23:26 ` [PATCH locking 07/11] rust: sync: Add accessor for the lock behind a given guard Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] " tip-bot2 for Alice Ryhl
2025-03-07 23:26 ` [PATCH locking 08/11] rust: sync: lock: Add an example for Guard::lock_ref() Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] rust: sync: lock: Add an example for Guard:: Lock_ref() tip-bot2 for Boqun Feng
2025-03-07 23:26 ` [PATCH locking 09/11] rust: sync: condvar: Add wait_interruptible_freezable() Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] " tip-bot2 for Alice Ryhl
2025-03-07 23:27 ` [PATCH locking 10/11] rust: lockdep: Remove support for dynamically allocated LockClassKeys Boqun Feng
2025-03-08 0:08 ` tip-bot2 for Mitchell Levy [this message]
2025-03-07 23:27 ` [PATCH locking 11/11] rust: lockdep: Use Pin for all LockClassKey usages Boqun Feng
2025-03-08 0:08 ` [tip: locking/core] " tip-bot2 for Mitchell Levy
2025-03-08 0:01 ` [PATCH locking 00/11] LOCKDEP and Rust locking changes for v6.15 Ingo Molnar
2025-03-08 0:04 ` Boqun Feng
2025-03-08 0:11 ` Ingo Molnar
2025-03-08 0:11 ` Boqun Feng
-- strict thread matches above, loose matches on Subject: below --
2025-02-08 0:39 [PATCH v4 1/2] rust: lockdep: Remove support for dynamically allocated LockClassKeys Mitchell Levy
2025-03-03 18:51 ` [tip: locking/core] " tip-bot2 for Mitchell Levy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=174139249455.14745.13816550054744263008.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=boqun.feng@gmail.com \
--cc=levymitchell0@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®