From nobody Sun May 24 19:34:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 CE4FC47DD42; Fri, 22 May 2026 17:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469983; cv=none; b=VN2YB0LqgL8piLlM3K5IGGFaka8UH90bgNcKASpbpfYxWpJfUaYpGlZm0VWT7Jf5XwCeksA0csu6uKpzAgevBFNUf8YNie6p/YdRKxa5W4vqL1BhvzGG5CAg33RODNi/jLs3SGKl30Dl5bXXHSDARW33oriRfymn+eCaLDM3s0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469983; c=relaxed/simple; bh=QHPl3FdxSK5t2AimauYdUsFspKALGMrQLr9cwIIAC5Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r/8ubj/sLkN+YoMrnkokDbxIrkxp3eTbrM3UKBIx7cucig4MXT638KOk2AZGGbRF3QzJcbyHkNutSPqq+efqsVMJG2uIufZcd2wRaZfXW6oNlMpj/5XCwiePS/VKvYBO/b3CE0VUxzRs635YqzTRciApt3lklLkXSDVCjYWraUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dKW2hEEJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dKW2hEEJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 778321F00A3F; Fri, 22 May 2026 17:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779469982; bh=KNGi0wIN15aq3Bf92E24Fes1mI/qLY4ql43zmrD3jWI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=dKW2hEEJYcecByMpiN8INKPZPVasOsr8/cwQ2PcZqcmJ2+YdGKVaYAmj4GCHL8Jze SNicTSneN0mH36FGB9MNBpzqOI5+0yUH33LzR4pa20/qAIXKenTIt87WEc2poGja+p Xt/rcEQ/p5ctKh08VCjj2T6Ot9oRsh7+ju1Lvi0MbUElhw8D5F663nQsND3sEMORwk yq1pxEZ+QiSlINnhotfB1hPfJIlnsh5l18cFuWblddtKRAb+GkZK/M/rgPZ8VY4XyN kiasRRY+DnWgwcy0nfoS8mT6f8BkYzeWihBIhPdTgYUPCGpeoZziBn6qLyWTf++zJd 5K9r+C3BXrEtQ== From: Tamir Duberstein Date: Fri, 22 May 2026 19:12:46 +0200 Subject: [PATCH 1/6] rust: binder: use strict provenance APIs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260522-binder-strict-provenance-v1-1-3d6e9406e864@kernel.org> References: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> In-Reply-To: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Alice Ryhl , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1973; i=tamird@kernel.org; h=from:subject:message-id; bh=QHPl3FdxSK5t2AimauYdUsFspKALGMrQLr9cwIIAC5Q=; b=owGbwMvMwCV2wYdPVfy60HTG02pJDFkCfdNy+PeH5S9SvWm90WDOIvXko5qSW/r3zLt1obL/p uJx17vsHRNZGMS4GCzFFFkSRQ/tTU+9vUc2891xmDmsTCBDpEUaGICAhYEvNzGv1EjHSM9U21DP 0EjHQMeYgYtTAKa6eg0jww3Zj9Ouv066WWHLbL00cvuSNWV6z6OWrttZYXLz/4uGzWWMDG1LxK5 EsbUyJDBrPW7IWOV2w4Zh0+9LpvbOm1ZxhySJ8wIA X-Developer-Key: i=tamird@kernel.org; a=openpgp; fpr=5A6714204D41EC844C50273C19D6FF6092365380 Replace the pointer-to-integer conversions in the Binder Rust driver with calls to the strict provenance APIs. The strict provenance APIs were stabilized in Rust 1.84.0 [1]. Since commit f32fb9c58a5b ("rust: bump Rust minimum supported version to 1.85.0 (Debian Trixie)"), the minimum supported Rust version is 1.85.0, so no polyfills are needed. Link: https://blog.rust-lang.org/2025/01/09/Rust-1.84.0.html#strict-provena= nce-apis [1] Signed-off-by: Tamir Duberstein --- drivers/android/binder/node.rs | 2 +- drivers/android/binder/rust_binder_main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs index 69f757ff7461..d710940c3c8f 100644 --- a/drivers/android/binder/node.rs +++ b/drivers/android/binder/node.rs @@ -321,7 +321,7 @@ pub(crate) unsafe fn remove_node_info( /// An id that is unique across all binder nodes on the system. Used a= s the key in the /// `by_node` map. pub(crate) fn global_id(&self) -> usize { - self as *const Node as usize + (self as *const Node).addr() } =20 pub(crate) fn get_id(&self) -> (u64, u64) { diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/b= inder/rust_binder_main.rs index dc1941cd2407..d487638266e3 100644 --- a/drivers/android/binder/rust_binder_main.rs +++ b/drivers/android/binder/rust_binder_main.rs @@ -511,7 +511,7 @@ unsafe impl Sync for AssertSync {} _: *mut kernel::ffi::c_void, ) -> kernel::ffi::c_int { // SAFETY: Accessing the private field of `seq_file` is okay. - let pid =3D (unsafe { (*ptr).private }) as usize as Pid; + let pid =3D unsafe { (*ptr).private }.addr() as Pid; // SAFETY: The caller ensures that the pointer is valid and exclusive = for the duration in which // this method is called. let m =3D unsafe { SeqFile::from_raw(ptr) }; --=20 2.54.0 From nobody Sun May 24 19:34:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 6E80047DF9D; Fri, 22 May 2026 17:13:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469987; cv=none; b=Z86afOB1hlg+w9XkYdPAshZ4NArxp7FNbaX/BwEqjg1alrKAHpEvElhE+AvPhzTQw+dzyBlwmwfMv3KGlTKhCnmMc3MP9QCR6kcwJlVp+jqIBZu2S37nMJWP+uhH7XAw/5rR8TkJCpkA1NiDHofMh3rTNzbqKmc4pJ4CpCip8Xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469987; c=relaxed/simple; bh=Nhy3JJ2+K5iB9IH5eVa3djc247xyKWGSx7pz3YeeHEE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IRWKhtzod1Q/G4zt2WHS9sUVKp15lKqAGe1M9Cem2SrhSVR6ZpsA4u+MWh8NYRwdAX5dnczuUMb3GM3YxQh0llxszofHF0Jk1SarpCr0bfb686pFwX0GbcvaEWjdwV9JomUdHWB8u1ecN+z7qjyI+Y6ZosTgDx/btD0Nm8BKc38= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mjSY2arL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mjSY2arL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDCC81F000E9; Fri, 22 May 2026 17:13:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779469986; bh=du1sgdEdfbbUsPXXtvPNFg4wpVTG1J3WsnClKpPTu5Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=mjSY2arLKdCn4XvqLyEP0YheVm9pFfCcKNgXUe3z0x+br5/PP3qs9Jp484BfkhLdV fOwqqg9JpwRm8ViBV7sgD/q3NIRBrsDA+/55v9Bwzq1V10eHPH8L276B1Fnb/PBVJ/ 2DN/IkLmdzWDM5hJ/Ycd3baXF282IpKWPQn9VpCLrN+XlBQhXcd83WzAY5/vdNYkLc b4Fi7OMlRiaPY3tp0njj8SRe6/XZI7hamlcsy/A+sbeaNMh9v4iIhtSUGLc7QRqMK/ FepE/qGNfQynyUrAD3aTtsw+ETJCEBwqwUcrgfNLubhO45rBdQFUA+XtgZ3S1uZJbU ebCIfQlaSOb/Q== From: Tamir Duberstein Date: Fri, 22 May 2026 19:12:47 +0200 Subject: [PATCH 2/6] rust: binder: transmute transaction data Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260522-binder-strict-provenance-v1-2-3d6e9406e864@kernel.org> References: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> In-Reply-To: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Alice Ryhl , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1155; i=tamird@kernel.org; h=from:subject:message-id; bh=Nhy3JJ2+K5iB9IH5eVa3djc247xyKWGSx7pz3YeeHEE=; b=owGbwMvMwCV2wYdPVfy60HTG02pJDFkCfdMve/2Zv9nWXaYgasu0zyeVgvKYldKX6kkmygpbh h+SulnbMZGFQYyLwVJMkSVR9NDe9NTbe2Qz3x2HmcPKBDJEWqSBAQhYGPhyE/NKjXSM9Ey1DfUM jXQMdIwZuDgFYKqPezD8r85gUla6MMNJ13DhGkbB69Ws09bWzDwYduRBN6th7NI//YwMuxZIinD euxZ1w3ne9ZNuW31OCfJqZ1i6+xU/ffZaYcspBgA= X-Developer-Key: i=tamird@kernel.org; a=openpgp; fpr=5A6714204D41EC844C50273C19D6FF6092365380 `BinderTransactionData` is a transparent wrapper around `binder_transaction_data`. Use a transmute to view the transaction data in `BinderTransactionDataSecctx` through that wrapper, matching the safety argument at the conversion site and avoiding the raw pointer round trip. Signed-off-by: Tamir Duberstein --- drivers/android/binder/defs.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/android/binder/defs.rs b/drivers/android/binder/defs.rs index 33f51b4139c7..fd0ef3f9ebd1 100644 --- a/drivers/android/binder/defs.rs +++ b/drivers/android/binder/defs.rs @@ -164,10 +164,7 @@ impl BinderTransactionDataSecctx { /// View the inner data as wrapped in `BinderTransactionData`. pub(crate) fn tr_data(&mut self) -> &mut BinderTransactionData { // SAFETY: Transparent wrapper is safe to transmute. - unsafe { - &mut *(&mut self.transaction_data as *mut uapi::binder_transac= tion_data - as *mut BinderTransactionData) - } + unsafe { core::mem::transmute(&mut self.transaction_data) } } } =20 --=20 2.54.0 From nobody Sun May 24 19:34:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 1D30B47D94A; Fri, 22 May 2026 17:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469991; cv=none; b=HcIV7jr9GNqvB7UeUUTqD8sgalq1pXOSHjSVuaAcKYRbbihHbvDuVpvjSOx+q5p3MQTJF0fT8Rle3QoG+6ZgwmgLLjdA8hgEx9rOuKsgbg/pbDmvNmw2YKzSogq6lfrNSWKbn8ZJ75UVwr5IUFVEfjIh2PwAOb7CCo6YQp02Uds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469991; c=relaxed/simple; bh=lsyeDqYSyaT5bG8s0HcH1cJvBeqvRiaZFyFUfLKGcEU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MKyNYH6id2642G+DoqYKT6eGhmZHjlxZ9F37tb6JgJa9RSyl2TQ8MlgD0ERQzimMf9hukiulO+Ru6rn/S1z+IFbM/jVIVMzdjs8gzsSiZBqUcDWsfhx+QL97RnsmCwKnmIj1hizQat3xJbcGZco35IN2AhHj1sMEhge9aE08epQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UXY86dA+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UXY86dA+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDFB31F00A3D; Fri, 22 May 2026 17:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779469989; bh=c8oUAd0hKy3lN8xx7yxBMID+XbMnJ0Ef4G0D6URmye0=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=UXY86dA+j+W9A5+pmqFTUqkXGDLBJd2dsQLT66tB3nZhUq2Ey9wYu3kQQuhBnOxqI 4jyCr6DxewJPzjz+nJh0QIHw2jigckyWTZBGVeZMKDXzStVJtJg+3SBEoNjJBsgpHm 1n3V/mRbVY2ZGHQ0BZQXC0tMd3Fpo+Y1VN8KAWcExcC8jTlBRr/oK6tyPyp6zKijXF KA/OKktJ3lwJ99PkjRRZHSlEV5MsdG4XntIVpSq2lskB9ZPdlr2XVyaL8Vo1TqD1Br yNchQH8Q+ZSR4YLxdbeAEtFfHAoVqzhhAqFd8327qvmKIY3VneHSSqRFA1XHo0TSY4 DT3FJPkGCworQ== From: Tamir Duberstein Date: Fri, 22 May 2026 19:12:48 +0200 Subject: [PATCH 3/6] rust: binder: enable `clippy::ptr_as_ptr` lint Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260522-binder-strict-provenance-v1-3-3d6e9406e864@kernel.org> References: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> In-Reply-To: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Alice Ryhl , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3183; i=tamird@kernel.org; h=from:subject:message-id; bh=lsyeDqYSyaT5bG8s0HcH1cJvBeqvRiaZFyFUfLKGcEU=; b=owGbwMvMwCV2wYdPVfy60HTG02pJDFkCfdPv3ls1zbP2u52UWcfiPa6sTVfsnn9e8Uc/IjDt8 NnejTbRHRNZGMS4GCzFFFkSRQ/tTU+9vUc2891xmDmsTCBDpEUaGICAhYEvNzGv1EjHSM9U21DP 0EjHQMeYgYtTAKbacwHD/8qPLWqfJk/czssu5vz+nGGuY9kSr6Ak2UNv1edeOb3zUjXDX9mp7Nt 9fs3kO/Kt2s2vtqVj1fusU5tV32kvufF3muXdQgYA X-Developer-Key: i=tamird@kernel.org; a=openpgp; fpr=5A6714204D41EC844C50273C19D6FF6092365380 In Rust 1.51.0, Clippy introduced the `ptr_as_ptr` lint [1]: > Though `as` casts between raw pointers are not terrible, > `pointer::cast` is safer because it cannot accidentally change pointer > mutability or cast the pointer to other types like `usize`. Apply the required changes and enable the lint in the Binder Rust driver -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr = [1] Signed-off-by: Tamir Duberstein --- drivers/android/binder/page_range.rs | 6 +++--- drivers/android/binder/rust_binder_main.rs | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/android/binder/page_range.rs b/drivers/android/binder/= page_range.rs index e54a90e62402..927b0802e80d 100644 --- a/drivers/android/binder/page_range.rs +++ b/drivers/android/binder/page_range.rs @@ -571,7 +571,7 @@ pub(crate) unsafe fn read(&self, offset: = usize) -> Result { unsafe { self.iterate(offset, size_of::(), |page, offset, to_copy| { // SAFETY: The sum of `offset` and `to_copy` is bounded by= the size of T. - let obj_ptr =3D (out.as_mut_ptr() as *mut u8).add(out_offs= et); + let obj_ptr =3D out.as_mut_ptr().cast::().add(out_offs= et); // SAFETY: The pointer points is in-bounds of the `out` va= riable, so it is valid. page.read_raw(obj_ptr, offset, to_copy)?; out_offset +=3D to_copy; @@ -593,7 +593,7 @@ pub(crate) unsafe fn write(&self, offset: us= ize, obj: &T) -> Result { unsafe { self.iterate(offset, size_of_val(obj), |page, offset, to_copy|= { // SAFETY: The sum of `offset` and `to_copy` is bounded by= the size of T. - let obj_ptr =3D (obj as *const T as *const u8).add(obj_off= set); + let obj_ptr =3D (obj as *const T).cast::().add(obj_off= set); // SAFETY: We have a reference to the object, so the point= er is valid. page.write_raw(obj_ptr, offset, to_copy)?; obj_offset +=3D to_copy; @@ -712,7 +712,7 @@ fn drop(self: Pin<&mut Self>) { =20 { // CAST: The `list_head` field is first in `PageInfo`. - let info =3D item as *mut PageInfo; + let info =3D item.cast::(); // SAFETY: The `range` field of `PageInfo` is immutable. range_ptr =3D unsafe { (*info).range }; // SAFETY: The `range` outlives its `PageInfo` values. diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/b= inder/rust_binder_main.rs index d487638266e3..fa28697982d3 100644 --- a/drivers/android/binder/rust_binder_main.rs +++ b/drivers/android/binder/rust_binder_main.rs @@ -6,12 +6,7 @@ =20 #![crate_name =3D "rust_binder"] #![recursion_limit =3D "256"] -#![allow( - clippy::as_underscore, - clippy::ref_as_ptr, - clippy::ptr_as_ptr, - clippy::cast_lossless -)] +#![allow(clippy::as_underscore, clippy::ref_as_ptr, clippy::cast_lossless)] =20 use kernel::{ bindings::{self, seq_file}, --=20 2.54.0 From nobody Sun May 24 19:34:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4DB39407575; Fri, 22 May 2026 17:13:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469994; cv=none; b=o4YWHSF+jeoCuO+8EA8I/xkArUaa57CB4tA/BDB/BFWFOynlhkcu9ohKhiu0Y8g+omLurtdpaLY7o+zNjbUzu0Eg9ZXH+H7koIk00jIIBKQr5xanvm/MRZ7n5EoBjheJHdKOnbl96+XEDKd4XfeWxldIR+y02asRw+lh1Tn+OU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469994; c=relaxed/simple; bh=zeqj+9t0L5xdRRSqEE/HLdnKiiFyO9hUXW2GPEDwynw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aw56LSDVSvD91SZEuYzi01X3EA/OE4M4GzS5JC7YH/AyVDylbNk3C/XcUkND2cbQSEQmIYfQArrQ/1VROFgRxzFFxKnoOzIOHS1/jSfogVniAzuXDWroKsnW4BP3DMIhdvAMiMv/UnTcEFEDrxqiv5EbxALgD67ELpSvyBiQm5Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FEsSQBwD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FEsSQBwD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30EF71F000E9; Fri, 22 May 2026 17:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779469993; bh=EHxaSfVmkdyCIDw8kkg+n1bEmvVR632xN69mYs8Qnhs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=FEsSQBwDJsl/Cgpn68SUtJIx0lfHeGR1zXp8+tbaj/l09KRYH9DiJvpsVrbnZxZ+t VrkjkCy8ii/nojsOGzYz8VunBz6dpM/hro7zVqhwIhqaVpJQMWCCIFRY5821qJb9qe KxYOJXsGAcdD/hO11iyKLgRktsCSt67LOBjM5zot6CirXDjcu1Ek8MeK6yfnOZ4giC BLLQkmcaKhEyw+KjXYTcIOX6IorGvzN7bz9w1td8DsLiVdxwMM2V3b+sR99NiEDnrV KYVV40YsgLe1NnHRkpTiqYwFY43rH1VInG3MmcJd+P8pqM2pvVK/a8Haoi2M4YlgKV IlYxvhxOHjRfA== From: Tamir Duberstein Date: Fri, 22 May 2026 19:12:49 +0200 Subject: [PATCH 4/6] rust: binder: enable `clippy::ref_as_ptr` lint Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260522-binder-strict-provenance-v1-4-3d6e9406e864@kernel.org> References: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> In-Reply-To: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Alice Ryhl , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3682; i=tamird@kernel.org; h=from:subject:message-id; bh=zeqj+9t0L5xdRRSqEE/HLdnKiiFyO9hUXW2GPEDwynw=; b=owGbwMvMwCV2wYdPVfy60HTG02pJDFkCfdNvqWlkrJ7RuOFCaLaZZdUUBpOdXBr/o1wFY3VEf YzsLcM7JrIwiHExWIopsiSKHtqbnnp7j2zmu+Mwc1iZQIZIizQwAAELA19uYl6pkY6Rnqm2oZ6h kY6BjjEDF6cATPWfd4wMayft4L82IfHGz87v6x8/nTfjr+31U2Z3tiTG+uxati2fgYvhn+2l5ft PMbIuLvna0rdc49ntM77GvoFswc31E71imGbMYQMA X-Developer-Key: i=tamird@kernel.org; a=openpgp; fpr=5A6714204D41EC844C50273C19D6FF6092365380 In Rust 1.78.0, Clippy introduced the `ref_as_ptr` lint [1]: > Using `as` casts may result in silently changing mutability or type. While this does not eliminate unchecked `as` conversions, it makes such conversions easier to scrutinize. It also has the slight benefit of removing a degree of freedom on which to bikeshed. Thus apply the changes and enable the lint in the Binder Rust driver -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#ref_as_ptr = [1] Signed-off-by: Tamir Duberstein --- drivers/android/binder/node.rs | 2 +- drivers/android/binder/page_range.rs | 4 ++-- drivers/android/binder/rust_binder_main.rs | 2 +- drivers/android/binder/trace.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs index d710940c3c8f..a4a3ddda6ac9 100644 --- a/drivers/android/binder/node.rs +++ b/drivers/android/binder/node.rs @@ -321,7 +321,7 @@ pub(crate) unsafe fn remove_node_info( /// An id that is unique across all binder nodes on the system. Used a= s the key in the /// `by_node` map. pub(crate) fn global_id(&self) -> usize { - (self as *const Node).addr() + core::ptr::from_ref(self).addr() } =20 pub(crate) fn get_id(&self) -> (u64, u64) { diff --git a/drivers/android/binder/page_range.rs b/drivers/android/binder/= page_range.rs index 927b0802e80d..93e79c08b89a 100644 --- a/drivers/android/binder/page_range.rs +++ b/drivers/android/binder/page_range.rs @@ -312,7 +312,7 @@ pub(crate) fn register_with_vma(&self, vma: &virt::VmaN= ew) -> Result { =20 // SAFETY: This just initializes the pages array. unsafe { - let self_ptr =3D self as *const ShrinkablePageRange; + let self_ptr =3D core::ptr::from_ref(self); for i in 0..num_pages { let info =3D pages.as_mut_ptr().add(i); (&raw mut (*info).range).write(self_ptr); @@ -593,7 +593,7 @@ pub(crate) unsafe fn write(&self, offset: us= ize, obj: &T) -> Result { unsafe { self.iterate(offset, size_of_val(obj), |page, offset, to_copy|= { // SAFETY: The sum of `offset` and `to_copy` is bounded by= the size of T. - let obj_ptr =3D (obj as *const T).cast::().add(obj_off= set); + let obj_ptr =3D core::ptr::from_ref(obj).cast::().add(= obj_offset); // SAFETY: We have a reference to the object, so the point= er is valid. page.write_raw(obj_ptr, offset, to_copy)?; obj_offset +=3D to_copy; diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/b= inder/rust_binder_main.rs index fa28697982d3..88da29413e16 100644 --- a/drivers/android/binder/rust_binder_main.rs +++ b/drivers/android/binder/rust_binder_main.rs @@ -6,7 +6,7 @@ =20 #![crate_name =3D "rust_binder"] #![recursion_limit =3D "256"] -#![allow(clippy::as_underscore, clippy::ref_as_ptr, clippy::cast_lossless)] +#![allow(clippy::as_underscore, clippy::cast_lossless)] =20 use kernel::{ bindings::{self, seq_file}, diff --git a/drivers/android/binder/trace.rs b/drivers/android/binder/trace= .rs index 5539672d7285..b6cae57801fc 100644 --- a/drivers/android/binder/trace.rs +++ b/drivers/android/binder/trace.rs @@ -26,7 +26,7 @@ =20 #[inline] fn raw_transaction(t: &Transaction) -> rust_binder_transaction { - t as *const Transaction as rust_binder_transaction + core::ptr::from_ref(t).cast_mut().cast() } =20 #[inline] --=20 2.54.0 From nobody Sun May 24 19:34:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0B71C480331; Fri, 22 May 2026 17:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469998; cv=none; b=qouVzOeU+T1QzW+7szfrlOrvhX/D0/ecHYvn7R9IDG63vbD90skXIFCA2NyWNh2vZdXgLuGCQ9HzfFrv6zDcyxrFcCUl+Ks/LuKGryXk/eKiDdvb1MFkDpYUv2iRFl0d1BlEn1AppjsEiXtI7N6Yg80TNshIllvsqMzHcLWkVQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779469998; c=relaxed/simple; bh=ZABJEDgLiRrJk4lGGLErV+wQXs7IYcWC3GGwG0961z8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s8VL/XXwoki3LwqAXiXEChfVLhu/JL9V84izZA2/cdG183MiT8KS/gZcD+vPmjFJSmFTPM8lyUn3OGm1H4/xPgFTiyBb9p+sznakUr1oXV461Res9rkMc3ynxCPUkF890v1FRGV9/9DULjZtw1lHNCutpaooUWCkgUNmm2eCgh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SxVUg+gt; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SxVUg+gt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D15E1F00A3F; Fri, 22 May 2026 17:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779469996; bh=JuZneZp60TIeiwZglXELuNSz9vuAuig9ocPn9+aAtpU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=SxVUg+gtbGxqNWq/5qvrgfw6LEyx9MXgmAxOffeUav2cq37LGtqSeI3x1KkzqVORp CqlStJt5Fgqh6f/NugR0BrPHQs2WPonqsuvSCPq+onUpgBEBbdBi/W2iL0gm49SzDR fC0Fx98z5SD+iKj1wTmId1aAqEMqRtHQ0UkV4DiawJHP4P3aFP9yKEEvvXL2htHU7w hCIO0aaDofmTW2dYndHa3IJtaFmA0P66SJh2z8zPQxDEJh4AiK/XhEh1g2rSusdEVk t59nSML+YQPcgMYqfEnB4EdRZxwb+mQp5ApgYwva28/deDfaVXiA0crrruodWpHVpP 93IV10vWPaKgw== From: Tamir Duberstein Date: Fri, 22 May 2026 19:12:50 +0200 Subject: [PATCH 5/6] rust: binder: enable `clippy::as_underscore` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260522-binder-strict-provenance-v1-5-3d6e9406e864@kernel.org> References: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> In-Reply-To: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Alice Ryhl , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=13025; i=tamird@kernel.org; h=from:subject:message-id; bh=ZABJEDgLiRrJk4lGGLErV+wQXs7IYcWC3GGwG0961z8=; b=owGbwMvMwCV2wYdPVfy60HTG02pJDFkCfdPDDiwIvqE3N7/z7N3SuWxfFESvTLBLeJtVILvh5 N5VtU76HRNZGMS4GCzFFFkSRQ/tTU+9vUc2891xmDmsTCBDpEUaGICAhYEvNzGv1EjHSM9U21DP 0EjHQMeYgYtTAKa6JJWRoePirYrUSwY1xa9PGMU1XFSY9EI2KDXLwcdF58WWaeWP9jMyXOiTZ7/ ctj6/dfI79da+386c05uMxb1EvrglOy93MPDhAAA= X-Developer-Key: i=tamird@kernel.org; a=openpgp; fpr=5A6714204D41EC844C50273C19D6FF6092365380 In Rust 1.63.0, Clippy introduced the `as_underscore` lint [1]: > The conversion might include lossy conversion or a dangerous cast that > might go undetected due to the type being inferred. > > The lint is allowed by default as using `_` is less wordy than always > specifying the type. Always specifying the type is especially helpful in function call contexts where the inferred type may change at a distance. Specifying the type also allows Clippy to spot more cases of `useless_conversion`. While this does not eliminate unchecked `as` conversions, it makes such conversions easier to scrutinize. It also has the slight benefit of removing a degree of freedom on which to bikeshed. Thus apply the changes and enable the lint in the Binder Rust driver -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_undersco= re [1] Signed-off-by: Tamir Duberstein --- drivers/android/binder/allocation.rs | 4 ++-- drivers/android/binder/defs.rs | 2 +- drivers/android/binder/node.rs | 10 +++++----- drivers/android/binder/node/wrapper.rs | 2 +- drivers/android/binder/process.rs | 6 +++--- drivers/android/binder/rust_binder_main.rs | 4 ++-- drivers/android/binder/thread.rs | 24 +++++++++++++----------- drivers/android/binder/transaction.rs | 12 ++++++------ 8 files changed, 33 insertions(+), 31 deletions(-) diff --git a/drivers/android/binder/allocation.rs b/drivers/android/binder/= allocation.rs index 0cab959e4b7e..4ac42bb7216b 100644 --- a/drivers/android/binder/allocation.rs +++ b/drivers/android/binder/allocation.rs @@ -376,8 +376,8 @@ pub(crate) fn transfer_binder_object( BINDER_TYPE_WEAK_BINDER }; newobj.flags =3D obj.flags; - newobj.__bindgen_anon_1.binder =3D ptr as _; - newobj.cookie =3D cookie as _; + newobj.__bindgen_anon_1.binder =3D ptr; + newobj.cookie =3D cookie; self.write(offset, &newobj)?; // Increment the user ref count on the node. It will be decrem= ented as part of the // destruction of the buffer, when we see a binder or weak-bin= der object. diff --git a/drivers/android/binder/defs.rs b/drivers/android/binder/defs.rs index fd0ef3f9ebd1..a9682eb6d984 100644 --- a/drivers/android/binder/defs.rs +++ b/drivers/android/binder/defs.rs @@ -146,7 +146,7 @@ fn default() -> Self { impl BinderVersion { pub(crate) fn current() -> Self { Self(MaybeUninit::new(uapi::binder_version { - protocol_version: BINDER_CURRENT_PROTOCOL_VERSION as _, + protocol_version: BINDER_CURRENT_PROTOCOL_VERSION as i32, })) } } diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs index a4a3ddda6ac9..8f5307c03b1a 100644 --- a/drivers/android/binder/node.rs +++ b/drivers/android/binder/node.rs @@ -464,7 +464,7 @@ pub(crate) fn incr_refcount_allow_zero2one_with_wrapper( owner_inner: &mut ProcessInner, ) -> Option> { match self.incr_refcount_allow_zero2one(strong, owner_inner) { - Ok(Some(node)) =3D> Some(node as _), + Ok(Some(node)) =3D> Some(node as DLArc), Ok(None) =3D> None, Err(CouldNotDeliverCriticalIncrement) =3D> { assert!(strong); @@ -489,8 +489,8 @@ pub(crate) fn populate_counts( guard: &Guard<'_, ProcessInner, SpinLockBackend>, ) { let inner =3D self.inner.access(guard); - out.strong_count =3D inner.strong.count as _; - out.weak_count =3D inner.weak.count as _; + out.strong_count =3D inner.strong.count as u32; + out.weak_count =3D inner.weak.count as u32; } =20 pub(crate) fn populate_debug_info( @@ -498,8 +498,8 @@ pub(crate) fn populate_debug_info( out: &mut BinderNodeDebugInfo, guard: &Guard<'_, ProcessInner, SpinLockBackend>, ) { - out.ptr =3D self.ptr as _; - out.cookie =3D self.cookie as _; + out.ptr =3D self.ptr; + out.cookie =3D self.cookie; let inner =3D self.inner.access(guard); if inner.strong.has_count { out.has_strong_ref =3D 1; diff --git a/drivers/android/binder/node/wrapper.rs b/drivers/android/binde= r/node/wrapper.rs index 43294c050502..6e4ca01c941a 100644 --- a/drivers/android/binder/node/wrapper.rs +++ b/drivers/android/binder/node/wrapper.rs @@ -21,7 +21,7 @@ pub(crate) fn new() -> Result { =20 pub(super) fn init(self, node: DArc) -> DLArc= { match self.inner.pin_init_with(DTRWrap::new(NodeWrapper { node }))= { - Ok(initialized) =3D> ListArc::from(initialized) as _, + Ok(initialized) =3D> ListArc::from(initialized) as DLArc, Err(err) =3D> match err {}, } } diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/pro= cess.rs index 820cbd541435..3a22260eb9b4 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -259,7 +259,7 @@ pub(crate) fn new_node_ref_with_thread( let push =3D match wrapper { None =3D> node .incr_refcount_allow_zero2one(strong, self)? - .map(|node| node as _), + .map(|node| node as DLArc), Some(wrapper) =3D> node.incr_refcount_allow_zero2one_with_wrap= per(strong, wrapper, self), }; if let Some(node) =3D push { @@ -741,7 +741,7 @@ fn set_as_manager( } else { (0, 0, 0) }; - let node_ref =3D self.get_node(ptr, cookie, flags as _, true, thre= ad)?; + let node_ref =3D self.get_node(ptr, cookie, flags, true, thread)?; let node =3D node_ref.node.clone(); self.ctx.set_manager_node(node_ref)?; self.inner.lock().is_manager =3D true; @@ -1517,7 +1517,7 @@ fn get_frozen_status(data: UserSlice) -> Result { =20 for ctx in crate::context::get_all_contexts()? { ctx.for_each_proc(|proc| { - if proc.task.pid() =3D=3D info.pid as _ { + if proc.task.pid() =3D=3D info.pid as i32 { found =3D true; let inner =3D proc.inner.lock(); let txns_pending =3D inner.txns_pending_locked(); diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/b= inder/rust_binder_main.rs index 88da29413e16..2c10a8cd3d88 100644 --- a/drivers/android/binder/rust_binder_main.rs +++ b/drivers/android/binder/rust_binder_main.rs @@ -6,7 +6,7 @@ =20 #![crate_name =3D "rust_binder"] #![recursion_limit =3D "256"] -#![allow(clippy::as_underscore, clippy::cast_lossless)] +#![allow(clippy::cast_lossless)] =20 use kernel::{ bindings::{self, seq_file}, @@ -412,7 +412,7 @@ unsafe impl Sync for AssertSync {} // SAFETY: We previously set `private_data` in `rust_binder_open`. let f =3D unsafe { Arc::::borrow((*file).private_data) }; // SAFETY: The caller ensures that the file is valid. - match Process::ioctl(f, unsafe { File::from_raw_file(file) }, cmd as _= , arg as _) { + match Process::ioctl(f, unsafe { File::from_raw_file(file) }, cmd, arg= ) { Ok(()) =3D> 0, Err(err) =3D> err.to_errno() as isize, } diff --git a/drivers/android/binder/thread.rs b/drivers/android/binder/thre= ad.rs index 97d5f31e8fe3..87298a8c597d 100644 --- a/drivers/android/binder/thread.rs +++ b/drivers/android/binder/thread.rs @@ -666,9 +666,9 @@ fn translate_object( let strong =3D obj.hdr.type_ =3D=3D BINDER_TYPE_BINDER; // SAFETY: `binder` is a `binder_uintptr_t`; any bit patte= rn is a valid // representation. - let ptr =3D unsafe { obj.__bindgen_anon_1.binder } as _; - let cookie =3D obj.cookie as _; - let flags =3D obj.flags as _; + let ptr =3D unsafe { obj.__bindgen_anon_1.binder }; + let cookie =3D obj.cookie; + let flags =3D obj.flags; let node =3D self .process .as_arc_borrow() @@ -679,7 +679,7 @@ fn translate_object( BinderObjectRef::Handle(obj) =3D> { let strong =3D obj.hdr.type_ =3D=3D BINDER_TYPE_HANDLE; // SAFETY: `handle` is a `u32`; any bit pattern is a valid= representation. - let handle =3D unsafe { obj.__bindgen_anon_1.handle } as _; + let handle =3D unsafe { obj.__bindgen_anon_1.handle }; let node =3D self.process.get_node_from_handle(handle, str= ong)?; security::binder_transfer_binder(&self.process.cred, &view= .alloc.process.cred)?; view.transfer_binder_object(offset, obj, strong, node)?; @@ -736,7 +736,7 @@ fn translate_object( ScatterGatherEntry { obj_index, offset: alloc_offset, - sender_uaddr: obj.buffer as _, + sender_uaddr: obj.buffer as usize, length: obj_length, pointer_fixups: KVec::new(), fixup_min_offset: 0, @@ -843,7 +843,7 @@ fn translate_object( .ok_or(EINVAL)?; =20 let mut fda_bytes =3D KVec::new(); - UserSlice::new(UserPtr::from_addr(fda_uaddr as _), fds_len) + UserSlice::new(UserPtr::from_addr(fda_uaddr as usize), fds= _len) .read_all(&mut fda_bytes, GFP_KERNEL)?; =20 if fds_len !=3D fda_bytes.len() { @@ -1365,7 +1365,7 @@ fn write(self: &Arc, req: &mut BinderWriteRead)= -> Result { let write_start =3D req.write_buffer.wrapping_add(req.write_consum= ed); let write_len =3D req.write_size.saturating_sub(req.write_consumed= ); let mut reader =3D - UserSlice::new(UserPtr::from_addr(write_start as _), write_len= as _).reader(); + UserSlice::new(UserPtr::from_addr(write_start as usize), write= _len as usize).reader(); =20 while reader.len() >=3D size_of::() && self.inner.lock().retu= rn_work.is_unused() { let before =3D reader.len(); @@ -1436,7 +1436,7 @@ fn read(self: &Arc, req: &mut BinderWriteRead, = wait: bool) -> Result { let read_start =3D req.read_buffer.wrapping_add(req.read_consumed); let read_len =3D req.read_size.saturating_sub(req.read_consumed); let mut writer =3D BinderReturnWriter::new( - UserSlice::new(UserPtr::from_addr(read_start as _), read_len a= s _).writer(), + UserSlice::new(UserPtr::from_addr(read_start as usize), read_l= en as usize).writer(), self, ); let (in_pool, has_transaction, thread_todo, use_proc_queue) =3D { @@ -1500,9 +1500,11 @@ fn read(self: &Arc, req: &mut BinderWriteRead,= wait: bool) -> Result { =20 // Write BR_SPAWN_LOOPER if the process needs more threads for its= pool. if has_noop_placeholder && in_pool && self.process.needs_thread() { - let mut writer =3D - UserSlice::new(UserPtr::from_addr(req.read_buffer as _), r= eq.read_size as _) - .writer(); + let mut writer =3D UserSlice::new( + UserPtr::from_addr(req.read_buffer as usize), + req.read_size as usize, + ) + .writer(); writer.write(&BR_SPAWN_LOOPER)?; } Ok(()) diff --git a/drivers/android/binder/transaction.rs b/drivers/android/binder= /transaction.rs index 47d5e4d88b07..6edd19461785 100644 --- a/drivers/android/binder/transaction.rs +++ b/drivers/android/binder/transaction.rs @@ -402,16 +402,16 @@ fn do_work( let tr =3D tr_sec.tr_data(); if let Some(target_node) =3D &self.target_node { let (ptr, cookie) =3D target_node.get_id(); - tr.target.ptr =3D ptr as _; - tr.cookie =3D cookie as _; + tr.target.ptr =3D ptr; + tr.cookie =3D cookie; }; tr.code =3D self.code; tr.flags =3D self.flags; - tr.data_size =3D self.data_size as _; - tr.data.ptr.buffer =3D self.data_address as _; - tr.offsets_size =3D self.offsets_size as _; + tr.data_size =3D self.data_size as u64; + tr.data.ptr.buffer =3D self.data_address as u64; + tr.offsets_size =3D self.offsets_size as u64; if tr.offsets_size > 0 { - tr.data.ptr.offsets =3D (self.data_address + ptr_align(self.da= ta_size).unwrap()) as _; + tr.data.ptr.offsets =3D (self.data_address + ptr_align(self.da= ta_size).unwrap()) as u64; } tr.sender_euid =3D self.sender_euid.into_uid_in_current_ns(); tr.sender_pid =3D 0; --=20 2.54.0 From nobody Sun May 24 19:34:48 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5460847DD7C; Fri, 22 May 2026 17:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779470001; cv=none; b=gOqPPkc3FqCvYEZ21eHJ2v9T5tyNWaX7KfRIh8+MLKkeRtZGhOR0DBFp/UxHpOKkpEkhJ70rq8E+Jkg6+ju4OAk9dUgQCfBA13qf78u/MK8/fFrXVQ1KGRJngh372LWMoKSsfZRp6XgHzRhuPUe+5Mn8PCmwPazZ1abcF6L1U98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779470001; c=relaxed/simple; bh=tZVFcJ0SDOSpha47vLT8wPnQbq4+EpWGnED1uar/t70=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W6msee9N/FLKo0UmjYumDERiFGpW7lhXU76RjZUVLMAo4j4/DG2qEsM81Bj3yhDdddz9vedwt0yjjs8D2z7x8TPEvDpsNw1LAW1AnXqoQrPxyZXCpzqNueSIcNdu49fz+XreAZWo1qhOucEF5oWSomdSYSdwqf5o8Mlz+NTLcto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IneIh/eR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IneIh/eR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1613F1F000E9; Fri, 22 May 2026 17:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779470000; bh=17FQYeo9EnNLOAsRTJ8Zra7Gt9u+o1SjdNCJpNuLEaA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=IneIh/eRTaZmumwyglUXJKF0MCSkAb/6/pWgx5XKgy64qZoVwJ56oH9bYUhxlOeCQ YJ9yOk6bY6zveSEoUDjh99BjhTfOFk7fA08ax+kEK3dlhcKrCkPE2GAlY8d2eG3YUw iGpLLyrvnrGR7hFXQRrGuqP6Ohp/Gdaf2hguvYR2TY41JHCMi1nPGDh8MElwCYL6m/ ohN/l34Q6UpFGpgl+JyWGKrCTKf/AoZy0Y2dJ+DCHtpu9kmHgFILInLRcXEhNm0lUf 8jxPZK2SPA56NIreKKVhj+7CmKtt7Gp0meeSgxoZ4PhRRX+9r2JtbEWCimkDjAIDv7 Yb4xpdghf7gEA== From: Tamir Duberstein Date: Fri, 22 May 2026 19:12:51 +0200 Subject: [PATCH 6/6] rust: binder: enable `clippy::cast_lossless` Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260522-binder-strict-provenance-v1-6-3d6e9406e864@kernel.org> References: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> In-Reply-To: <20260522-binder-strict-provenance-v1-0-3d6e9406e864@kernel.org> To: Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Alice Ryhl , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2977; i=tamird@kernel.org; h=from:subject:message-id; bh=tZVFcJ0SDOSpha47vLT8wPnQbq4+EpWGnED1uar/t70=; b=owGbwMvMwCV2wYdPVfy60HTG02pJDFkCfdNT5j763nvJNHjR6mpDO6WpOUm9or1r3zSUfF1Tc /4Cq3lix0QWBjEuBksxRZZE0UN701Nv75HNfHccZg4rE8gQaZEGBiBgYeDLTcwrNdIx0jPVNtQz NNIx0DFm4OIUgKn22crwz9bgvOZ0OfvlVmK9CZvEGm9aiYfIvtU47yCyjuNNiEthKcM/jYuL627 yPph0szzq7AvW1ZHPv1m2bP+/+RiHj7ua4O7NzAA= X-Developer-Key: i=tamird@kernel.org; a=openpgp; fpr=5A6714204D41EC844C50273C19D6FF6092365380 Before Rust 1.29.0, Clippy introduced the `cast_lossless` lint [1]: > Rust's `as` keyword will perform many kinds of conversions, including > silently lossy conversions. Conversion functions such as `i32::from` > will only perform lossless conversions. Using the conversion functions > prevents conversions from becoming silently lossy if the input types > ever change, and makes it clear for people reading the code that the > conversion is lossless. While this does not eliminate unchecked `as` conversions, it makes such conversions easier to scrutinize. It also has the slight benefit of removing a degree of freedom on which to bikeshed. Thus apply the changes and enable the lint in the Binder Rust driver -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossle= ss [1] Signed-off-by: Tamir Duberstein --- drivers/android/binder/freeze.rs | 2 +- drivers/android/binder/process.rs | 6 +++--- drivers/android/binder/rust_binder_main.rs | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/android/binder/freeze.rs b/drivers/android/binder/free= ze.rs index 53b60035639a..2178258772e5 100644 --- a/drivers/android/binder/freeze.rs +++ b/drivers/android/binder/freeze.rs @@ -127,7 +127,7 @@ fn do_work( } =20 let mut state_info =3D BinderFrozenStateInfo::default(); - state_info.is_frozen =3D is_frozen as u32; + state_info.is_frozen =3D u32::from(is_frozen); state_info.cookie =3D freeze.cookie.0; freeze.is_pending =3D true; freeze.last_is_frozen =3D Some(is_frozen); diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/pro= cess.rs index 3a22260eb9b4..fc69826d4be6 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -1521,9 +1521,9 @@ fn get_frozen_status(data: UserSlice) -> Result { found =3D true; let inner =3D proc.inner.lock(); let txns_pending =3D inner.txns_pending_locked(); - info.async_recv |=3D inner.async_recv as u32; - info.sync_recv |=3D inner.sync_recv as u32; - info.sync_recv |=3D (txns_pending as u32) << 1; + info.async_recv |=3D u32::from(inner.async_recv); + info.sync_recv |=3D u32::from(inner.sync_recv); + info.sync_recv |=3D u32::from(txns_pending) << 1; } }); } diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/b= inder/rust_binder_main.rs index 2c10a8cd3d88..432390aab25b 100644 --- a/drivers/android/binder/rust_binder_main.rs +++ b/drivers/android/binder/rust_binder_main.rs @@ -6,7 +6,6 @@ =20 #![crate_name =3D "rust_binder"] #![recursion_limit =3D "256"] -#![allow(clippy::cast_lossless)] =20 use kernel::{ bindings::{self, seq_file}, --=20 2.54.0