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: <27dad59c-ba8a-43c4-a288-870cf29fa131@proton.me>
Date: Thu, 25 Jul 2024 18:06:06 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Alex Mantel <alexmantel93@...lbox.org>, ojeda@...nel.org, alex.gaynor@...il.com, wedsonaf@...il.com, boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com, a.hindborg@...sung.com, aliceryhl@...gle.com, rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] rust: Implement the smart pointer `InPlaceInit` for `Arc`

On 19.07.24 21:22, Alex Mantel wrote:
> diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
> index 68605b633..46f50cf12 100644
> --- a/rust/kernel/init.rs
> +++ b/rust/kernel/init.rs
> @@ -213,6 +213,7 @@
>  use crate::{
>      alloc::{box_ext::BoxExt, AllocError, Flags},
>      error::{self, Error},
> +    sync::Arc,
>      sync::UniqueArc,
>      types::{Opaque, ScopeGuard},
>  };
> @@ -1112,11 +1113,15 @@ unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E> {
> 
>  /// Smart pointer that can initialize memory in-place.
>  pub trait InPlaceInit<T>: Sized {
> +    /// A type might be pinned implicitly. An addtional `Pin<ImplicitlyPinned>` is useless. In
> +    /// doubt, the type can just be set to `Pin<Self>`.

This comment should better describe the purpose of this associated type,
the first line could be "Pinned version of `Self`" then (with an empty
line in between) you could write more explanatory stuff. I would also
rephrase what you have above, for example: "If a type already implicitly
pins its pointee, `Pin<Self>` is unnecessary. In this case use `Self`,
otherwise just use `Pin<Self>`.".

> +    type PinnedResult;

I don't really like the name for this, since it is not a result. What do
you think of `PinnedSelf`?

Otherwise this looks good!

---
Cheers,
Benno

> +
>      /// Use the given pin-initializer to pin-initialize a `T` inside of a new smart pointer of this
>      /// type.
>      ///
>      /// If `T: !Unpin` it will not be able to move afterwards.
> -    fn try_pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> Result<Pin<Self>, E>
> +    fn try_pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> Result<Self::PinnedResult, E>
>      where
>          E: From<AllocError>;
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ