Skip to contentSkip to conversation

binder: skip dead binder_proc during binder_open

PATCH In review zhengyan 3 participants 3 messages Apr 29, 2025 Android drivers

lore
Share & tools
lore

zhengyan

author
#0 lore raw

PATCH 1/1 binder: skip dead binder_proc during binder_open

During binder_open, the binder_proc list is travesed to check for the existing binder_proc instances. binder_proc objects are async released in a deferred work after binder_release, and may remain temporarily on the binder_procs list even after being marked as dead.

Without checking the flag, binder_open may face a crash as "Unable to handle kernel paging request at virtual address dead000000000140"

---
 drivers/android/binder.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/android/binder.c +2 -0
index 76052006bd87..43ab4350e589 100644
@@ -6041,6 +6041,8 @@ static int binder_open(struct inode *nodp, struct file *filp)
 
 	mutex_lock(&binder_procs_lock);
 	hlist_for_each_entry(itr, &binder_procs, proc_node) {
+		if (itr->is_dead)
+			continue;
 		if (itr->pid == proc->pid) {
 			existing_pid = true;
 			break;
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 5 lines · zhengyan

During binder_open, the binder_proc list is travesed to check for the existing binder_proc instances. binder_proc objects are async released in a deferred work after binder_release, and may remain temporarily on the binder_procs list even after being marked as dead.

Nit, you do have a full 72 columns to use, can you use that?

Quoted 6 lines

Without checking the flag, binder_open may face a crash as "Unable to handle kernel paging request at virtual address dead000000000140"

Please use your name, not just an email alias.

Quoted 9 lines
---
 drivers/android/binder.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/android/binder.c +0 -0
index 76052006bd87..43ab4350e589 100644

drivers/android/binder.c static int binder_open(struct inode *nodp, struct file *filp) · line 6045

Quoted 5 lines
drivers/android/binder.c +2 -0
@@ -6041,6 +6041,8 @@ static int binder_open(struct inode *nodp, struct file *filp)
 
 	mutex_lock(&binder_procs_lock);
 	hlist_for_each_entry(itr, &binder_procs, proc_node) {
+		if (itr->is_dead)
+			continue;

What commit id does this fix? Should it go to stable kernels? If so, how far back?

How was this tested?

thanks,

greg k-h

maintainer
#2 lore raw
In reply to zhengyan
Quoted 30 lines · zhengyan

During binder_open, the binder_proc list is travesed to check for the existing binder_proc instances. binder_proc objects are async released in a deferred work after binder_release, and may remain temporarily on the binder_procs list even after being marked as dead.

Without checking the flag, binder_open may face a crash as "Unable to handle kernel paging request at virtual address dead000000000140"

---
 drivers/android/binder.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/android/binder.c +2 -0
index 76052006bd87..43ab4350e589 100644
@@ -6041,6 +6041,8 @@ static int binder_open(struct inode *nodp, struct file *filp)
 
 	mutex_lock(&binder_procs_lock);
 	hlist_for_each_entry(itr, &binder_procs, proc_node) {
+		if (itr->is_dead)
+			continue;
 		if (itr->pid == proc->pid) {
 			existing_pid = true;
 			break;
Signature · 1 line
2.25.1

Can you please explain this scenario? My understanding is that dead procs are removed from the binder_procs list (with appropriate locks) before they are marked as ->is_dead. So how is this even possible?

--
Carlos Llamas