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: <DC0A9UKTPH05.2O2V0B2KHMIW8@kernel.org>
Date: Tue, 12 Aug 2025 09:50:34 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Tamir Duberstein" <tamird@...il.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>, "Danilo Krummrich" <dakr@...nel.org>,
 "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>, "Rafael J. Wysocki"
 <rafael@...nel.org>, "Luis Chamberlain" <mcgrof@...nel.org>, "Russ Weight"
 <russ.weight@...ux.dev>, "Peter Zijlstra" <peterz@...radead.org>, "Ingo
 Molnar" <mingo@...hat.com>, "Will Deacon" <will@...nel.org>, "Waiman Long"
 <longman@...hat.com>, "Nathan Chancellor" <nathan@...nel.org>, "Nick
 Desaulniers" <nick.desaulniers+lkml@...il.com>, "Bill Wendling"
 <morbo@...gle.com>, "Justin Stitt" <justinstitt@...gle.com>, "Christian
 Brauner" <brauner@...nel.org>
Cc: <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
 <llvm@...ts.linux.dev>
Subject: Re: [PATCH v14 3/3] rust: replace `CStr` with `core::ffi::CStr`

On Thu Jul 10, 2025 at 4:53 PM CEST, Tamir Duberstein wrote:
> `kernel::ffi::CStr` was introduced in commit d126d2380131 ("rust: str:
> add `CStr` type") in November 2022 as an upstreaming of earlier work
> that was done in May 2021[0]. That earlier work, having predated the
> inclusion of `CStr` in `core`, largely duplicated the implementation of
> `std::ffi::CStr`.
>
> `std::ffi::CStr` was moved to `core::ffi::CStr` in Rust 1.64 in
> September 2022. Hence replace `kernel::str::CStr` with `core::ffi::CStr`
> to reduce our custom code footprint, and retain needed custom
> functionality through an extension trait.
>
> Add `CStr` to `ffi` and the kernel prelude.
>
> Link: https://github.com/Rust-for-Linux/linux/commit/faa3cbcca03d0dec8f8e43f1d8d5c0860d98a23f [0]
> Acked-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
> Signed-off-by: Tamir Duberstein <tamird@...il.com>

Reviewed-by: Benno Lossin <lossin@...nel.org>

> ---
>  rust/ffi.rs                     |   2 +
>  rust/kernel/device.rs           |   1 +
>  rust/kernel/error.rs            |   2 +
>  rust/kernel/firmware.rs         |   9 +-
>  rust/kernel/prelude.rs          |   4 +-
>  rust/kernel/seq_file.rs         |   2 +-
>  rust/kernel/str.rs              | 395 +++++++++-------------------------------
>  rust/kernel/sync/condvar.rs     |   2 +-
>  rust/kernel/sync/lock.rs        |   2 +-
>  rust/kernel/sync/lock/global.rs |   2 +-
>  10 files changed, 106 insertions(+), 315 deletions(-)

> +/// Extensions to [`CStr`].
> +pub trait CStrExt {

Should we make this trait sealed?

---
Cheers,
Benno

>      /// Wraps a raw C string pointer.
>      ///
>      /// # Safety

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ