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: <aQoJUAdFFBpQiEZU@google.com>
Date: Tue, 4 Nov 2025 14:10:24 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, 
	"Björn Roy Baron" <bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>, 
	Andreas Hindborg <a.hindborg@...nel.org>, Trevor Gross <tmgross@...ch.edu>, 
	Danilo Krummrich <dakr@...nel.org>, Nathan Chancellor <nathan@...nel.org>, 
	Nicolas Schier <nicolas.schier@...ux.dev>, linux-kernel@...r.kernel.org, 
	rust-for-linux@...r.kernel.org, linux-kbuild@...r.kernel.org
Subject: Re: [PATCH v2] rust: enable slice_flatten feature and provide it
 through an extension trait

On Tue, Nov 04, 2025 at 12:53:18PM +0900, Alexandre Courbot wrote:
> In Rust 1.80, the previously unstable `slice::flatten` family of methods
> have been stabilized and renamed to `slice::as_flattened`.
> 
> This creates an issue as we want to use `as_flattened`, but need to
> support the MSRV (which at the moment is Rust 1.78) where it is named
> `flatten`.
> 
> Solve this by enabling the `slice_flatten` feature, and providing an
> `as_flattened` implementation through an extension trait for compiler
> versions where it is not available.
> 
> This lets code use `as_flattened` portably by just adding
> 
>     #[cfg(not(CONFIG_RUSTC_HAS_SLICE_AS_FLATTENED))]
>     use kernel::slice::AsFlattened;
> 
> This extension trait can be removed once the MSRV passes 1.80.
> 
> Suggested-by: Miguel Ojeda <ojeda@...nel.org>
> Link: https://lore.kernel.org/all/CANiq72kK4pG=O35NwxPNoTO17oRcg1yfGcvr3==Fi4edr+sfmw@mail.gmail.com/
> Acked-by: Danilo Krummrich <dakr@...nel.org>
> Acked-by: Miguel Ojeda <ojeda@...nel.org>
> Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
> ---
> This patch was part of the Nova GSP boot series [1], but since it
> requires attention from the core Rust team (and possibly the build
> maintainers?) and is otherwise buried under Nova patches, I am taking
> the freedom to send it separately for visibility.
> 
> For v2, the methods are aligned with the final names of the standard
> library, and the extension trait is only visible when needed. This
> simplifies both the patch, and the extra labor for user code.
> 
> [1] https://lore.kernel.org/all/20251029-gsp_boot-v7-0-34227afad347@nvidia.com/
> [2] https://lore.kernel.org/all/CANiq72kK4pG=O35NwxPNoTO17oRcg1yfGcvr3==Fi4edr+sfmw@mail.gmail.com/

With the below concern verified, you may add:
Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>

> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index d0ee33a487be..a84b9e3171a3 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -308,6 +308,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
>  
>  # The features in this list are the ones allowed for non-`rust/` code.
>  #
> +#   - Stable since Rust 1.80.0: `feature(slice_flatten)`.
>  #   - Stable since Rust 1.81.0: `feature(lint_reasons)`.
>  #   - Stable since Rust 1.82.0: `feature(asm_const)`,
>  #     `feature(offset_of_nested)`, `feature(raw_ref_op)`.
> @@ -317,7 +318,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
>  #
>  # Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
>  # the unstable features in use.
> -rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,used_with_arg
> +rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,offset_of_nested,raw_ref_op,slice_flatten,used_with_arg

You should double-check, but I don't think you need to list it here
because all uses of the unstable method are under the `rust/` directory.

Alice

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ