[PATCH v3 0/2] rust: improve `ForeignOwnable`

Andreas Hindborg posted 2 patches 4 months ago
rust/kernel/alloc/kbox.rs | 41 +++++++++++++++++++++++------------------
rust/kernel/miscdevice.rs | 10 +++++-----
rust/kernel/pci.rs        |  2 +-
rust/kernel/platform.rs   |  2 +-
rust/kernel/sync/arc.rs   | 24 +++++++++++++-----------
rust/kernel/types.rs      | 46 +++++++++++++++++++++++-----------------------
rust/kernel/xarray.rs     |  9 +++++----
7 files changed, 71 insertions(+), 63 deletions(-)
[PATCH v3 0/2] rust: improve `ForeignOwnable`
Posted by Andreas Hindborg 4 months ago
This series improves `ForeignOwnable` by:

 - changing the way we assert pointer allignment,
 - improving the safety requirements of the trait.

Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
Changes in v3:
- Remove more instances of absolute paths to `ffi` types.
- Reword safety requirements in terms of function guarantees.
- Add a patch to restrict use of null pointers with `ForeignOwnable`.
- Link to v2: https://lore.kernel.org/r/20250610-pointed-to-v2-1-fad8f92cf1e5@kernel.org

Changes in v2:
- Replace qualified path with `use` for `crate::ffi::c_void`.
- Fix a typo and rephrase docs for `ForeignOwnable`.
- Reorganize docs for `ForeignOwnable::into_foreign`.
- Link to v1: https://lore.kernel.org/r/20250605-pointed-to-v1-1-ee1e262912cc@kernel.org

---
Andreas Hindborg (2):
      rust: types: add FOREIGN_ALIGN to ForeignOwnable
      rust: types: require `ForeignOwnable::into_foreign` return non-null

 rust/kernel/alloc/kbox.rs | 41 +++++++++++++++++++++++------------------
 rust/kernel/miscdevice.rs | 10 +++++-----
 rust/kernel/pci.rs        |  2 +-
 rust/kernel/platform.rs   |  2 +-
 rust/kernel/sync/arc.rs   | 24 +++++++++++++-----------
 rust/kernel/types.rs      | 46 +++++++++++++++++++++++-----------------------
 rust/kernel/xarray.rs     |  9 +++++----
 7 files changed, 71 insertions(+), 63 deletions(-)
---
base-commit: ec7714e4947909190ffb3041a03311a975350fe0
change-id: 20250605-pointed-to-6170ae01520f

Best regards,
-- 
Andreas Hindborg <a.hindborg@kernel.org>
Re: [PATCH v3 0/2] rust: improve `ForeignOwnable`
Posted by Miguel Ojeda 2 months, 3 weeks ago
On Thu, Jun 12, 2025 at 3:11 PM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> This series improves `ForeignOwnable` by:
>
>  - changing the way we assert pointer allignment,
>  - improving the safety requirements of the trait.
>
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>

Applied to `rust-next` -- thanks everyone!

Cheers,
Miguel
Re: [PATCH v3 0/2] rust: improve `ForeignOwnable`
Posted by Alice Ryhl 3 months, 2 weeks ago
On Thu, Jun 12, 2025 at 3:11 PM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> This series improves `ForeignOwnable` by:
>
>  - changing the way we assert pointer allignment,
>  - improving the safety requirements of the trait.
>
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
> ---
> Changes in v3:
> - Remove more instances of absolute paths to `ffi` types.
> - Reword safety requirements in terms of function guarantees.
> - Add a patch to restrict use of null pointers with `ForeignOwnable`.
> - Link to v2: https://lore.kernel.org/r/20250610-pointed-to-v2-1-fad8f92cf1e5@kernel.org
>
> Changes in v2:
> - Replace qualified path with `use` for `crate::ffi::c_void`.
> - Fix a typo and rephrase docs for `ForeignOwnable`.
> - Reorganize docs for `ForeignOwnable::into_foreign`.
> - Link to v1: https://lore.kernel.org/r/20250605-pointed-to-v1-1-ee1e262912cc@kernel.org
>
> ---
> Andreas Hindborg (2):
>       rust: types: add FOREIGN_ALIGN to ForeignOwnable
>       rust: types: require `ForeignOwnable::into_foreign` return non-null
>
>  rust/kernel/alloc/kbox.rs | 41 +++++++++++++++++++++++------------------
>  rust/kernel/miscdevice.rs | 10 +++++-----
>  rust/kernel/pci.rs        |  2 +-
>  rust/kernel/platform.rs   |  2 +-
>  rust/kernel/sync/arc.rs   | 24 +++++++++++++-----------
>  rust/kernel/types.rs      | 46 +++++++++++++++++++++++-----------------------
>  rust/kernel/xarray.rs     |  9 +++++----
>  7 files changed, 71 insertions(+), 63 deletions(-)

Reviewed-by: Alice Ryhl <aliceryhl@google.com>