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: <aFrULqf7gQgI4T9p@Mac.home>
Date: Tue, 24 Jun 2025 09:37:02 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: gregkh@...uxfoundation.org, rafael@...nel.org, ojeda@...nel.org,
	alex.gaynor@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
	lossin@...nel.org, a.hindborg@...nel.org, aliceryhl@...gle.com,
	tmgross@...ch.edu, david.m.ertman@...el.com, ira.weiny@...el.com,
	leon@...nel.org, kwilczynski@...nel.org, bhelgaas@...gle.com,
	rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-pci@...r.kernel.org
Subject: Re: [PATCH v2 3/4] rust: devres: get rid of Devres' inner Arc

On Tue, Jun 24, 2025 at 06:20:41PM +0200, Danilo Krummrich wrote:
> On Tue, Jun 24, 2025 at 06:15:43PM +0200, Danilo Krummrich wrote:
> > Oh, so you meant adding this to the safety comment. Yes, that makes sense. Maybe
> > ScopeGuard works too, as you say.
> 
> diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
> index 2591cacecb7b..afd73a8c6012 100644
> --- a/rust/kernel/devres.rs
> +++ b/rust/kernel/devres.rs
> @@ -14,7 +14,7 @@
>      prelude::*,
>      revocable::{Revocable, RevocableGuard},
>      sync::{rcu, Completion},
> -    types::{ARef, ForeignOwnable, Opaque},
> +    types::{ARef, ForeignOwnable, ScopeGuard, Opaque},
>  };
>  use core::ops::Deref;
> 
> @@ -177,15 +177,15 @@ fn data(&self) -> &Revocable<T> {
>          // hence `ptr` must be a valid pointer to `Inner`.
>          let inner = unsafe { &*ptr.cast::<Inner<T>>() };
> 
> +        // Ensure that `inner` can't be used anymore after we signal completion of this callback.
> +        let inner = ScopeGuard::new_with_data(inner, |inner| inner.devm.complete_all());
> +
>          if !inner.data.revoke() {
>              // If `revoke()` returns false, it means that `Devres::drop` already started revoking
>              // `data` for us. Hence we have to wait until `Devres::drop` signals that it
>              // completed revoking `data`.
>              inner.revoke.wait_for_completion();
>          }
> -
> -        // Signal that we're done using `inner`.
> -        inner.devm.complete_all();
>      }
> 
>      fn remove_action(&self) -> bool {
> 
> Is this what you thought of?

Yep, looks good to me. Thanks!

Regards,
Boqun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ