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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aElxTuk4Nz1qGNpX@cassiopeiae>
Date: Wed, 11 Jun 2025 14:06:38 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Remo Senekowitsch <remo@...nzli.dev>
Cc: Rob Herring <robh@...nel.org>, Saravana Kannan <saravanak@...gle.com>,
	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>,
	Dirk Behme <dirk.behme@...bosch.com>, linux-kernel@...r.kernel.org,
	devicetree@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v8 0/9] More Rust bindings for device property reads

Hi Remo,

On Wed, Jun 11, 2025 at 12:28:59PM +0200, Remo Senekowitsch wrote:

I went through the single patches and found the following issues.

> Remo Senekowitsch (9):
>   rust: device: Create FwNode abstraction for accessing device
>     properties

This patch creates a warning for FwNode::from_raw() to be unused, and needs this
fix:

diff --git a/rust/kernel/device/property.rs b/rust/kernel/device/property.rs
index 03850b7bb808..82ef54b54f18 100644
--- a/rust/kernel/device/property.rs
+++ b/rust/kernel/device/property.rs
@@ -37,6 +37,7 @@ impl FwNode {
     /// - They relinquish that increment. That is, if there is only one
     ///   increment, callers must not use the underlying object anymore -- it is
     ///   only safe to do so via the newly created `ARef<FwNode>`.
+    #[expect(dead_code)]
     unsafe fn from_raw(raw: *mut bindings::fwnode_handle) -> ARef<Self> {
         // SAFETY: As per the safety requirements of this function:
         // - `NonNull::new_unchecked`:

>   rust: device: Enable accessing the FwNode of a Device
>   rust: device: Move property_present() to FwNode
>   rust: device: Enable printing fwnode name and path

This patch starts using FwNode::from_raw() and hence needs:

diff --git a/rust/kernel/device/property.rs b/rust/kernel/device/property.rs
index a5ebadd878d6..4cac335bad78 100644
--- a/rust/kernel/device/property.rs
+++ b/rust/kernel/device/property.rs
@@ -38,7 +38,6 @@ impl FwNode {
     /// - They relinquish that increment. That is, if there is only one
     ///   increment, callers must not use the underlying object anymore -- it is
     ///   only safe to do so via the newly created `ARef<FwNode>`.
-    #[expect(dead_code)]
     unsafe fn from_raw(raw: *mut bindings::fwnode_handle) -> ARef<Self> {
         // SAFETY: As per the safety requirements of this function:
         // - `NonNull::new_unchecked`:

>   rust: device: Introduce PropertyGuard

This patch fails to compile (print macros are not included) and needs the
following change.

diff --git a/rust/kernel/device/property.rs b/rust/kernel/device/property.rs
index a10033d310e6..1286669a9a40 100644
--- a/rust/kernel/device/property.rs
+++ b/rust/kernel/device/property.rs
@@ -8,6 +8,7 @@
 
 use crate::{
     bindings,
+    prelude::*,
     str::CStr,
     types::{ARef, Opaque},
 };

>   rust: device: Implement accessors for firmware properties

This patch also fails to compile, throws a warning about transmute() and hence
needs the following change.

diff --git a/rust/kernel/device/property.rs b/rust/kernel/device/property.rs
index 75621abe8117..fe0c5469a278 100644
--- a/rust/kernel/device/property.rs
+++ b/rust/kernel/device/property.rs
@@ -6,12 +6,12 @@

 use core::{mem::MaybeUninit, ptr};

+use super::private::Sealed;
 use crate::{
     alloc::KVec,
     bindings,
     error::{to_result, Result},
     prelude::*,
-    private::Sealed,
     str::{CStr, CString},
     types::{ARef, Opaque},
 };
@@ -303,7 +303,7 @@ fn read_array_from_fwnode_property<'a>(
                 // `&'a mut [Self]` is sound, because the previous call to a
                 // `fwnode_property_read_*_array` function (which didn't fail)
                 // fully initialized the slice.
-                Ok(unsafe { core::mem::transmute(out) })
+                Ok(unsafe { core::mem::transmute::<&mut [MaybeUninit<Self>], &mut [Self]>(out) })
             }

             fn read_array_len_from_fwnode_property(fwnode: &FwNode, name: &CStr) -> Result<usize> {

>   rust: device: Add child accessor and iterator
>   rust: device: Add property_get_reference_args
>   samples: rust: platform: Add property read examples

In general, please make sure to compile test every patch of a series
individually, not only the entire series.

Otherwise the series looks good. Given that the required fixes are minor, there
is no need for you to send a new version, I can apply those changes why I apply
the patch series.

- Danilo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ