]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: types: add FOREIGN_ALIGN to ForeignOwnable
authorAndreas Hindborg <a.hindborg@kernel.org>
Thu, 12 Jun 2025 13:09:43 +0000 (15:09 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 14 Jul 2025 21:55:24 +0000 (23:55 +0200)
commit12717ebeffcf3e34063dbc1e1b7f34924150c7c9
treecc9818d02cff1adcc0c3029b5e8f522a8d126116
parentb6f885060e8e24f1a1a9205ba41a0524964e8c30
rust: types: add FOREIGN_ALIGN to ForeignOwnable

The current implementation of `ForeignOwnable` is leaking the type of the
opaque pointer to consumers of the API. This allows consumers of the opaque
pointer to rely on the information that can be extracted from the pointer
type.

To prevent this, change the API to the version suggested by Maira
Canal (link below): Remove `ForeignOwnable::PointedTo` in favor of a
constant, which specifies the alignment of the pointers returned by
`into_foreign`.

With this change, `ArcInner` no longer needs `pub` visibility, so change it
to private.

Suggested-by: Alice Ryhl <aliceryhl@google.com>
Suggested-by: MaĆ­ra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20240309235927.168915-3-mcanal@igalia.com
Acked-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250612-pointed-to-v3-1-b009006d86a1@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/alloc/kbox.rs
rust/kernel/miscdevice.rs
rust/kernel/pci.rs
rust/kernel/platform.rs
rust/kernel/sync/arc.rs
rust/kernel/types.rs
rust/kernel/xarray.rs