* [PATCH] rust_binder: retry ready threads or fallback to proc queue on dead thread
@ 2026-11-27 10:22 Adhyansh Verma
2026-11-27 14:27 ` Alice Ryhl
0 siblings, 1 reply; 2+ messages in thread
From: Adhyansh Verma @ 2026-11-27 10:22 UTC (permalink / raw)
To: Alice Ryhl, Greg Kroah-Hartman, Carlos Llamas
Cc: Arve Hjønnevåg, Todd Kjos, Christian Brauner,
linux-kernel, Adhyansh Verma, stable
When ProcessInner::push_work() attempts to deliver work to a waiting
thread from ready_threads, it previously checked only the first thread
with an 'if let'. If that thread has exited while waiting in the pool,
thread.push_work_inner() returns PushWorkRes::FailedDead(work).
Matching on FailedDead immediately returned Err(BinderError::new_dead()),
aborting the delivery and dropping the work item. This incorrectly
treated the entire process as dead, even though the process itself was
alive, other live worker threads might be available in ready_threads,
and the process work queue (self.work) was ready to accept the work.
Change the lookup to a 'while let' loop so that if a popped thread is
dead, push_work() continues checking any remaining ready threads. If no
ready threads remain, fall back to queuing the work on self.work, only
returning an error if self.is_dead is actually true.
Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Cc: stable@vger.kernel.org
---
drivers/android/binder/process.rs | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index 1f4cb43f1de..b7b53b99689 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -184,23 +184,27 @@ fn new() -> Self {
pub(crate) fn push_work(
&mut self,
proc: &Process,
- work: DLArc<dyn DeliverToRead>,
+ mut work: DLArc<dyn DeliverToRead>,
) -> Result<(), (BinderError, DLArc<dyn DeliverToRead>)> {
let sync = work.should_sync_wakeup();
// Try to find a ready thread to which to push the work.
- if let Some(thread) = self.ready_threads.pop_front() {
+ while let Some(thread) = self.ready_threads.pop_front() {
// Push to thread while holding state lock. This prevents the thread from giving up
// (for example, because of a signal) when we're about to deliver work.
match thread.push_work_inner(work, sync) {
- PushWorkRes::Ok => Ok(()),
+ PushWorkRes::Ok => return Ok(()),
PushWorkRes::OkNotifyPoll => {
proc.notify_poll(sync);
- Ok(())
+ return Ok(());
+ }
+ PushWorkRes::FailedDead(dead_work) => {
+ work = dead_work;
}
- PushWorkRes::FailedDead(work) => Err((BinderError::new_dead(), work)),
}
- } else if self.is_dead {
+ }
+
+ if self.is_dead {
Err((BinderError::new_dead(), work))
} else {
// Didn't find a thread waiting for proc work; this can happen
--
2.56.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] rust_binder: retry ready threads or fallback to proc queue on dead thread
2026-11-27 10:22 [PATCH] rust_binder: retry ready threads or fallback to proc queue on dead thread Adhyansh Verma
@ 2026-11-27 14:27 ` Alice Ryhl
0 siblings, 0 replies; 2+ messages in thread
From: Alice Ryhl @ 2026-11-27 14:27 UTC (permalink / raw)
To: Adhyansh Verma
Cc: Alice Ryhl, Greg Kroah-Hartman, Carlos Llamas,
Arve Hjønnevåg, Todd Kjos, Christian Brauner,
linux-kernel, stable
On Fri, Nov 27, 2026 at 03:52:32PM +0530, Adhyansh Verma wrote:
> When ProcessInner::push_work() attempts to deliver work to a waiting
> thread from ready_threads, it previously checked only the first thread
> with an 'if let'. If that thread has exited while waiting in the pool,
> thread.push_work_inner() returns PushWorkRes::FailedDead(work).
A thread in `ready_threads` can never be dead: `Thread::release()` is
only called from `BINDER_THREAD_EXIT` on `current` (which cannot be
sleeping in `Thread::get_work()` with a `Registration` active) or from
`Process::deferred_release()` after `ready_threads` is already emptied.
So this case is unreachable, and I don't think we need this change.
Alice
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 14:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 10:22 [PATCH] rust_binder: retry ready threads or fallback to proc queue on dead thread Adhyansh Verma
2026-11-27 14:27 ` Alice Ryhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®