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: <87h62419r5.fsf@kernel.org>
Date: Thu, 01 May 2025 20:11:42 +0200
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@...il.com>
Cc: "Danilo Krummrich" <dakr@...nel.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>,  "Benno Lossin" <benno.lossin@...ton.me>,
  "Alice Ryhl" <aliceryhl@...gle.com>,  "Trevor Gross" <tmgross@...ch.edu>,
  "Joel Becker" <jlbec@...lplan.org>,  "Peter Zijlstra"
 <peterz@...radead.org>,  "Ingo Molnar" <mingo@...hat.com>,  "Will Deacon"
 <will@...nel.org>,  "Waiman Long" <longman@...hat.com>,  "Fiona Behrens"
 <me@...enk.dev>,  "Charalampos Mitrodimas" <charmitro@...teo.net>,
  "Daniel Almeida" <daniel.almeida@...labora.com>,  "Breno Leitao"
 <leitao@...ian.org>,  <rust-for-linux@...r.kernel.org>,
  <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v6 1/3] rust: configfs: introduce rust support for configfs

"Miguel Ojeda" <miguel.ojeda.sandonis@...il.com> writes:

> On Thu, May 1, 2025 at 1:32 PM Andreas Hindborg <a.hindborg@...nel.org> wrote:
>>
>> The one just before the cut?
>
> Both.

But why does that matter? Anything in the commit message after the cut
is dropped when applying the patch, right?

>
>> Thanks. Would be nice with a lint for missed intra-doc links.
>
> Definitely -- I filled it a while back:
>
>     https://github.com/rust-lang/rust/issues/131510
>
>> Clippy gets mad if we move it up. Because rustfmt wants the unsafe block
>> to a new line:
>
> Yeah, then it is one of the cases I was referring to. In that case, it
> is fine, but please indent the safety comment to match the `unsafe`
> block.

OK. rustfmt does not seem to care about this though.

>
>> The reason I choose build_error is that if this should somehow end up
>> being evaluated in non-const context at some point, I want the build to
>> fail if the condition is not true. I don't think I get that with assert?
>
> I am not sure what you mean. My understanding is that `const` blocks,
> if execution reaches them, are always evaluated at compile-time (they
> are a const context):
>
>     https://doc.rust-lang.org/reference/expressions/block-expr.html#const-blocks
>
> e.g.
>
>     https://godbolt.org/z/h36s3nqWK
>
> We are lucky to have Gary with us, since he stabilized this particular
> language feature, so he can correct us! :)

I might not have the full picture, but it is my understanding that
while `const fn` are evaluated in const context when called from const
context, they _may_ be called from non-const context, and then they are
evaluated in non-const context if their arguments are not const [1].
They are not guaranteed to be evaluated in const context.

So my thinking is that down the road, refactoring of this code may cause
the `AttributeList::add` to be called in a way so that it is not
evaluated in const context, and then the `assert` would be evaluated at
run time. With `build_error` we would get an error during build.

But I should probably use `build_assert` instead of the conditional with
`build_error`.


Best regards,
Andreas Hindborg


[1] https://doc.rust-lang.org/reference/const_eval.html#r-const-eval.const-expr.list


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ