[PATCH] binder: do not crash on bad transaction in binder_thread_release()
From: Frode Isaksen
Date: Mon Mar 31 2025 - 11:42:27 EST
From: Frode Isaksen <frode@xxxxxxxx>
Instead of calling BUG(), set the binder_thread to NULL,
as is done in other parts of the code.
Log if it is a bad transaction (other than in or out).
The BUG in binder_thread_release() was preceded by
these warning logs:
binder: 1198:1217 got reply transaction with bad transaction stack,
transaction 49693 has target 1198:0
binder: 1198:1217 transaction failed 29201/-71, size 4-0 line 3065
...
binder: release 954:1333 transaction 49693 out, still active
...
binder: release 1198:1217 transaction 49693 out, still active
kernel BUG at drivers/android/binder.c:5070!
Signed-off-by: Frode Isaksen <frode@xxxxxxxx>
---
This bug was discovered, tested and fixed (no more crashes seen) on Meta Quest 3 device.
drivers/android/binder.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 76052006bd87..c21d7806e42b 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -5302,7 +5302,8 @@ static int binder_thread_release(struct binder_proc *proc,
"release %d:%d transaction %d %s, still active\n",
proc->pid, thread->pid,
t->debug_id,
- (t->to_thread == thread) ? "in" : "out");
+ (t->to_thread == thread) ? "in" :
+ (t->from == thread) ? "out" : "bad");
if (t->to_thread == thread) {
thread->proc->outstanding_txns--;
@@ -5317,7 +5318,7 @@ static int binder_thread_release(struct binder_proc *proc,
t->from = NULL;
t = t->from_parent;
} else
- BUG();
+ t = NULL;
spin_unlock(&last_t->lock);
if (t)
spin_lock(&t->lock);
--
2.49.0