From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F36A54670; Fri, 13 Jun 2025 12:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749819232; cv=none; b=azv7nqu8Xclr+NYRZIL2jlj0X5Q8JvfHlyQMc3OQ5M+qWg9BHozJR8WpCXsGbbQKEvzIbSL2GAD5PgAjZXDLkOwaIM3DXeQiAaBIFjmq5pl4T5RPX0pvDKSBDmZNLG/16lTNPTgx0C7fGEVCeDdo/A9rIk2yOP64+M3Kzg9kl7k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749819232; c=relaxed/simple; bh=9NILGPi+IgsNtn81oQYyesjFnsHS92zOjt5H9tpm4W4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=YgUV7WoJYtYn1BcSzdxpsyiIjiDAeE+cGQQUxPYTR0jAv+Jz0NJOVxEM9FIg4F22OMb8AFN6IgFnOjRh8If/GTwbePZzZnDgq2YtEZBwwynWKHOWgR3IQ2U78kByZKdDNlRZcxLWk99pOOdTo1tftLid/AEqb0XjOUI4xYQEh2g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m0RVRQl8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m0RVRQl8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9940DC4CEE3; Fri, 13 Jun 2025 12:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749819231; bh=9NILGPi+IgsNtn81oQYyesjFnsHS92zOjt5H9tpm4W4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=m0RVRQl8cpn/vhBcA5bbs+XJt5w1gkbye0vIjR3iei/AbcVq7md2bmYkOWjXT8Ffg Kuod1g3bSdyhlGPqfpmlOth0iU5bxSebpLlXyq7JhxpgVVln9n+n8cKBMCauhjPx+7 bAX6PX5FgWOhK4tIHzcNUQorZaXeXZ5vd5pdYeVDfXAzARVQcpLbOP71l9SD9W2ugZ ZwyVP2uy9OyzMt94KQzCJ6NXQIdFUME2F/FcFJj+4ggyq1ravIXSDENoNpzG3b11yY naauGWtr7HIzpOgG7cvPDSbYSUl8R0wvpWQqYBsUCPUDKiMDr9kDkdmpKlZiuUAYYm KgCNLWYnWTroA== From: Andreas Hindborg To: "Benno Lossin" Cc: "Danilo Krummrich" , "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?Q?Bj?= =?utf-8?Q?=C3=B6rn?= Roy Baron , "Alice Ryhl" , "Trevor Gross" , "Bjorn Helgaas" , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , "Tamir Duberstein" , "Viresh Kumar" , , , Subject: Re: [PATCH v3 2/2] rust: types: require `ForeignOwnable::into_foreign` return non-null In-Reply-To: (Benno Lossin's message of "Thu, 12 Jun 2025 16:52:15 +0200") References: <20250612-pointed-to-v3-0-b009006d86a1@kernel.org> <20250612-pointed-to-v3-2-b009006d86a1@kernel.org> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Fri, 13 Jun 2025 14:53:42 +0200 Message-ID: <87sek3by5l.fsf@kernel.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "Benno Lossin" writes: > 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 >> Suggested-by: Alice Ryhl >> Signed-off-by: Andreas Hindborg >> --- >> 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. Which is exactly what I did :) Best regards, Andreas Hindborg