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: <CANiq72n8qdymDJnqtvFqoOsFXJqn1EuvRqBkT+A_ibZmmh7SYw@mail.gmail.com>
Date: Fri, 18 Jul 2025 19:59:57 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: TruongSinh Tran-Nguyen <i@...ongsinh.pro>, Jason Devers <dev.json2@...il.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.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, dakr@...nel.org
Subject: Re: [PATCH] rust: Add #[must_use] to Lock::try_lock,
 GlobalLock::try_lock, and XArray::try_lock

On Fri, Jul 18, 2025 at 4:20 PM TruongSinh Tran-Nguyen <i@...ongsinh.pro> wrote:
>
> This addresses issue #1133 in the rust-for-linux project.

We typically use the "Suggested-by:" and "Links:" tags for this,
please see e.g. how it was done in the patch linked below.

> diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs
> index e82fa5be289c..1c2ddade6d6d 100644
> --- a/rust/kernel/sync/lock.rs
> +++ b/rust/kernel/sync/lock.rs
> @@ -175,6 +175,7 @@ pub fn lock(&self) -> Guard<'_, T, B> {
>      /// Tries to acquire the lock.
>      ///
>      /// Returns a guard that can be used to access the data protected by the lock if successful.
> +    #[must_use = "the lock unlocks immediately when the guard is unused"]
>      pub fn try_lock(&self) -> Option<Guard<'_, T, B>> {
>          // SAFETY: The constructor of the type calls `init`, so the existence of the object proves
>          // that `init` was called.

This part was done at:

    https://lore.kernel.org/rust-for-linux/20241212154753.139563-1-dev.json2@gmail.com/

which is soon landing in mainline.

We may want to add the comment on top here like in that patch to the
other 2, and possibly make the "reason string" after the `=` the same
one too.

Thanks for the patch!

Cheers,
Miguel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ