lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <176104292997.2601451.15640432795343343471.tip-bot2@tip-bot2>
Date: Tue, 21 Oct 2025 10:35:29 -0000
From: "tip-bot2 for Daniel Almeida" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Benno Lossin <lossin@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
 Daniel Almeida <daniel.almeida@...labora.com>,
 "Peter Zijlstra (Intel)" <peterz@...radead.org>,
 Alice Ryhl <aliceryhl@...gle.com>, x86@...nel.org,
 linux-kernel@...r.kernel.org
Subject: [tip: locking/core] rust: lock: guard: Add T: Unpin bound to DerefMut

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     da123f0ee40f0e5a3791bbaf58a1db1744c59f72
Gitweb:        https://git.kernel.org/tip/da123f0ee40f0e5a3791bbaf58a1db1744c59f72
Author:        Daniel Almeida <daniel.almeida@...labora.com>
AuthorDate:    Fri, 19 Sep 2025 11:12:39 +02:00
Committer:     Peter Zijlstra <peterz@...radead.org>
CommitterDate: Tue, 21 Oct 2025 12:31:55 +02:00

rust: lock: guard: Add T: Unpin bound to DerefMut

A core property of pinned types is not handing a mutable reference to
the inner data in safe code, as this trivially allows that data to be
moved.

Enforce this condition by adding a bound on lock::Guard's DerefMut
implementation, so that it's only implemented for pinning-agnostic
types.

Suggested-by: Benno Lossin <lossin@...nel.org>
Suggested-by: Boqun Feng <boqun.feng@...il.com>
Signed-off-by: Daniel Almeida <daniel.almeida@...labora.com>
Signed-off-by: Boqun Feng <boqun.feng@...il.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Benno Lossin <lossin@...nel.org>
Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1181
---
 rust/kernel/sync/lock.rs        | 5 ++++-
 rust/kernel/sync/lock/global.rs | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs
index 27202be..b482f34 100644
--- a/rust/kernel/sync/lock.rs
+++ b/rust/kernel/sync/lock.rs
@@ -251,7 +251,10 @@ impl<T: ?Sized, B: Backend> core::ops::Deref for Guard<'_, T, B> {
     }
 }
 
-impl<T: ?Sized, B: Backend> core::ops::DerefMut for Guard<'_, T, B> {
+impl<T: ?Sized, B: Backend> core::ops::DerefMut for Guard<'_, T, B>
+where
+    T: Unpin,
+{
     fn deref_mut(&mut self) -> &mut Self::Target {
         // SAFETY: The caller owns the lock, so it is safe to deref the protected data.
         unsafe { &mut *self.lock.data.get() }
diff --git a/rust/kernel/sync/lock/global.rs b/rust/kernel/sync/lock/global.rs
index d65f94b..38b4480 100644
--- a/rust/kernel/sync/lock/global.rs
+++ b/rust/kernel/sync/lock/global.rs
@@ -106,7 +106,10 @@ impl<B: GlobalLockBackend> core::ops::Deref for GlobalGuard<B> {
     }
 }
 
-impl<B: GlobalLockBackend> core::ops::DerefMut for GlobalGuard<B> {
+impl<B: GlobalLockBackend> core::ops::DerefMut for GlobalGuard<B>
+where
+    B::Item: Unpin,
+{
     fn deref_mut(&mut self) -> &mut Self::Target {
         &mut self.inner
     }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ