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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251025134516.40302-1-sunyizhe@fastmail.com>
Date: Sat, 25 Oct 2025 21:44:26 +0800
From: Yizhe Sun <sunyizhe@...tmail.com>
To: fujita.tomonori@...il.com,
	ojeda@...nel.org,
	alex.gaynor@...il.com
Cc: tmgross@...ch.edu,
	netdev@...r.kernel.org,
	boqun.feng@...il.com,
	gary@...yguo.net,
	bjorn3_gh@...tonmail.com,
	lossin@...nel.org,
	a.hindborg@...nel.org,
	aliceryhl@...gle.com,
	dakr@...nel.org,
	rust-for-linux@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Yizhe Sun <sunyizhe@...tmail.com>
Subject: [PATCH v2] rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`

From: Benno Lossin <lossin@...nel.org>

All types in `bindings` implement `Zeroable` if they can, so use
`pin_init::zeroed` instead of relying on `unsafe` code.

If this ends up not compiling in the future, something in bindgen or on
the C side changed and is most likely incorrect.

Signed-off-by: Benno Lossin <lossin@...nel.org>
Signed-off-by: Yizhe Sun <sunyizhe@...tmail.com>
---
This is a resend. Original: https://lore.kernel.org/rust-for-linux/20250814093046.2071971-5-lossin@kernel.org/

 rust/kernel/net/phy.rs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index bf6272d87a7b..46c693c5768a 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -553,9 +553,7 @@ pub const fn create_phy_driver<T: Driver>() -> DriverVTable {
         } else {
             None
         },
-        // SAFETY: The rest is zeroed out to initialize `struct phy_driver`,
-        // sets `Option<&F>` to be `None`.
-        ..unsafe { core::mem::MaybeUninit::<bindings::phy_driver>::zeroed().assume_init() }
+        ..pin_init::zeroed()
     }))
 }
 

base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
-- 
2.51.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ