Skip to content

Commit d4b83ba

Browse files
Darksonngregkh
authored andcommitted
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 <aliceryhl@google.com> Acked-by: Carlos Llamas <cmllamas@google.com> Link: https://patch.msgid.link/20251031-binder-compatptrioctl-v2-1-3d05b5cc058e@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a1fb84a commit d4b83ba

2 files changed

Lines changed: 3 additions & 28 deletions

File tree

drivers/android/binder/process.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,15 +1623,6 @@ impl Process {
16231623
}
16241624
}
16251625

1626-
pub(crate) fn compat_ioctl(
1627-
this: ArcBorrow<'_, Process>,
1628-
file: &File,
1629-
cmd: u32,
1630-
arg: usize,
1631-
) -> Result {
1632-
Self::ioctl(this, file, cmd, arg)
1633-
}
1634-
16351626
pub(crate) fn mmap(
16361627
this: ArcBorrow<'_, Process>,
16371628
_file: &File,

drivers/android/binder/rust_binder_main.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ pub static rust_binder_fops: AssertSync<kernel::bindings::file_operations> = {
313313
let ops = kernel::bindings::file_operations {
314314
owner: THIS_MODULE.as_ptr(),
315315
poll: Some(rust_binder_poll),
316-
unlocked_ioctl: Some(rust_binder_unlocked_ioctl),
317-
compat_ioctl: Some(rust_binder_compat_ioctl),
316+
unlocked_ioctl: Some(rust_binder_ioctl),
317+
compat_ioctl: Some(bindings::compat_ptr_ioctl),
318318
mmap: Some(rust_binder_mmap),
319319
open: Some(rust_binder_open),
320320
release: Some(rust_binder_release),
@@ -402,23 +402,7 @@ unsafe extern "C" fn rust_binder_release(
402402

403403
/// # Safety
404404
/// Only called by binderfs.
405-
unsafe extern "C" fn rust_binder_compat_ioctl(
406-
file: *mut bindings::file,
407-
cmd: kernel::ffi::c_uint,
408-
arg: kernel::ffi::c_ulong,
409-
) -> kernel::ffi::c_long {
410-
// SAFETY: We previously set `private_data` in `rust_binder_open`.
411-
let f = unsafe { Arc::<Process>::borrow((*file).private_data) };
412-
// SAFETY: The caller ensures that the file is valid.
413-
match Process::compat_ioctl(f, unsafe { File::from_raw_file(file) }, cmd as _, arg as _) {
414-
Ok(()) => 0,
415-
Err(err) => err.to_errno() as isize,
416-
}
417-
}
418-
419-
/// # Safety
420-
/// Only called by binderfs.
421-
unsafe extern "C" fn rust_binder_unlocked_ioctl(
405+
unsafe extern "C" fn rust_binder_ioctl(
422406
file: *mut bindings::file,
423407
cmd: kernel::ffi::c_uint,
424408
arg: kernel::ffi::c_ulong,

0 commit comments

Comments
 (0)