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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240801.100342.2177122481364088518.fujita.tomonori@gmail.com>
Date: Thu, 01 Aug 2024 10:03:42 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: aliceryhl@...gle.com
Cc: fujita.tomonori@...il.com, netdev@...r.kernel.org,
 rust-for-linux@...r.kernel.org, andrew@...n.ch, tmgross@...ch.edu,
 miguel.ojeda.sandonis@...il.com, benno.lossin@...ton.me
Subject: Re: [PATCH net-next v2 3/6] rust: net::phy implement
 AsRef<kernel::device::Device> trait

On Wed, 31 Jul 2024 10:38:11 +0200
Alice Ryhl <aliceryhl@...gle.com> wrote:

>> +impl AsRef<kernel::device::Device> for Device {
>> +    fn as_ref(&self) -> &kernel::device::Device {
>> +        let phydev = self.0.get();
>> +        // SAFETY: The struct invariant ensures that we may access
>> +        // this field without additional synchronization.
>> +        unsafe { kernel::device::Device::as_ref(&mut (*phydev).mdio.dev) }
> 
> This is a case where I would recommend use of the `addr_of_mut!`
> macro. The type of the mutable reference will be `&mut
> bindings::device` without a `Opaque` wrapper around the referent, and
> the lack of `Opaque` raises questions about uniqueness guarantees.
> Using `addr_of_mut!` sidesteps those questions.
> 
> With `addr_of_mut!` and no intermediate mutable reference you may add:
> 
> Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>

Understood. I will use addr_of_mut! in v3.

Thanks a lot!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ