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] [day] [month] [year] [list]
Message-ID: <D9CKABQE6FC5.IGM9KTS4E0VX@proton.me>
Date: Mon, 21 Apr 2025 19:25:30 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Tamir Duberstein <tamird@...il.com>
Cc: Simona Vetter <simona.vetter@...ll.ch>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 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>, Aliet Exposito Garcia <aliet.exposito@...il.com>, Fiona Behrens <me@...enk.dev>, rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/4] rust: transmute: add `cast_slice[_mut]` functions

On Mon Apr 21, 2025 at 8:42 PM CEST, Tamir Duberstein wrote:
> On Mon, Apr 21, 2025 at 9:50 AM Benno Lossin <benno.lossin@...ton.me> wrote:
>> +/// Casts the type of a slice to another.
>> +///
>> +/// # Examples
>> +///
>> +/// ```rust
>> +/// # use kernel::transmute::cast_slice;
>> +/// #[repr(transparent)]
>> +/// #[derive(Debug)]
>> +/// struct Container<T>(T);
>> +///
>> +/// let array = [0u32; 42];
>> +/// let slice = &array;
>> +/// // SAFETY: `Container<T>` transparently wraps a `T`.
>> +/// let container_slice = unsafe { cast_slice(slice) };
>> +/// pr_info!("{container_slice}");
>> +/// ```
>
> How can this example compile? The type of `container_slice` can't
> possibly be known.

I should really start the habit of rerunning my testing scripts before
final submission... I added this example after the initial run... I
think you're correct in that it doesn't compile. Will fix for the next
version.

---
Cheers,
Benno


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ