On 9/23/26 10:31 PM, Priya Bala Govindasamy wrote:
> 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: 0b08fc292842 ("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]>
I've queued the patch (v2) on modules-next for v7.4-rc1.
--
Thanks,
Petr