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]
Date: Mon, 11 Dec 2023 12:23:38 -0800
From: Boqun Feng <boqun.feng@...il.com>
To: netdev@...r.kernel.org
Cc: rust-for-linux@...r.kernel.org, andrew@...n.ch, tmgross@...ch.edu,
	miguel.ojeda.sandonis@...il.com, benno.lossin@...ton.me,
	wedsonaf@...il.com, aliceryhl@...gle.com,
	FUJITA Tomonori <fujita.tomonori@...il.com>
Subject: Re: [net-next PATCH] rust: net: phy: Correct the safety comment for
 impl Sync

+ Tomo

On Mon, Dec 11, 2023 at 11:49:09AM -0800, Boqun Feng wrote:
> The current safety comment for impl Sync for DriverVTable has two
> problem:
> 
> * the correctness is unclear, since all types impl Any[1], therefore all
>   types have a `&self` method (Any::type_id).
> 
> * it doesn't explain why useless of immutable references can ensure the
>   safety.
> 
> Fix this by rewritting the comment.
> 
> [1]: https://doc.rust-lang.org/std/any/trait.Any.html
> 
> Signed-off-by: Boqun Feng <boqun.feng@...il.com>
> ---
> This is a follow-up for my ignored feedback:
> 
> 	https://lore.kernel.org/rust-for-linux/ZV5FjEM1EWm6iTAm@boqun-archlinux/	
> 
> Honestly, I believe that people who are active in the review process all
> get it right, but I want to make sure who read the code later can also
> understand it and reuse the reasoning in their code. Hence this
> improvement.
> 
> Tomo, feel free to fold it in your patch if you and others think the
> wording is fine.
> 
>  rust/kernel/net/phy.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
> index d9cec139324a..e3377f8f36b7 100644
> --- a/rust/kernel/net/phy.rs
> +++ b/rust/kernel/net/phy.rs
> @@ -489,8 +489,8 @@ impl<T: Driver> Adapter<T> {
>  #[repr(transparent)]
>  pub struct DriverVTable(Opaque<bindings::phy_driver>);
>  
> -// SAFETY: `DriverVTable` has no &self methods, so immutable references to it
> -// are useless.
> +// SAFETY: `DriverVTable` doesn't expose any &self method to access internal data, so it's safe to
> +// share `&DriverVTable` across execution context boundries.
>  unsafe impl Sync for DriverVTable {}
>  
>  /// Creates a [`DriverVTable`] instance from [`Driver`].
> -- 
> 2.43.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ