Re: [PATCH] rust: print: add safety comments for %pA formatting
From: Muchamad Coirul Anwar
Date: Wed Feb 11 2026 - 08:45:25 EST
Hi Shivendra,
That sounds great, I agree with the plan.
The wording for the SAFETY comment matches exactly what Alice
suggested, so it looks good to me.
Please feel free to include my tags:
Co-developed-by: Muchamad Coirul Anwar <muchamadcoirulanwar@xxxxxxxxx>
Signed-off-by: Muchamad Coirul Anwar <muchamadcoirulanwar@xxxxxxxxx>
Thanks for taking the lead on the v2
Best regards,
Muchamad Coirul Anwar
Pada Rab, 11 Feb 2026 pukul 16.58 Shivendra Sharma
<shivendra02467@xxxxxxxxx> menulis:
>
> Hi Muchamad, Miguel,
>
> Thanks for the response! I’m happy to take the lead on the v2 patch.
>
> Regarding the safety comments, I think Alice actually gave us the perfect wording in her reply. She suggested removing the specific reference to call_printk to make it more generic since %pA is used in other places like seq_file.rs.
>
> To keep things simple and ensure we follow her suggestion exactly, I’ll use this text for the SAFETY comment:
>
> // SAFETY: The C implementation of `vsprintf` (in `lib/vsprintf.c`) specifically
>
> // calls this function ONLY when processing the `%pA` format specifier.
>
> // On the Rust side, we always pair `%pA` with a valid pointer to
>
> // `fmt::Arguments`.
>
> Muchamad, if you're okay with that, I'll integrate this into the v2 along with the cleanup from my previous patch and Miguel's earlier suggestions. I'll include you as a Co-author.
>
> Does that sound good to everyone?
>
> Best regards,
>
> Shivendra
>
>
> On Wed, Feb 11, 2026, 3:12 PM Muchamad Coirul Anwar <muchamadcoirulanwar@xxxxxxxxx> wrote:
>>
>> Hi Miguel, Shivendra,
>>
>> Thanks for the heads-up, Miguel, I'd be happy to collaborate with Shivendra on this. Hi Shivendra, I checked your patch and I really like how you handled the documentation and the C-header part. It’s definitely cleaner than my initial attempt. That said, I just got some feedback from Alice Ryhl regarding the internal '// SAFETY' comments. She pointed out that we should make the safety guarantee generic (covering `seq_file` usage too, not just `printk`). How about we combine our work? You could take the lead on the v2 patch, and I can provide the updated safety comment text that covers Alice's feedback. Let me know what you think.
>>
>> Best regards,
>> Muchamad Coirul Anwar
>>
>> Pada Sel, 10 Feb 2026 pukul 22.00 Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> menulis:
>>>
>>> On Thu, Feb 5, 2026 at 5:23 AM Muchamad Coirul Anwar
>>> <muchamadcoirulanwar@xxxxxxxxx> wrote:
>>> >
>>> > The safety comments in `rust_fmt_argument` and `call_printk` were
>>> > previously marked as TODO.
>>> >
>>> > This patch adds the missing safety documentation explaining why
>>> > dereferencing the pointers and calling the C `_printk` function
>>> > is safe in these contexts. It clarifies the contract between
>>> > `lib/vsprintf.c` and the Rust implementation regarding the `%pA`
>>> > format specifier.
>>> >
>>> > Signed-off-by: Muchamad Coirul Anwar <muchamadcoirulanwar@xxxxxxxxx>
>>>
>>> Related:
>>>
>>> https://lore.kernel.org/rust-for-linux/20260128202130.196419-1-shivendra02467@xxxxxxxxx/
>>>
>>> Cc'ing Shivendra.
>>>
>>> Could you (i.e. both) please coordinate the patches, perhaps merging
>>> them into a single series? You may want to use Co-developed-by and/or
>>> have a different author per patch etc.
>>>
>>> Thanks!
>>>
>>> Cheers,
>>> Miguel