From: Adhyansh Verma <adhyanshverma2010@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Carlos Llamas <cmllamas@google.com>
Cc: "Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Christian Brauner" <brauner@kernel.org>,
linux-kernel@vger.kernel.org,
"Adhyansh Verma" <adhyanshverma2010@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] rust_binder: retry ready threads or fallback to proc queue on dead thread
Date: Fri, 27 Nov 2026 15:52:32 +0530 [thread overview]
Message-ID: <20261127102232.74796-1-adhyanshverma2010@gmail.com> (raw)
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
next reply other threads:[~2026-11-27 10:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 10:22 Adhyansh Verma [this message]
2026-11-27 14:27 ` Alice Ryhl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127102232.74796-1-adhyanshverma2010@gmail.com \
--to=adhyanshverma2010@gmail.com \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tkjos@android.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®