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: <DCND3LBZ0Y2J.377ZTOSOUXMOB@kernel.org>
Date: Mon, 08 Sep 2025 12:54:46 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>
Cc: "Matthew Maurer" <mmaurer@...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>, "Andreas
 Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
 "Trevor Gross" <tmgross@...ch.edu>, "Rafael J. Wysocki"
 <rafael@...nel.org>, "Sami Tolvanen" <samitolvanen@...gle.com>, "Timur
 Tabi" <ttabi@...dia.com>, "Benno Lossin" <lossin@...nel.org>, "Dirk Beheme"
 <dirk.behme@...bosch.com>, <linux-kernel@...r.kernel.org>,
 <rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v11 2/7] rust: debugfs: Add support for read-only files

On Mon Sep 8, 2025 at 12:17 PM CEST, Greg Kroah-Hartman wrote:
> I tried using this in a "tiny" test module I had written, and I get the
> following build error:
>
>    --> samples/rust/rust_debugfs2.rs:64:53
>     |
> 64  |         _file = root.read_only_file(c_str!("name"), &hw_soc_info.name);
>     |                      --------------                 ^^^^^^^^^^^^^^^^^ expected `&u32`, found `&&CStr`
>     |                      |
>     |                      arguments to this method are incorrect
>     |
>     = note: expected reference `&u32`
>                found reference `&&'static kernel::prelude::CStr`
>
> I'm trying to "just" print a CStr, which is defined as:
>
> struct HwSocInfo {
>     id: u32,
>     ver: u32,
>     raw_id: u32,
>     foundry: u32,
>     name: &'static CStr,
> }
>
> Is this just a "user is holding it wrong" error on my side, or can this api not
> handle CStr values?

What you're doing should fundamentally work.

The above error suggests that your declaration of `_file` is File<&u32> rather
than File<&'static CStr>.

Also note the double reference you create with `&hw_soc_info.name`, this should
just be `hw_soc_info.name`.

You can also test this case by applying the following diff the the sample in v5:

diff --git a/samples/rust/rust_debugfs.rs b/samples/rust/rust_debugfs.rs
index b26eea3ee723..475502f30b1a 100644
--- a/samples/rust/rust_debugfs.rs
+++ b/samples/rust/rust_debugfs.rs
@@ -59,6 +59,8 @@ struct RustDebugFs {
     #[pin]
     _compatible: File<CString>,
     #[pin]
+    _test: File<&'static CStr>,
+    #[pin]
     counter: File<AtomicUsize>,
     #[pin]
     inner: File<Mutex<Inner>>,
@@ -140,6 +142,7 @@ fn new(pdev: &platform::Device<Core>) -> impl PinInit<Self, Error> + '_ {
                         .property_read::<CString>(c_str!("compatible"))
                         .required_by(dev)?,
                 ),
+                _test <- debugfs.read_only_file(c_str!("test"), c_str!("some_value")),
                 counter <- Self::build_counter(&debugfs),
                 inner <- Self::build_inner(&debugfs),
                 _debugfs: debugfs,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ