Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Alice Ryhl and committed by
Greg Kroah-Hartman
d4b83ba1 a1fb84ab

+3 -28
-9
drivers/android/binder/process.rs
··· 1623 1623 } 1624 1624 } 1625 1625 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 - 1635 1626 pub(crate) fn mmap( 1636 1627 this: ArcBorrow<'_, Process>, 1637 1628 _file: &File,
+3 -19
drivers/android/binder/rust_binder_main.rs
··· 313 313 let ops = kernel::bindings::file_operations { 314 314 owner: THIS_MODULE.as_ptr(), 315 315 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), 318 318 mmap: Some(rust_binder_mmap), 319 319 open: Some(rust_binder_open), 320 320 release: Some(rust_binder_release), ··· 402 402 403 403 /// # Safety 404 404 /// 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( 422 406 file: *mut bindings::file, 423 407 cmd: kernel::ffi::c_uint, 424 408 arg: kernel::ffi::c_ulong,