]> Git Repo - linux.git/commitdiff
binder: fix hang of unregistered readers
authorCarlos Llamas <[email protected]>
Thu, 11 Jul 2024 20:14:51 +0000 (20:14 +0000)
committerGreg Kroah-Hartman <[email protected]>
Fri, 12 Jul 2024 09:31:37 +0000 (11:31 +0200)
With the introduction of binder_available_for_proc_work_ilocked() in
commit 1b77e9dcc3da ("ANDROID: binder: remove proc waitqueue") a binder
thread can only "wait_for_proc_work" after its thread->looper has been
marked as BINDER_LOOPER_STATE_{ENTERED|REGISTERED}.

This means an unregistered reader risks waiting indefinitely for work
since it never gets added to the proc->waiting_threads. If there are no
further references to its waitqueue either the task will hang. The same
applies to readers using the (e)poll interface.

I couldn't find the rationale behind this restriction. So this patch
restores the previous behavior of allowing unregistered threads to
"wait_for_proc_work". Note that an error message for this scenario,
which had previously become unreachable, is now re-enabled.

Fixes: 1b77e9dcc3da ("ANDROID: binder: remove proc waitqueue")
Cc: [email protected]
Cc: Martijn Coenen <[email protected]>
Cc: Arve Hjønnevåg <[email protected]>
Signed-off-by: Carlos Llamas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/android/binder.c

index 0c2161b1f057752618c9f71cb86e7610342d5964..f26286e3713ec73388c92ecaa579abc361a617a5 100644 (file)
@@ -570,9 +570,7 @@ static bool binder_has_work(struct binder_thread *thread, bool do_proc_work)
 static bool binder_available_for_proc_work_ilocked(struct binder_thread *thread)
 {
        return !thread->transaction_stack &&
-               binder_worklist_empty_ilocked(&thread->todo) &&
-               (thread->looper & (BINDER_LOOPER_STATE_ENTERED |
-                                  BINDER_LOOPER_STATE_REGISTERED));
+               binder_worklist_empty_ilocked(&thread->todo);
 }
 
 static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc,
This page took 0.074387 seconds and 4 git commands to generate.