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: <CAJ-ks9n4V-PEDhkTv6SXj_Oh6LB4LdsNi8Nnv_6JbT7dhvnh2w@mail.gmail.com>
Date: Wed, 13 Aug 2025 10:06:11 -0400
From: Tamir Duberstein <tamird@...il.com>
To: Benno Lossin <lossin@...nel.org>
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>, 
	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>, 
	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 Tue, Aug 12, 2025 at 3:50 AM Benno Lossin <lossin@...nel.org> wrote:
>
> 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>

Thanks!


> > ---
> >  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?

We can -- but is it harmful for someone to implement? I think probably not.

>
> ---
> Cheers,
> Benno
>
> >      /// Wraps a raw C string pointer.
> >      ///
> >      /// # Safety

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ