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: <aTocnf23EBdU3tFV@google.com>
Date: Thu, 11 Dec 2025 01:21:33 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Benno Lossin <lossin@...nel.org>
Cc: Alexandre Courbot <acourbot@...dia.com>, Miguel Ojeda <ojeda@...nel.org>, 
	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>, 
	Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>, John Hubbard <jhubbard@...dia.com>, 
	Alistair Popple <apopple@...dia.com>, Joel Fernandes <joelagnelf@...dia.com>, 
	Timur Tabi <ttabi@...dia.com>, Edwin Peer <epeer@...dia.com>, 
	Eliot Courtney <ecourtney@...dia.com>, rust-for-linux@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/2] rust: transmute: implement FromBytes and AsBytes
 for inhabited ZSTs

On Tue, Dec 09, 2025 at 01:14:08PM +0100, Benno Lossin wrote:
> On Tue Dec 9, 2025 at 3:57 AM CET, Alexandre Courbot wrote:
> > This is useful when using types that may or may not be empty in generic
> > code relying on these traits. It is also safe because technically a
> > no-op.
> >
> > Reviewed-by: Alistair Popple <apopple@...dia.com>
> > Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
> > ---
> >  rust/kernel/transmute.rs | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/rust/kernel/transmute.rs b/rust/kernel/transmute.rs
> > index be5dbf3829e2..a888a312e7ff 100644
> > --- a/rust/kernel/transmute.rs
> > +++ b/rust/kernel/transmute.rs
> > @@ -170,6 +170,10 @@ macro_rules! impl_frombytes {
> >  }
> >  
> >  impl_frombytes! {
> > +    // SAFETY: Inhabited ZSTs only have one possible bit pattern.
> 
> Even inhabited ZSTs cannot just be conjured out of thin air, since there
> might be safety invariants on the creation of such a type. Now these
> two concrete ones do not have any, so this is fine, but should still be
> mentioned in the comment IMO.

I think we can say "it has no invariants".

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ