From 2ef75ab83a6a7872129c38bd2d3fee007c6f54ad Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Wed, 2 Jul 2025 12:52:35 +0000 Subject: [PATCH] ANDROID: rust_binder: use tgid_nr_ns for getting pid Because we are backporting commit e0020ba6cbcb ("rust: add PidNamespace"), it is neccesary to update Rust Binder to use the new tgid_nr_ns() method for getting the task's pid, as that commit deleted pid_in_current_ns(). Bug: 429146594 Change-Id: I3acd7e3f1fee2957d5663208614667220e09dfd5 Signed-off-by: Alice Ryhl --- drivers/android/binder/node.rs | 2 +- drivers/android/binder/process.rs | 8 ++++++-- drivers/android/binder/thread.rs | 6 +++--- drivers/android/binder/transaction.rs | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs index 23148d3c9597..738ce34776f6 100644 --- a/drivers/android/binder/node.rs +++ b/drivers/android/binder/node.rs @@ -723,7 +723,7 @@ impl Node { if len == inner.freeze_list.len() { pr_warn!( "Could not remove freeze listener for {}\n", - p.task.pid_in_current_ns() + p.pid_in_current_ns() ); } if inner.freeze_list.is_empty() { diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs index a46267b5fdf9..d630fc067324 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -511,9 +511,13 @@ impl Process { Ok(process) } + pub(crate) fn pid_in_current_ns(&self) -> kernel::task::Pid { + self.task.tgid_nr_ns(None) + } + #[inline(never)] pub(crate) fn debug_print_stats(&self, m: &SeqFile, ctx: &Context) -> Result<()> { - seq_print!(m, "proc {}\n", self.task.pid_in_current_ns()); + seq_print!(m, "proc {}\n", self.pid_in_current_ns()); seq_print!(m, "context {}\n", &*ctx.name); let inner = self.inner.lock(); @@ -561,7 +565,7 @@ impl Process { #[inline(never)] pub(crate) fn debug_print(&self, m: &SeqFile, ctx: &Context, print_all: bool) -> Result<()> { - seq_print!(m, "proc {}\n", self.task.pid_in_current_ns()); + seq_print!(m, "proc {}\n", self.pid_in_current_ns()); seq_print!(m, "context {}\n", &*ctx.name); let mut all_threads = KVec::new(); diff --git a/drivers/android/binder/thread.rs b/drivers/android/binder/thread.rs index 5352f5deaac8..362d72052d60 100644 --- a/drivers/android/binder/thread.rs +++ b/drivers/android/binder/thread.rs @@ -1299,7 +1299,7 @@ impl Thread { pr_warn!( "Transaction failed: {:?} my_pid:{}", err, - self.process.task.pid_in_current_ns() + self.process.pid_in_current_ns() ); } @@ -1584,7 +1584,7 @@ impl Thread { pr_warn!( "Write failure {:?} in pid:{}", err, - self.process.task.pid_in_current_ns() + self.process.pid_in_current_ns() ); req.read_consumed = 0; writer.write(&req)?; @@ -1601,7 +1601,7 @@ impl Thread { pr_warn!( "Read failure {:?} in pid:{}", ret, - self.process.task.pid_in_current_ns() + self.process.pid_in_current_ns() ); } } diff --git a/drivers/android/binder/transaction.rs b/drivers/android/binder/transaction.rs index 240bbac341de..1477b93af7b1 100644 --- a/drivers/android/binder/transaction.rs +++ b/drivers/android/binder/transaction.rs @@ -429,7 +429,7 @@ impl DeliverToRead for Transaction { tr.sender_pid = 0; if self.target_node.is_some() && self.flags & TF_ONE_WAY == 0 { // Not a reply and not one-way. - tr.sender_pid = self.from.process.task.pid_in_current_ns(); + tr.sender_pid = self.from.process.pid_in_current_ns(); } let code = if self.target_node.is_none() { BR_REPLY