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: <aEr5FNDaueo5SG5R@cassiopeiae>
Date: Thu, 12 Jun 2025 17:58:12 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Benno Lossin <lossin@...nel.org>
Cc: gregkh@...uxfoundation.org, rafael@...nel.org, ojeda@...nel.org,
	alex.gaynor@...il.com, boqun.feng@...il.com, gary@...yguo.net,
	bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
	a.hindborg@...nel.org, aliceryhl@...gle.com, tmgross@...ch.edu,
	rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/4] rust: revocable: support fallible PinInit types

On Thu, Jun 12, 2025 at 05:48:36PM +0200, Benno Lossin wrote:
> On Thu Jun 12, 2025 at 4:51 PM CEST, Danilo Krummrich wrote:
> > diff --git a/rust/kernel/revocable.rs b/rust/kernel/revocable.rs
> > index fa1fd70efa27..41b8fe374af6 100644
> > --- a/rust/kernel/revocable.rs
> > +++ b/rust/kernel/revocable.rs
> > @@ -82,8 +82,11 @@ unsafe impl<T: Sync + Send> Sync for Revocable<T> {}
> >  
> >  impl<T> Revocable<T> {
> >      /// Creates a new revocable instance of the given data.
> > -    pub fn new(data: impl PinInit<T>) -> impl PinInit<Self> {
> > -        pin_init!(Self {
> > +    pub fn new<E>(data: impl PinInit<T, E>) -> impl PinInit<Self, Error>
> > +    where
> > +        Error: From<E>,
> 
> I don't think we need this bound as you don't use it in the function
> body.

I think it's needed by try_pin_init!() below, no?

Without it I get the compilation error in [1].

> > +    {
> > +        try_pin_init!(Self {
> >              is_available: AtomicBool::new(true),
> >              data <- Opaque::pin_init(data),
> >          })
> 

[1]

error[E0277]: `?` couldn't convert the error to `error::Error`
  --> rust/kernel/revocable.rs:87:9
   |
87 | /         try_pin_init!(Self {
88 | |             is_available: AtomicBool::new(true),
89 | |             data <- Opaque::pin_init(data),
90 | |         })
   | |          ^
   | |          |
   | |__________this can't be annotated with `?` because it has type `Result<_, E>`
   |            the trait `core::convert::From<E>` is not implemented for `error::Error`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = note: required for `core::result::Result<revocable::Revocable<T>::new::__InitOk, error::Error>` to implement `core::ops::FromResidual<core::result::Result<core::convert::Infallible, E>>`
   = note: this error originates in the macro `$crate::__init_internal` which comes from the expansion of the macro `try_pin_init` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
   |
83 | impl<T> Revocable<T> where error::Error: core::convert::From<E> {
   |                      ++++++++++++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `impl PinInit<Revocable<T>, Error>: PinInit<Revocable<T>, E>` is not satisfied
  --> rust/kernel/revocable.rs:85:48
   |
85 |     pub fn new<E>(data: impl PinInit<T, E>) -> impl PinInit<Self, E>
   |                                                ^^^^^^^^^^^^^^^^^^^^^ the trait `pin_init::PinInit<revocable::Revocable<T>, E>` is not implemented for `impl pin_init::PinInit<revocable::Revocable<T>, error::Error>`
   |
   = help: the following other types implement trait `pin_init::PinInit<T, E>`:
             `core::result::Result<T, E>` implements `pin_init::PinInit<T, E>`
             `pin_init::ChainInit<I, F, T, E>` implements `pin_init::PinInit<T, E>`
             `pin_init::ChainPinInit<I, F, T, E>` implements `pin_init::PinInit<T, E>`
             `pin_init::__internal::AlwaysFail<T>` implements `pin_init::PinInit<T, ()>`
   = note: the full name for the type has been written to 'kernel.long-type-441004638990533407.txt'
   = note: consider using `--verbose` to print the full type name to the console

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ