[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260106-this_module_fix-v2-0-842ac026f00b@gmail.com>
Date: Tue, 06 Jan 2026 18:11:38 +0200
From: Kari Argillander <kari.argillander@...il.com>
To: 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>
Cc: 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>,
Petr Pavlu <petr.pavlu@...e.com>, Daniel Gomez <da.gomez@...nel.org>,
Sami Tolvanen <samitolvanen@...gle.com>, Aaron Tomlin <atomlin@...mlin.com>,
Kari Argillander <kari.argillander@...il.com>,
Youseok Yang <ileixe@...il.com>, Yuheng Su <gipsyh.icu@...il.com>
Subject: [PATCH RFC v2 00/11] rust: Reimplement ThisModule to fix ownership
problems
Still RFC. Not all people for each subsystems are not included yet as
this touch quite lot of things. Introducing new THIS_MODULE and
ThisModule still change configfs in same patch which is not ideal.
So currently we have problem that we are not always filling .owner field
for file_operations. I think we can enable const_refs_to_static already
as that is in 1.78 and is stable in 1.83. So that fits perfecly for us.
This also seems to be quite request feature but I did not found that no
one has ever suggested that we just enable this.
So basic idea is that we will have ThisModule trait which is used kernel
side. Module side we will always use THIS_MODULE. That is completly
private for modules and kernel cannot use it. So this unifies ways of
using cofing ThisModule things. Currently we have THIS_MODULE and also
module: &' static ThisModule
on init functions. As we anyway need THIS_MODULE just use that.
Argillander
To: Miguel Ojeda <ojeda@...nel.org>
To: Boqun Feng <boqun.feng@...il.com>
To: Gary Guo <gary@...yguo.net>
To: Björn Roy Baron <bjorn3_gh@...tonmail.com>
To: Benno Lossin <lossin@...nel.org>
To: Andreas Hindborg <a.hindborg@...nel.org>
To: Alice Ryhl <aliceryhl@...gle.com>
To: Trevor Gross <tmgross@...ch.edu>
To: Danilo Krummrich <dakr@...nel.org>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Luis Chamberlain <mcgrof@...nel.org>
Cc: Petr Pavlu <petr.pavlu@...e.com>
Cc: Daniel Gomez <da.gomez@...nel.org>
Cc: Sami Tolvanen <samitolvanen@...gle.com>
Cc: Aaron Tomlin <atomlin@...mlin.com>
Signed-off-by: Kari Argillander <kari.argillander@...il.com>
---
Changes in v2:
- Patches are now sepereted properly.
- Removed debugfs changes as that is not so clear to me.
- Remove module parameter and just used THIS_MODULE everywhere.
- Made macro to make THIS_MODULE.
- Doc tests also have THIS_MODULE.
- Link to v1: https://lore.kernel.org/r/20260101-this_module_fix-v1-0-46ae3e5605a0@gmail.com
---
Kari Argillander (11):
rust: enable const_refs_to_static feature
rust: add new ThisModule trait and THIS_MODULE impl
rust: miscdevice: fix use after free because missing .owner
rust: block: fix missing owner field in block_device_operations
rust: drm: fix missing owner in file_operations
rust: driver: make RegistrationOps::register() to use new ThisModule
rust: phy: make Registration::register() use new ThisModule
rust: binder: use new THIS_MODULE
rust: remove module argument from InPlaceModule::init()
rust: remove kernel::ModuleMetadata
rust: remove old version of ThisModule
drivers/android/binder/rust_binder_main.rs | 5 +-
drivers/block/rnull/configfs.rs | 2 +-
drivers/block/rnull/rnull.rs | 3 +-
drivers/gpu/drm/nova/driver.rs | 2 +
drivers/gpu/drm/tyr/driver.rs | 2 +
drivers/gpu/nova-core/nova_core.rs | 2 +-
lib/find_bit_benchmark_rust.rs | 3 +-
rust/kernel/auxiliary.rs | 16 +--
rust/kernel/block/mq.rs | 1 +
rust/kernel/block/mq/gen_disk.rs | 30 +-----
rust/kernel/block/mq/operations.rs | 30 ++++++
rust/kernel/configfs.rs | 49 ++++-----
rust/kernel/driver.rs | 31 +++---
rust/kernel/drm/device.rs | 2 +-
rust/kernel/drm/driver.rs | 4 +
rust/kernel/drm/gem/mod.rs | 5 +-
rust/kernel/firmware.rs | 4 +-
rust/kernel/i2c.rs | 11 +-
rust/kernel/lib.rs | 161 ++++++++++++++++++++++++-----
rust/kernel/miscdevice.rs | 5 +
rust/kernel/net/phy.rs | 29 ++++--
rust/kernel/pci.rs | 15 +--
rust/kernel/platform.rs | 12 +--
rust/kernel/prelude.rs | 2 +-
rust/kernel/sync/lock/global.rs | 4 +-
rust/kernel/usb.rs | 13 +--
rust/macros/lib.rs | 4 +-
rust/macros/module.rs | 24 +----
samples/rust/rust_configfs.rs | 2 +-
samples/rust/rust_debugfs_scoped.rs | 2 +-
samples/rust/rust_driver_auxiliary.rs | 8 +-
samples/rust/rust_driver_faux.rs | 2 +-
samples/rust/rust_minimal.rs | 2 +-
samples/rust/rust_misc_device.rs | 3 +-
samples/rust/rust_print_main.rs | 2 +-
scripts/rustdoc_test_gen.rs | 2 +
36 files changed, 298 insertions(+), 196 deletions(-)
---
base-commit: 6cd6c12031130a349a098dbeb19d8c3070d2dfbe
change-id: 20251230-this_module_fix-a390bff24897
Best regards,
--
Kari Argillander <kari.argillander@...il.com>
Powered by blists - more mailing lists