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: <aFAx997imisc3HGk@Mac.home>
Date: Mon, 16 Jun 2025 08:02:15 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Daniel Almeida <daniel.almeida@...labora.com>
Cc: Alexandre Courbot <acourbot@...dia.com>,
	Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
	Danilo Krummrich <dakr@...nel.org>, linux-kernel@...r.kernel.org,
	rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v6] rust: kernel: add support for bits/genmask macros

On Mon, Jun 16, 2025 at 11:45:21AM -0300, Daniel Almeida wrote:
> 
> 
> > On 16 Jun 2025, at 11:42, Daniel Almeida <daniel.almeida@...labora.com> wrote:
> > 
> > Hi Boqun,
> > 
> >> 
> >> We should tell/educate people to do the right thing, if a..b is not
> >> inclusive in Rust, then we should treat them as non-inclusive in Rust
> >> kernel code. Otherwise you create confusion for no reason. My assumption
> >> is that most people will ask "what's the right way to do this" first
> >> instead of replicating the old way.
> >> 
> >> Regards,
> >> Boqun
> >> 
> > 
> > This is just my opinion, of course:
> > 
> > I _hardly_ believe this will be the case. When people see genmask and two
> > numbers, they expect the range to be inclusive, full stop (at least IMHO). That's how it has
> > worked for decades, so it´s only natural to expect this behavior to transfer over.
> > 

Well, there are always users who don't read the manual, but we shouldn't
encourage that ;-) Technically kernel internal API is unstable, so use
before fully understanding the semantics is a user risk.

And if we provided non-inclusive range as inclusive, there would be
complains (probably from the same people) that:

    for_each_bit(genmask(a..b), |i| { do_sth(i); });

doesn't behave the same as:

    for i in a..b { do_sth(i); }

And we cannot always make them happy ;-)

> > However, I do understand and agree with your point, and I will change the
> > implementation here to comply. Perhaps we can use some markdown to alert users?
> > 
> > - Daniel
> 
> Or better yet, perhaps we should only support a..=b.
> 

Yes, given the const function factor for now, and I think eventually
most people will get themselves more familiar with Rust syntax.

Regards,
Boqun

> - Daniel 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ