Re: [PATCH] rust: print: add SAFETY comments to unsafe blocks
From: Miguel Ojeda
Date: Sat Mar 21 2026 - 19:14:12 EST
On Sat, Mar 21, 2026 at 3:34 PM Albab Hasan <albabhasan276@xxxxxxxxx> wrote:
>
> Replace the placeholder // SAFETY: TODO. comments with proper safety
> descriptions for the two unsafe blocks in rust_fmt_argument and
> call_printk.
>
> For rust_fmt_argument the ptr parameter is provided by the %pA
> format specifier handler in vsprintf that guarantees it points to a
> valid properly aligned fmt::Arguments<'_> value. since
> fmt::Arguments implements Copy the dereference is a bitwise
> copy with no side effects.
>
> For call_printk the safety depends on the functions documented
> preconditions the format string is one of the fixed compile time
> constants from format_strings and the module name is null terminated.
> the arguments match the format specifiers (%s for module name %pA
> for the fmt::Arguments pointer).
>
> Signed-off-by: Albab Hasan <albabhasan276@xxxxxxxxx>
Did you see the following ones?
https://lore.kernel.org/rust-for-linux/20260212125427.122362-1-alizainuimx@xxxxxxxxx/
https://lore.kernel.org/rust-for-linux/20260211182755.82220-1-shivendra02467@xxxxxxxxx/
What is the relation with them? (Cc'ing their authors)
Thanks!
Link: https://github.com/Rust-for-Linux/linux/issues/351
Cheers,
Miguel