All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Riccardo Adami <riccioadami@gmail.com>
Cc: rust-for-linux@vger.kernel.org
Subject: Re: Fwd: [PATCH] rust: document safety requirements for fmt::Arguments dereference
Date: Wed, 17 Dec 2025 20:38:27 +0000	[thread overview]
Message-ID: <aUMUw3A5yWxugLyC@google.com> (raw)
In-Reply-To: <CAO0d=D8c_JYAvhe6cB-R+23-uxH5AnKi7TtuLA3Ra3hfViiGgw@mail.gmail.com>

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

      reply	other threads:[~2025-12-17 20:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aUMUw3A5yWxugLyC@google.com \
    --to=aliceryhl@google.com \
    --cc=riccioadami@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.