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: <29c6fb60-0b5e-4822-bd49-80ce3d9eb6d9@suse.com>
Date: Wed, 14 Jan 2026 15:26:30 +0100
From: Petr Pavlu <petr.pavlu@...e.com>
To: Kari Argillander <kari.argillander@...il.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>, Alice Ryhl <aliceryhl@...gle.com>,
 Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>,
 Alexandre Courbot <acourbot@...dia.com>,
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-modules@...r.kernel.org, Luis Chamberlain <mcgrof@...nel.org>,
 Daniel Gomez <da.gomez@...nel.org>, Sami Tolvanen <samitolvanen@...gle.com>,
 Aaron Tomlin <atomlin@...mlin.com>
Subject: Re: [PATCH RFC v3 02/15] rust: add new ThisModule trait and
 THIS_MODULE impl

On 1/10/26 4:08 PM, Kari Argillander wrote:
> To make clear separation between module crates and kernel crate we
> introduce ThisModule trait which is meant to be used by kernel space.
> THIS_MODULE is meant to be used by modules. So kernel create will be
> unable to even accidentally use THIS_MODULE.
> 
> As ThisModule is trait we can pass that around in const context. This is
> needed so that we can read ownership information in const context when
> we create example file_operations structs for modules.
> 
> New ThisModule will also eventually replace kernel::ModuleMetadata trait
> and for this reason it also have NAME field.
> 
> To make transition smooth use mod this_module so we can have two
> ThisModule same time. Also some functionality is added to THIS_MODULE
> temporarily so that we do not have to change everything at once.
> 
> Also docs examples will need THIS_MODULE so also define that in docs.
> 
> Signed-off-by: Kari Argillander <kari.argillander@...il.com>

Is this pattern common in other Rust code in the kernel? The situation
on the C side is that THIS_MODULE is a variable of the module struct. On
the Rust side, it is currently quite similar, with THIS_MODULE being a
variable of the ThisModule struct/wrapper. The patch shifts this and
makes THIS_MODULE a type that implements the ThisModule trait.

Naively, it seems somewhat confusing to me, coming mostly from the C
side and expecting THIS_MODULE to be a variable.

I'd like to understand this better. Would enabling const_refs_to_static
alone be sufficient, or is it necessary to make THIS_MODULE a type for
this to work? Should we be concerned that this new model could confuse
people, or do you think it actually simplifies things? Does making the
functions generic on ThisModule impact code size in any significant way,
or could it in the future?

-- 
Thanks,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ