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] [day] [month] [year] [list]
Message-ID: <CANeycqou9AT6BzxdNKrT_B2eRs4htjJx3dq-mKBByMOAj-8qiw@mail.gmail.com>
Date: Tue, 26 Mar 2024 23:17:31 -0300
From: Wedson Almeida Filho <wedsonaf@...il.com>
To: Benno Lossin <benno.lossin@...ton.me>
Cc: rust-for-linux@...r.kernel.org, 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>, 
	Andreas Hindborg <a.hindborg@...sung.com>, Alice Ryhl <aliceryhl@...gle.com>, 
	linux-kernel@...r.kernel.org, Wedson Almeida Filho <walmeida@...rosoft.com>
Subject: Re: [PATCH 09/10] rust: init: update `init` module to take allocation flags

On Tue, 26 Mar 2024 at 11:08, Benno Lossin <benno.lossin@...ton.me> wrote:
>
> On 25.03.24 20:54, Wedson Almeida Filho wrote:
> > From: Wedson Almeida Filho <walmeida@...rosoft.com>
> >
> > This is the last component in the conversion for allocators to take
> > allocation flags as parameters.
> >
> > Signed-off-by: Wedson Almeida Filho <walmeida@...rosoft.com>
> > ---
> >   rust/kernel/init.rs               | 49 ++++++++++++++++---------------
> >   rust/kernel/sync/arc.rs           | 17 ++++++-----
> >   rust/kernel/sync/condvar.rs       |  2 +-
> >   rust/kernel/sync/lock/mutex.rs    |  2 +-
> >   rust/kernel/sync/lock/spinlock.rs |  2 +-
> >   rust/kernel/workqueue.rs          | 13 +++++---
> >   6 files changed, 47 insertions(+), 38 deletions(-)
>
> One formatting issue below, with that fixed:
>
> Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
>
> > diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
> > index 077200f5350b..af539c5eb4bc 100644
> > --- a/rust/kernel/sync/arc.rs
> > +++ b/rust/kernel/sync/arc.rs
> > @@ -565,13 +565,16 @@ pub fn new(value: T, flags: Flags) -> Result<Self, AllocError> {
> >       }
> >
> >       /// Tries to allocate a new [`UniqueArc`] instance whose contents are not initialised yet.
> > -    pub fn new_uninit(_flags: Flags) -> Result<UniqueArc<MaybeUninit<T>>, AllocError> {
> > +    pub fn new_uninit(flags: Flags) -> Result<UniqueArc<MaybeUninit<T>>, AllocError> {
> >           // INVARIANT: The refcount is initialised to a non-zero value.
> > -        let inner = Box::try_init::<AllocError>(try_init!(ArcInner {
> > +        let inner = Box::try_init::<AllocError>(
> > +            try_init!(ArcInner {
> >               // SAFETY: There are no safety requirements for this FFI call.
> >               refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }),
> >               data <- init::uninit::<T, AllocError>(),
> > -        }? AllocError))?;
> > +        }? AllocError),
> > +            flags,
> > +        )?;
>
> The indentation looks wrong, rustfmt sadly cannot handle the pin-init
> macros. This looks better to me:
>
>         let inner = Box::try_init::<AllocError>(
>             try_init!(ArcInner {
>                 // SAFETY: There are no safety requirements for this FFI call.
>                 refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }),
>                 data <- init::uninit::<T, AllocError>(),
>             }? AllocError),
>             flags,
>         )?;

I remember trying to rearrange this and `rustfmtcheck` not liking it
but it seems to be happy with your suggestion.

Applying it in v2.

> --
> Cheers,
> Benno
>
> >           Ok(UniqueArc {
> >               // INVARIANT: The newly-created object has a refcount of 1.
> >               // SAFETY: The pointer from the `Box` is valid.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ