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: <20250930120354.GA3415500@joelbox2>
Date: Tue, 30 Sep 2025 08:03:54 -0400
From: Joel Fernandes <joelagnelf@...dia.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
	linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
	dri-devel@...ts.freedesktop.org, dakr@...nel.org,
	Alistair Popple <apopple@...dia.com>,
	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
	bjorn3_gh@...tonmail.com, Benno Lossin <lossin@...nel.org>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
	David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
	Maxime Ripard <mripard@...nel.org>,
	Thomas Zimmermann <tzimmermann@...e.de>,
	John Hubbard <jhubbard@...dia.com>, Timur Tabi <ttabi@...dia.com>,
	joel@...lfernandes.org, Elle Rhumsaa <elle@...thered-steel.dev>,
	Yury Norov <yury.norov@...il.com>,
	Daniel Almeida <daniel.almeida@...labora.com>,
	nouveau@...ts.freedesktop.org
Subject: Re: [PATCH v4 6/6] rust: bitfield: Use 'as' operator for setter type
 conversion

On Mon, Sep 29, 2025 at 11:44:56PM +0900, Alexandre Courbot wrote:
> On Mon Sep 29, 2025 at 10:59 PM JST, Miguel Ojeda wrote:
> > On Sat, Sep 20, 2025 at 8:23 PM Joel Fernandes <joelagnelf@...dia.com> wrote:
> >>
> >> The bitfield macro's setter currently uses the From trait for type
> >> conversion, which is overly restrictive and prevents use cases such as
> >> narrowing conversions (e.g., u32 storage size to u8 field size) which
> >> aren't supported by From.
> >
> > Being restrictive is a good thing
> 
> On that note, I have been wondering whether we should not push the
> restriction up to having bounded primitive types with only a set number
> of bits valid, e.g. `bound_u8::<2>` is guaranteed to only contain values
> in the range `0..=3`.
> 
> Getters and setters would use these types depending on the number of
> bits of the field, meaning that a caller would have to validate the
> value they want to write if it does not implement e.g.
> `Into<bound_u8<2>>`.
> 
> A bit radical maybe, but correcness ensues. :)

In my v5, I will be rejecting setter inputs that are out of range. Do we have a
usecase where we want the inputs to exceed the bit width range? If not, let
us keep the API simple. I should probably post v5 today so we have a full
discussion on the same and get alignment from everyone.

Thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ