From: "Benno Lossin" <lossin@kernel.org>
To: "Andreas Hindborg" <a.hindborg@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Tamir Duberstein" <tamird@gmail.com>,
"Viresh Kumar" <viresh.kumar@linaro.org>
Cc: <rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-pci@vger.kernel.org>
Subject: Re: [PATCH v3 2/2] rust: types: require `ForeignOwnable::into_foreign` return non-null
Date: Thu, 12 Jun 2025 16:52:15 +0200 [thread overview]
Message-ID: <DAKN1HO7WUXY.QS098VXTDICU@kernel.org> (raw)
In-Reply-To: <20250612-pointed-to-v3-2-b009006d86a1@kernel.org>
On Thu Jun 12, 2025 at 3:09 PM CEST, Andreas Hindborg wrote:
> The intended implementations of `ForeignOwnable` will not return null
> pointers from `into_foreign`, as this would render the implementation of
> `try_from_foreign` useless. Current users of `ForeignOwnable` rely on
> `into_foreign` returning non-null pointers. So require `into_foreign` to
> return non-null pointers.
>
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
> ---
> rust/kernel/types.rs | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
> index c156808a78d3..63a2559a545f 100644
> --- a/rust/kernel/types.rs
> +++ b/rust/kernel/types.rs
> @@ -43,6 +43,7 @@ pub unsafe trait ForeignOwnable: Sized {
> /// # Guarantees
> ///
> /// - Minimum alignment of returned pointer is [`Self::FOREIGN_ALIGN`].
> + /// - The returned pointer is not null.
This also needs to be mentioned in the `Safety` section of this trait.
Alternatively you can put "Implementers must ensure the guarantees on
[`into_foreign`] are upheld." or similar.
---
Cheers,
Benno
> ///
> /// [`from_foreign`]: Self::from_foreign
> /// [`try_from_foreign`]: Self::try_from_foreign
next prev parent reply other threads:[~2025-06-12 14:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 13:09 [PATCH v3 0/2] rust: improve `ForeignOwnable` Andreas Hindborg
2025-06-12 13:09 ` [PATCH v3 1/2] rust: types: add FOREIGN_ALIGN to ForeignOwnable Andreas Hindborg
2025-06-12 13:09 ` [PATCH v3 2/2] rust: types: require `ForeignOwnable::into_foreign` return non-null Andreas Hindborg
2025-06-12 14:52 ` Benno Lossin [this message]
2025-06-13 12:53 ` Andreas Hindborg
2025-06-14 18:53 ` Benno Lossin
2025-06-27 14:20 ` [PATCH v3 0/2] rust: improve `ForeignOwnable` Alice Ryhl
2025-07-14 23:32 ` Miguel Ojeda
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=DAKN1HO7WUXY.QS098VXTDICU@kernel.org \
--to=lossin@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@gmail.com \
--cc=tmgross@umich.edu \
--cc=viresh.kumar@linaro.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.