summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-07-06 14:54:21 +0100
committerMark Brown <broonie@kernel.org>2026-07-06 14:54:21 +0100
commit403060170a44f6024db217c6af71cbe5605b1c8a (patch)
tree5de9b24f8420a5ae60254f5e25590e593d1fa426
parent4978a7cd0398e5b11b946a2bad8ca60de61cbf0e (diff)
parent9e32d2a9784736b3fc262f51ddda1141de753314 (diff)
downloadlinux-next-403060170a44f6024db217c6af71cbe5605b1c8a.tar.gz
linux-next-403060170a44f6024db217c6af71cbe5605b1c8a.zip
Merge branch 'char-misc-next' of https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
-rw-r--r--drivers/android/binder/allocation.rs4
-rw-r--r--drivers/android/binder/defs.rs8
-rw-r--r--drivers/android/binder/freeze.rs2
-rw-r--r--drivers/android/binder/node.rs14
-rw-r--r--drivers/android/binder/node/wrapper.rs2
-rw-r--r--drivers/android/binder/page_range.rs8
-rw-r--r--drivers/android/binder/process.rs14
-rw-r--r--drivers/android/binder/rust_binder_main.rs10
-rw-r--r--drivers/android/binder/thread.rs24
-rw-r--r--drivers/android/binder/trace.rs4
-rw-r--r--drivers/android/binder/transaction.rs14
11 files changed, 54 insertions, 50 deletions
diff --git a/drivers/android/binder/allocation.rs b/drivers/android/binder/allocation.rs
index ea5846e4da16..165cb797eb1e 100644
--- a/drivers/android/binder/allocation.rs
+++ b/drivers/android/binder/allocation.rs
@@ -384,8 +384,8 @@ impl<'a> AllocationView<'a> {
BINDER_TYPE_WEAK_BINDER
};
newobj.flags = obj.flags;
- newobj.__bindgen_anon_1.binder = ptr as _;
- newobj.cookie = cookie as _;
+ newobj.__bindgen_anon_1.binder = ptr as uapi::binder_uintptr_t;
+ newobj.cookie = cookie as uapi::binder_uintptr_t;
self.write(offset, &newobj)?;
// Increment the user ref count on the node. It will be decremented as part of the
// destruction of the buffer, when we see a binder or weak-binder object.
diff --git a/drivers/android/binder/defs.rs b/drivers/android/binder/defs.rs
index 33f51b4139c7..8ac9bdd7a499 100644
--- a/drivers/android/binder/defs.rs
+++ b/drivers/android/binder/defs.rs
@@ -4,6 +4,8 @@
use core::mem::MaybeUninit;
use core::ops::{Deref, DerefMut};
+use core::ptr;
+
use kernel::{
transmute::{AsBytes, FromBytes},
uapi::{self, *},
@@ -146,7 +148,7 @@ decl_wrapper!(ExtendedError, uapi::binder_extended_error);
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,
}))
}
}
@@ -165,8 +167,8 @@ impl BinderTransactionDataSecctx {
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_transaction_data
- as *mut BinderTransactionData)
+ &mut *(ptr::from_mut::<uapi::binder_transaction_data>(&mut self.transaction_data)
+ .cast::<BinderTransactionData>())
}
}
}
diff --git a/drivers/android/binder/freeze.rs b/drivers/android/binder/freeze.rs
index f4df14568b25..e0bc159da63d 100644
--- a/drivers/android/binder/freeze.rs
+++ b/drivers/android/binder/freeze.rs
@@ -127,7 +127,7 @@ impl DeliverToRead for FreezeMessage {
}
let mut state_info = BinderFrozenStateInfo::default();
- state_info.is_frozen = is_frozen as u32;
+ state_info.is_frozen = u32::from(is_frozen);
state_info.cookie = freeze.cookie.0;
freeze.is_pending = true;
freeze.last_is_frozen = Some(is_frozen);
diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs
index c10148e9069f..979366276680 100644
--- a/drivers/android/binder/node.rs
+++ b/drivers/android/binder/node.rs
@@ -9,6 +9,7 @@ use kernel::{
seq_print,
sync::lock::{spinlock::SpinLockBackend, Guard},
sync::{Arc, LockedBy, SpinLock},
+ uapi,
};
use crate::{
@@ -21,6 +22,7 @@ use crate::{
};
use core::mem;
+use core::ptr;
mod wrapper;
pub(crate) use self::wrapper::CritIncrWrapper;
@@ -321,7 +323,7 @@ impl Node {
/// An id that is unique across all binder nodes on the system. Used as the key in the
/// `by_node` map.
pub(crate) fn global_id(&self) -> usize {
- self as *const Node as usize
+ ptr::from_ref(self).addr()
}
pub(crate) fn get_id(&self) -> (u64, u64) {
@@ -464,7 +466,7 @@ impl Node {
owner_inner: &mut ProcessInner,
) -> Option<DLArc<dyn DeliverToRead>> {
match self.incr_refcount_allow_zero2one(strong, owner_inner) {
- Ok(Some(node)) => Some(node as _),
+ Ok(Some(node)) => Some(node as DLArc<dyn DeliverToRead>),
Ok(None) => None,
Err(CouldNotDeliverCriticalIncrement) => {
assert!(strong);
@@ -489,8 +491,8 @@ impl Node {
guard: &Guard<'_, ProcessInner, SpinLockBackend>,
) {
let inner = self.inner.access(guard);
- out.strong_count = inner.strong.count as _;
- out.weak_count = inner.weak.count as _;
+ out.strong_count = inner.strong.count as u32;
+ out.weak_count = inner.weak.count as u32;
}
pub(crate) fn populate_debug_info(
@@ -498,8 +500,8 @@ impl Node {
out: &mut BinderNodeDebugInfo,
guard: &Guard<'_, ProcessInner, SpinLockBackend>,
) {
- out.ptr = self.ptr as _;
- out.cookie = self.cookie as _;
+ out.ptr = self.ptr as uapi::binder_uintptr_t;
+ out.cookie = self.cookie as uapi::binder_uintptr_t;
let inner = self.inner.access(guard);
if inner.strong.has_count {
out.has_strong_ref = 1;
diff --git a/drivers/android/binder/node/wrapper.rs b/drivers/android/binder/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 @@ impl CritIncrWrapper {
pub(super) fn init(self, node: DArc<Node>) -> DLArc<dyn DeliverToRead> {
match self.inner.pin_init_with(DTRWrap::new(NodeWrapper { node })) {
- Ok(initialized) => ListArc::from(initialized) as _,
+ Ok(initialized) => ListArc::from(initialized) as DLArc<dyn DeliverToRead>,
Err(err) => match err {},
}
}
diff --git a/drivers/android/binder/page_range.rs b/drivers/android/binder/page_range.rs
index e82a5523804f..52ffbf3504e7 100644
--- a/drivers/android/binder/page_range.rs
+++ b/drivers/android/binder/page_range.rs
@@ -312,7 +312,7 @@ impl ShrinkablePageRange {
// SAFETY: This just initializes the pages array.
unsafe {
- let self_ptr = self as *const ShrinkablePageRange;
+ let self_ptr = ptr::from_ref(self);
for i in 0..num_pages {
let info = pages.as_mut_ptr().add(i);
(&raw mut (*info).range).write(self_ptr);
@@ -571,7 +571,7 @@ impl ShrinkablePageRange {
unsafe {
self.iterate(offset, size_of::<T>(), |page, offset, to_copy| {
// SAFETY: The sum of `offset` and `to_copy` is bounded by the size of T.
- let obj_ptr = (out.as_mut_ptr() as *mut u8).add(out_offset);
+ let obj_ptr = out.as_mut_ptr().cast::<u8>().add(out_offset);
// SAFETY: The pointer points is in-bounds of the `out` variable, so it is valid.
page.read_raw(obj_ptr, offset, to_copy)?;
out_offset += to_copy;
@@ -593,7 +593,7 @@ impl ShrinkablePageRange {
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 = (obj as *const T as *const u8).add(obj_offset);
+ let obj_ptr = ptr::from_ref(obj).cast::<u8>().add(obj_offset);
// SAFETY: We have a reference to the object, so the pointer is valid.
page.write_raw(obj_ptr, offset, to_copy)?;
obj_offset += to_copy;
@@ -712,7 +712,7 @@ unsafe extern "C" fn rust_shrink_free_page(
{
// CAST: The `list_head` field is first in `PageInfo`.
- let info = item as *mut PageInfo;
+ let info = item.cast::<PageInfo>();
// SAFETY: The `range` field of `PageInfo` is immutable.
range_ptr = unsafe { (*info).range };
// SAFETY: The `range` outlives its `PageInfo` values.
diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index cdd1a9079726..3b8eeac666bb 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -32,7 +32,7 @@ use kernel::{
lock::{spinlock::SpinLockBackend, Guard},
Arc, ArcBorrow, CondVar, CondVarTimeoutResult, Mutex, SpinLock, UniqueArc,
},
- task::Task,
+ task::{Pid, Task},
uaccess::{UserSlice, UserSliceReader},
uapi,
workqueue::{self, Work},
@@ -259,7 +259,7 @@ impl ProcessInner {
let push = match wrapper {
None => node
.incr_refcount_allow_zero2one(strong, self)?
- .map(|node| node as _),
+ .map(|node| node as DLArc<dyn DeliverToRead>),
Some(wrapper) => node.incr_refcount_allow_zero2one_with_wrapper(strong, wrapper, self),
};
if let Some(node) = push {
@@ -741,7 +741,7 @@ impl Process {
} else {
(0, 0, 0)
};
- let node_ref = self.get_node(ptr, cookie, flags as _, true, thread)?;
+ let node_ref = self.get_node(ptr, cookie, flags, true, thread)?;
let node = node_ref.node.clone();
self.ctx.set_manager_node(node_ref)?;
self.inner.lock().is_manager = true;
@@ -1536,13 +1536,13 @@ fn get_frozen_status(data: UserSlice) -> Result {
for ctx in crate::context::get_all_contexts()? {
ctx.for_each_proc(|proc| {
- if proc.task.pid() == info.pid as _ {
+ if proc.task.pid() == info.pid as Pid {
found = true;
let inner = proc.inner.lock();
let txns_pending = inner.txns_pending_locked();
- info.async_recv |= inner.async_recv as u32;
- info.sync_recv |= inner.sync_recv as u32;
- info.sync_recv |= (txns_pending as u32) << 1;
+ info.async_recv |= u32::from(inner.async_recv);
+ info.sync_recv |= u32::from(inner.sync_recv);
+ info.sync_recv |= u32::from(txns_pending) << 1;
}
});
}
diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/binder/rust_binder_main.rs
index dc1941cd2407..432390aab25b 100644
--- a/drivers/android/binder/rust_binder_main.rs
+++ b/drivers/android/binder/rust_binder_main.rs
@@ -6,12 +6,6 @@
#![crate_name = "rust_binder"]
#![recursion_limit = "256"]
-#![allow(
- clippy::as_underscore,
- clippy::ref_as_ptr,
- clippy::ptr_as_ptr,
- clippy::cast_lossless
-)]
use kernel::{
bindings::{self, seq_file},
@@ -417,7 +411,7 @@ unsafe extern "C" fn rust_binder_ioctl(
// 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::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(()) => 0,
Err(err) => err.to_errno() as isize,
}
@@ -511,7 +505,7 @@ unsafe extern "C" fn rust_binder_proc_show(
_: *mut kernel::ffi::c_void,
) -> kernel::ffi::c_int {
// SAFETY: Accessing the private field of `seq_file` is okay.
- let pid = (unsafe { (*ptr).private }) as usize as Pid;
+ let pid = 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 = unsafe { SeqFile::from_raw(ptr) };
diff --git a/drivers/android/binder/thread.rs b/drivers/android/binder/thread.rs
index 3b8520813941..19f881948a84 100644
--- a/drivers/android/binder/thread.rs
+++ b/drivers/android/binder/thread.rs
@@ -673,9 +673,9 @@ impl Thread {
let strong = obj.hdr.type_ == BINDER_TYPE_BINDER;
// SAFETY: `binder` is a `binder_uintptr_t`; any bit pattern is a valid
// representation.
- let ptr = unsafe { obj.__bindgen_anon_1.binder } as _;
- let cookie = obj.cookie as _;
- let flags = obj.flags as _;
+ let ptr = unsafe { obj.__bindgen_anon_1.binder };
+ let cookie = obj.cookie;
+ let flags = obj.flags;
let node = self
.process
.as_arc_borrow()
@@ -686,7 +686,7 @@ impl Thread {
BinderObjectRef::Handle(obj) => {
let strong = obj.hdr.type_ == BINDER_TYPE_HANDLE;
// SAFETY: `handle` is a `u32`; any bit pattern is a valid representation.
- let handle = unsafe { obj.__bindgen_anon_1.handle } as _;
+ let handle = unsafe { obj.__bindgen_anon_1.handle };
let node = self.process.get_node_from_handle(handle, strong)?;
security::binder_transfer_binder(&self.process.cred, &view.alloc.process.cred)?;
view.transfer_binder_object(offset, obj, strong, node)?;
@@ -743,7 +743,7 @@ impl Thread {
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,
@@ -850,7 +850,7 @@ impl Thread {
.ok_or(EINVAL)?;
let mut fda_bytes = 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)?;
if fds_len != fda_bytes.len() {
@@ -1392,7 +1392,7 @@ impl Thread {
let write_start = req.write_buffer.wrapping_add(req.write_consumed);
let write_len = req.write_size.saturating_sub(req.write_consumed);
let mut reader =
- 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();
while reader.len() >= size_of::<u32>() && self.inner.lock().return_work.is_unused() {
let before = reader.len();
@@ -1463,7 +1463,7 @@ impl Thread {
let read_start = req.read_buffer.wrapping_add(req.read_consumed);
let read_len = req.read_size.saturating_sub(req.read_consumed);
let mut writer = BinderReturnWriter::new(
- UserSlice::new(UserPtr::from_addr(read_start as _), read_len as _).writer(),
+ UserSlice::new(UserPtr::from_addr(read_start as usize), read_len as usize).writer(),
self,
);
let (in_pool, has_transaction, thread_todo, use_proc_queue) = {
@@ -1527,9 +1527,11 @@ impl Thread {
// 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 =
- UserSlice::new(UserPtr::from_addr(req.read_buffer as _), req.read_size as _)
- .writer();
+ let mut writer = 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/trace.rs b/drivers/android/binder/trace.rs
index 5539672d7285..06aabb3cc2f1 100644
--- a/drivers/android/binder/trace.rs
+++ b/drivers/android/binder/trace.rs
@@ -4,6 +4,8 @@
use crate::transaction::Transaction;
+use core::ptr;
+
use kernel::bindings::{rust_binder_transaction, task_struct};
use kernel::error::Result;
use kernel::ffi::{c_int, c_uint, c_ulong};
@@ -26,7 +28,7 @@ declare_trace! {
#[inline]
fn raw_transaction(t: &Transaction) -> rust_binder_transaction {
- t as *const Transaction as rust_binder_transaction
+ ptr::from_ref(t).cast_mut().cast()
}
#[inline]
diff --git a/drivers/android/binder/transaction.rs b/drivers/android/binder/transaction.rs
index 0e5d07b7e6f0..afef5b46eac2 100644
--- a/drivers/android/binder/transaction.rs
+++ b/drivers/android/binder/transaction.rs
@@ -11,6 +11,7 @@ use kernel::{
task::{Kuid, Pid},
time::{Instant, Monotonic},
types::ScopeGuard,
+ uapi,
};
use crate::{
@@ -410,16 +411,17 @@ impl DeliverToRead for Transaction {
let tr = tr_sec.tr_data();
if let Some(target_node) = &self.target_node {
let (ptr, cookie) = target_node.get_id();
- tr.target.ptr = ptr as _;
- tr.cookie = cookie as _;
+ tr.target.ptr = ptr as uapi::binder_uintptr_t;
+ tr.cookie = cookie as uapi::binder_uintptr_t;
};
tr.code = self.code;
tr.flags = self.flags;
- tr.data_size = self.data_size as _;
- tr.data.ptr.buffer = self.data_address as _;
- tr.offsets_size = self.offsets_size as _;
+ tr.data_size = self.data_size as uapi::binder_size_t;
+ tr.data.ptr.buffer = self.data_address as uapi::binder_uintptr_t;
+ tr.offsets_size = self.offsets_size as uapi::binder_size_t;
if tr.offsets_size > 0 {
- tr.data.ptr.offsets = (self.data_address + ptr_align(self.data_size).unwrap()) as _;
+ tr.data.ptr.offsets =
+ (self.data_address + ptr_align(self.data_size).unwrap()) as uapi::binder_uintptr_t;
}
tr.sender_euid = self.sender_euid.into_uid_in_current_ns();
tr.sender_pid = 0;