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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260111120209.6133-2-boqun.feng@gmail.com>
Date: Sun, 11 Jan 2026 20:01:37 +0800
From: Boqun Feng <boqun.feng@...il.com>
To: "Peter Zijlstra" <peterz@...radead.org>,
	"Ingo Molnar" <mingo@...nel.org>
Cc: rust-for-linux@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	"Will Deacon" <will@...nel.org>,
	"Mark Rutland" <mark.rutland@....com>,
	"Thomas Gleixner" <tglx@...utronix.de>,
	"Miguel Ojeda" <ojeda@...nel.org>,
	"Gary Guo" <gary@...yguo.net>,
	"Alice Ryhl" <aliceryhl@...gle.com>,
	"Andreas Hindborg" <a.hindborg@...nel.org>,
	"Benno Lossin" <lossin@...nel.org>,
	"Danilo Krummrich" <dakr@...nel.org>,
	Daniel Almeida <daniel.almeida@...labora.com>,
	Alexandre Courbot <acourbot@...dia.com>,
	Boqun Feng <boqun.feng@...il.com>
Subject: [PATCH 04/36] rust: sync: Implement Unpin for ARef

From: Alice Ryhl <aliceryhl@...gle.com>

The default implementation of Unpin for ARef<T> is conditional on T
being Unpin due to its PhantomData<T> field. However, this is overly
strict as pointers to T are legal to move even if T itself cannot move.

Since commit 66f1ea83d9f8 ("rust: lock: Add a Pin<&mut T> accessor")
this causes build failures when combined with a Mutex that contains an
field ARef<T>, because almost any type that ARef is used with is !Unpin.

Reviewed-by: Daniel Almeida <daniel.almeida@...labora.com>
Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
Reviewed-by: Alexandre Courbot <acourbot@...dia.com>
Reviewed-by: Benno Lossin <lossin@...nel.org>
Signed-off-by: Boqun Feng <boqun.feng@...il.com>
Link: https://patch.msgid.link/20251218-unpin-for-aref-v2-1-30d77129cbc6@google.com
---
 rust/kernel/sync/aref.rs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rust/kernel/sync/aref.rs b/rust/kernel/sync/aref.rs
index 0d24a0432015..0616c0353c2b 100644
--- a/rust/kernel/sync/aref.rs
+++ b/rust/kernel/sync/aref.rs
@@ -83,6 +83,9 @@ unsafe impl<T: AlwaysRefCounted + Sync + Send> Send for ARef<T> {}
 // example, when the reference count reaches zero and `T` is dropped.
 unsafe impl<T: AlwaysRefCounted + Sync + Send> Sync for ARef<T> {}
 
+// Even if `T` is pinned, pointers to `T` can still move.
+impl<T: AlwaysRefCounted> Unpin for ARef<T> {}
+
 impl<T: AlwaysRefCounted> ARef<T> {
     /// Creates a new instance of [`ARef`].
     ///
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ