mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-12-19 09:08:10 +01:00
rust: lockdep: Remove support for dynamically allocated LockClassKeys
commit966944f371upstream. Currently, dynamically allocated LockCLassKeys can be used from the Rust side without having them registered. This is a soundness issue, so remove them. Fixes:6ea5aa0885("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 Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
812080b01d
commit
50b22a98c1
|
|
@ -26,11 +26,6 @@ pub struct LockClassKey(Opaque<bindings::lock_class_key>);
|
||||||
unsafe impl Sync for LockClassKey {}
|
unsafe impl Sync for LockClassKey {}
|
||||||
|
|
||||||
impl 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 {
|
pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
|
||||||
self.0.get()
|
self.0.get()
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +36,10 @@ impl LockClassKey {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! static_lock_class {
|
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
|
&CLASS
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user