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: <DBG25OQZJ18V.1W13FEOPX8MOH@kernel.org>
Date: Sat, 19 Jul 2025 15:15:40 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Daniel Almeida" <daniel.almeida@...labora.com>
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>, "Benno Lossin" <lossin@...nel.org>, "Andreas
 Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
 "Trevor Gross" <tmgross@...ch.edu>, "Greg Kroah-Hartman"
 <gregkh@...uxfoundation.org>, "Rafael J. Wysocki" <rafael@...nel.org>,
 <linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v15 3/3] rust: platform: add resource accessors

On Thu Jul 17, 2025 at 5:55 PM CEST, Daniel Almeida wrote:
> +impl Device<Bound> {
> +    /// Returns an `IoRequest` for the resource at `index`, if any.
> +    pub fn io_request_by_index(&self, index: u32) -> Option<IoRequest<'_>> {
> +        // SAFETY: `resource` is a valid resource for `&self` during the
> +        // lifetime of the `IoRequest`.
> +        self.resource_by_index(index)
> +            .map(|resource| unsafe { IoRequest::new(self.as_ref(), resource) })

It seems there's a bug in some clippy versions we support. My regular testing
shows a warning for this with clippy 1.78:

	warning: unsafe block missing a safety comment
	   --> rust/kernel/platform.rs:275:29
	    |
	275 |             .map(|resource| unsafe { IoRequest::new(self.as_ref(), resource) })
	    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	    |

However, there clearly is a safety comment.

It seems it gets confused by the multiline formatting. If I write this as

	self.resource_by_index(index)
	    // SAFETY: `resource` is a valid resource for `&self` during the
	    // lifetime of the `IoRequest`.
	    .map(|resource| unsafe { IoRequest::new(self.as_ref(), resource) })

the warning goes away.

@Miguel: What's the preferred way dealing with this? I assume we just want to
ignore this warning for the affected compiler versions?

> +    }
> +
> +    /// Returns an `IoRequest` for the resource with a given `name`, if any.
> +    pub fn io_request_by_name(&self, name: &CStr) -> Option<IoRequest<'_>> {
> +        // SAFETY: `resource` is a valid resource for `&self` during the
> +        // lifetime of the `IoRequest`.
> +        self.resource_by_name(name)
> +            .map(|resource| unsafe { IoRequest::new(self.as_ref(), resource) })
> +    }
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ