[PATCH v2 0/5] rust: binder: reduce `as` casts

Tamir Duberstein posted 5 patches 1 week, 6 days ago
drivers/android/binder/allocation.rs       |  4 ++--
drivers/android/binder/defs.rs             |  8 +++++---
drivers/android/binder/freeze.rs           |  2 +-
drivers/android/binder/node.rs             | 14 ++++++++------
drivers/android/binder/node/wrapper.rs     |  2 +-
drivers/android/binder/page_range.rs       |  8 ++++----
drivers/android/binder/process.rs          | 14 +++++++-------
drivers/android/binder/rust_binder_main.rs | 10 ++--------
drivers/android/binder/thread.rs           | 24 +++++++++++++-----------
drivers/android/binder/trace.rs            |  4 +++-
drivers/android/binder/transaction.rs      | 14 ++++++++------
11 files changed, 54 insertions(+), 50 deletions(-)
[PATCH v2 0/5] rust: binder: reduce `as` casts
Posted by Tamir Duberstein 1 week, 6 days ago
Follow up on the treewide Clippy lint series [1]. The Rust Binder driver
retains local allows for `clippy::ptr_as_ptr`, `clippy::ref_as_ptr`,
`clippy::as_underscore`, and `clippy::cast_lossless` even though those
lints are enabled for the rest of the kernel.

Fix the Binder violations and remove those allows one lint at a time.
The first patch replaces Binder pointer-to-integer conversions with
calls to the strict provenance APIs now that they are available at the
Rust MSRV.

Link: https://lore.kernel.org/r/20250615-ptr-as-ptr-v12-0-f43b024581e8@gmail.com [1]

Signed-off-by: Tamir Duberstein <tamird@kernel.org>
---
Changes in v2:
- Drop ref-to-ref transmute patch.
- Restore various `as` casts needed for platform compatibility.
- Link to v1: https://patch.msgid.link/20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org

To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Arve Hjønnevåg <arve@android.com>
To: Todd Kjos <tkjos@android.com>
To: Christian Brauner <brauner@kernel.org>
To: Carlos Llamas <cmllamas@google.com>
To: Alice Ryhl <aliceryhl@google.com>
To: Miguel Ojeda <ojeda@kernel.org>
To: Boqun Feng <boqun@kernel.org>
To: Gary Guo <gary@garyguo.net>
To: Björn Roy Baron <bjorn3_gh@protonmail.com>
To: Benno Lossin <lossin@kernel.org>
To: Andreas Hindborg <a.hindborg@kernel.org>
To: Trevor Gross <tmgross@umich.edu>
To: Danilo Krummrich <dakr@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: rust-for-linux@vger.kernel.org

---
Tamir Duberstein (5):
      rust: binder: use strict provenance APIs
      rust: binder: enable `clippy::ptr_as_ptr` lint
      rust: binder: enable `clippy::ref_as_ptr` lint
      rust: binder: enable `clippy::as_underscore`
      rust: binder: enable `clippy::cast_lossless`

 drivers/android/binder/allocation.rs       |  4 ++--
 drivers/android/binder/defs.rs             |  8 +++++---
 drivers/android/binder/freeze.rs           |  2 +-
 drivers/android/binder/node.rs             | 14 ++++++++------
 drivers/android/binder/node/wrapper.rs     |  2 +-
 drivers/android/binder/page_range.rs       |  8 ++++----
 drivers/android/binder/process.rs          | 14 +++++++-------
 drivers/android/binder/rust_binder_main.rs | 10 ++--------
 drivers/android/binder/thread.rs           | 24 +++++++++++++-----------
 drivers/android/binder/trace.rs            |  4 +++-
 drivers/android/binder/transaction.rs      | 14 ++++++++------
 11 files changed, 54 insertions(+), 50 deletions(-)
---
base-commit: fc1ce3afa2e61b4b15e71436ece91b0441a9f4f0
change-id: 20260522-binder-strict-provenance-077c5eddc943

Best regards,
--  
Tamir Duberstein <tamird@kernel.org>

Re: [PATCH v2 0/5] rust: binder: reduce `as` casts
Posted by Alice Ryhl 5 hours ago
On Tue, May 26, 2026 at 8:39 PM Tamir Duberstein <tamird@kernel.org> wrote:
>
> Follow up on the treewide Clippy lint series [1]. The Rust Binder driver
> retains local allows for `clippy::ptr_as_ptr`, `clippy::ref_as_ptr`,
> `clippy::as_underscore`, and `clippy::cast_lossless` even though those
> lints are enabled for the rest of the kernel.
>
> Fix the Binder violations and remove those allows one lint at a time.
> The first patch replaces Binder pointer-to-integer conversions with
> calls to the strict provenance APIs now that they are available at the
> Rust MSRV.
>
> Link: https://lore.kernel.org/r/20250615-ptr-as-ptr-v12-0-f43b024581e8@gmail.com [1]
>
> Signed-off-by: Tamir Duberstein <tamird@kernel.org>

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