All of lore.kernel.org
 help / color / mirror / Atom feed
* Fwd: [PATCH] rust: document safety requirements for fmt::Arguments dereference
       [not found] <CAO0d=D-+p2QbA9bxOSO0rd185GY5Pe0ruq=A=hcgTvovC3d1oA@mail.gmail.com>
@ 2025-12-14 13:11 ` Riccardo Adami
  2025-12-17 20:38   ` Alice Ryhl
  0 siblings, 1 reply; 2+ messages in thread
From: Riccardo Adami @ 2025-12-14 13:11 UTC (permalink / raw)
  To: rust-for-linux

---------- Forwarded message ---------
Da: Riccardo Adami <riccioadami@gmail.com>
Date: dom 14 dic 2025 alle ore 13:54
Subject: [PATCH] rust: document safety requirements for fmt::Arguments
dereference
To: <rust-for-linux@vger.kernel.org>


The `unsafe` dereference of `*ptr.cast::<fmt::Arguments<'_>>()` in
`rust_fmt_argument` is safe because `ptr` is provided by the kernel
formatting path for the `%pA` specifier and  during `vsnprintf`
processing.
 It always points to a valid `fmt::Arguments` value created by the caller.
 The value lives at least for the duration of this call and it is only
read here and not stored or accessed after returning.


--- a/rust/kernel/print_dot_rs
+++ b/rust/kernel/print_dot_rs
@@
-    // SAFETY: TODO.
+    // SAFETY: `ptr` is provided by the kernel formatting path for the `%pA`
+    // specifier during `vsnprintf` processing and always points to a valid
+    // `fmt::Arguments` value created by the caller. The value lives at least
+    // for the duration of this call and is only read here. It is not stored
+    // or accessed after returning, so dereferencing it is safe.
     let _ = w.write_fmt(unsafe { *ptr.cast::<fmt::Arguments<'_>>() });

Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fwd: [PATCH] rust: document safety requirements for fmt::Arguments dereference
  2025-12-14 13:11 ` Fwd: [PATCH] rust: document safety requirements for fmt::Arguments dereference Riccardo Adami
@ 2025-12-17 20:38   ` Alice Ryhl
  0 siblings, 0 replies; 2+ messages in thread
From: Alice Ryhl @ 2025-12-17 20:38 UTC (permalink / raw)
  To: Riccardo Adami; +Cc: rust-for-linux

On Sun, Dec 14, 2025 at 02:11:08PM +0100, Riccardo Adami wrote:
> ---------- Forwarded message ---------
> Da: Riccardo Adami <riccioadami@gmail.com>
> Date: dom 14 dic 2025 alle ore 13:54
> Subject: [PATCH] rust: document safety requirements for fmt::Arguments
> dereference
> To: <rust-for-linux@vger.kernel.org>
> 
> 
> The `unsafe` dereference of `*ptr.cast::<fmt::Arguments<'_>>()` in
> `rust_fmt_argument` is safe because `ptr` is provided by the kernel
> formatting path for the `%pA` specifier and  during `vsnprintf`
> processing.
>  It always points to a valid `fmt::Arguments` value created by the caller.
>  The value lives at least for the duration of this call and it is only
> read here and not stored or accessed after returning.
> 
> 
> --- a/rust/kernel/print_dot_rs
> +++ b/rust/kernel/print_dot_rs
> @@
> -    // SAFETY: TODO.
> +    // SAFETY: `ptr` is provided by the kernel formatting path for the `%pA`
> +    // specifier during `vsnprintf` processing and always points to a valid
> +    // `fmt::Arguments` value created by the caller. The value lives at least
> +    // for the duration of this call and is only read here. It is not stored
> +    // or accessed after returning, so dereferencing it is safe.
>      let _ = w.write_fmt(unsafe { *ptr.cast::<fmt::Arguments<'_>>() });
> 
> Thanks

This patch does not appear to be formatted correctly. Can you try using
git send-email?

Alice

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-17 20:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAO0d=D-+p2QbA9bxOSO0rd185GY5Pe0ruq=A=hcgTvovC3d1oA@mail.gmail.com>
2025-12-14 13:11 ` Fwd: [PATCH] rust: document safety requirements for fmt::Arguments dereference Riccardo Adami
2025-12-17 20:38   ` Alice Ryhl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.