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: <87senrd7eq.fsf@kernel.org>
Date: Wed, 05 Mar 2025 12:49:17 +0100
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Benno Lossin" <benno.lossin@...ton.me>
Cc: "Miguel Ojeda" <ojeda@...nel.org>,  "Alex Gaynor"
 <alex.gaynor@...il.com>,  "Boqun Feng" <boqun.feng@...il.com>,  "Gary Guo"
 <gary@...yguo.net>,  Björn Roy Baron
 <bjorn3_gh@...tonmail.com>,  "Alice
 Ryhl" <aliceryhl@...gle.com>,  "Trevor Gross" <tmgross@...ch.edu>,
  "Danilo Krummrich" <dakr@...nel.org>,  <rust-for-linux@...r.kernel.org>,
  <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 12/22] rust: pin-init: remove kernel-crate dependency

"Benno Lossin" <benno.lossin@...ton.me> writes:

> In order to make pin-init a standalone crate, remove dependencies on
> kernel-specific code such as `ScopeGuard` and `KBox`.
>
> `ScopeGuard` is only used in the `[pin_]init_array_from_fn` functions
> and can easily be replaced by a primitive construct.
>
> `KBox` is only used for type variance of unsized types and can also
> easily be replaced.
>
> Signed-off-by: Benno Lossin <benno.lossin@...ton.me>

Reviewed-by: Andreas Hindborg <a.hindborg@...nel.org>

> ---
>  rust/pin-init/src/__internal.rs |  2 +-
>  rust/pin-init/src/lib.rs        | 41 +++++++++++----------------------
>  2 files changed, 15 insertions(+), 28 deletions(-)
>
> diff --git a/rust/pin-init/src/__internal.rs b/rust/pin-init/src/__internal.rs
> index 0db800819681..74086365a18a 100644
> --- a/rust/pin-init/src/__internal.rs
> +++ b/rust/pin-init/src/__internal.rs
> @@ -105,7 +105,7 @@ fn make_closure<F, O, E>(self, f: F) -> F
>      }
>  }
>
> -pub struct AllData<T: ?Sized>(PhantomData<fn(KBox<T>) -> KBox<T>>);
> +pub struct AllData<T: ?Sized>(Invariant<T>);

Off topic, trying to learn something: You define `Invariant<T>` like so:

  pub(super) type Invariant<T> = PhantomData<fn(*mut T) -> *mut T>;

Consulting the variance table at [1], could you define it as

  pub(super) type Invariant<T> = PhantomData<*mut T>;

or is there another reason for using `fn`?


Best regards,
Andreas Hindborg


[1] https://doc.rust-lang.org/nomicon/subtyping.html#variance



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ