mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
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]>