Files
linux/rust/kernel
Priya Bala Govindasamy 2e8bac09ed rust: module_param: Fix potentially incorrect access of SetOnce<T>
The `set_param` function casts `kernel_param.arg` to `*const SetOnce<T>`
But the Rust module macro in rust/macros/module.rs initializes `arg` with
`#param_name.as_void_ptr()`, and `#param_name` is a `ModuleParamAccess<T>`,
not a `SetOnce<T>`.

ModuleParamAccess<T> has default Rust layout but `set_param` accesses its
first field SetOnce<T> assuming it to be at offset 0. This is not
guaranteed by Rust and could cause type confusion leading to data
corruption.

Fix this by casting `kernel_param.arg` to `ModuleParamAccess<T>` and
then accessing the `value: SetOnce<T>` field.

Fixes: 0b08fc2928 ("rust: introduce module_param module")
Cc: [email protected]
Reported-by: Dylan Zueck <[email protected]>
Assisted-by: LLM
Suggested-by: Andreas Hindborg <[email protected]>
Signed-off-by: Priya Bala Govindasamy <[email protected]>
Signed-off-by: Petr Pavlu <[email protected]>
2026-10-14 10:42:40 +02:00
..
2025-11-05 00:05:38 +01:00
…
2026-04-03 11:57:35 +02:00
…
2026-08-20 10:58:44 +10:00
…
2026-08-10 12:53:09 +02:00
2026-08-20 10:58:44 +10:00
…
…
2026-07-30 22:50:15 +02:00
2026-05-25 09:40:52 +05:30
2025-12-28 12:43:56 +01:00