rust_binder: use compat_ptr_ioctl
Subsystems (2)
Alice Ryhl
maintainerPATCH v2 1/1 rust_binder: use compat_ptr_ioctl
Binder always treats the ioctl argument as a pointer. In this scenario, the idiomatic way to implement compat_ioctl is to use compat_ptr_ioctl. Thus update Rust Binder to do that.
Signed-off-by Alice Ryhl <[email protected]>
---
Changes in v2:
- Reword commit message.
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/android/binder/process.rs | 9 --------- drivers/android/binder/rust_binder_main.rs | 22 +++------------------- 2 files changed, 3 insertions(+), 28 deletions(-)
drivers/android/binder/process.rs +0 -9
@@ -1599,15 +1599,6 @@ pub(crate) fn ioctl(this: ArcBorrow<'_, Process>, file: &File, cmd: u32, arg: us } } -pub (crate )fn compat_ioctl ( - this:ArcBorrow <'_,Process >, - file: &File , - cmd:u32 , - arg:usize , - ) ->Result { -Self ::ioctl (this, file, cmd, arg) - } -pub (crate )fn mmap ( this:ArcBorrow <'_,Process >, _file: &File,
drivers/android/binder/rust_binder_main.rs +3 -19
@@ -313,8 +313,8 @@ unsafe impl<T> Sync for AssertSync<T> {}let ops = kernel::bindings::file_operations { owner:THIS_MODULE .as_ptr (), poll:Some (rust_binder_poll), - unlocked_ioctl:Some (rust_binder_unlocked_ioctl), - compat_ioctl:Some (rust_binder_compat_ioctl), + unlocked_ioctl:Some (rust_binder_ioctl), + compat_ioctl:Some (bindings::compat_ptr_ioctl), mmap:Some (rust_binder_mmap), open:Some (rust_binder_open), release:Some (rust_binder_release),
@@ -402,23 +402,7 @@ unsafe impl<T> Sync for AssertSync<T> {}/// # Safety /// Only called by binderfs. -unsafe extern "C" fn rust_binder_compat_ioctl ( - file: *mut bindings::file , - cmd: kernel::ffi::c_uint , - arg: kernel::ffi::c_ulong , -) -> kernel::ffi::c_long { -// SAFETY: We previously set `private_data` in `rust_binder_open`. -let f =unsafe {Arc ::<Process >::borrow ((*file).private_data) }; -// SAFETY: The caller ensures that the file is valid. -match Process ::compat_ioctl (f,unsafe {File ::from_raw_file (file) }, cmdas _ , argas _ ) { -Ok (()) =>0 , -Err (err) => err.to_errno ()as isize , - } -} - -/// # Safety -/// Only called by binderfs. -unsafe extern "C" fn rust_binder_unlocked_ioctl ( +unsafe extern "C" fn rust_binder_ioctl ( file: *mut bindings::file , cmd: kernel::ffi::c_uint , arg: kernel::ffi::c_ulong,
---
base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
change-id: 20251030-binder-compatptrioctl-ecc9e2131edb
Best regards,
Signature · 1 line
Alice Ryhl <[email protected]>
Quoted 6 lines · Alice Ryhl
Binder always treats the ioctl argument as a pointer. In this scenario, the idiomatic way to implement
compat_ioctlis to usecompat_ptr_ioctl. Thus update Rust Binder to do that.Signed-off-by Alice Ryhl <[email protected]>---
LGTM,
Acked-by Carlos Llamas <[email protected]>