Skip to contentSkip to conversation

binder: add missing binder_unlock()

PATCH Applied Eric Biggers 3 participants 5 messages Feb 26, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 binder: add missing binder_unlock()

From: Eric Biggers <[email protected]>

[Please apply to 4.4-stable and 4.9-stable.]

When commit 4be5a2810489 ("binder: check for binder_thread allocation failure in binder_poll()") was applied to 4.4-stable and 4.9-stable it was forgotten to release the global binder lock in the new error path. The global binder lock wasn't removed until v4.14, by commit a60b890f607d ("binder: remove global binder lock").

Fix the new error path to release the lock.

---
 drivers/android/binder.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/android/binder.c +3 -1
index 3b6ac80b2127..49199bd2ab93 100644
@@ -2628,8 +2628,10 @@ static unsigned int binder_poll(struct file *filp,
 	binder_lock(__func__);
 
 	thread = binder_get_thread(proc);
-	if (!thread)
+	if (!thread) {
+		binder_unlock(__func__);
 		return POLLERR;
+	}
 
 	wait_for_proc_work = thread->transaction_stack == NULL &&
 		list_empty(&thread->todo) && thread->return_error == BR_OK;
Signature · 1 line
2.16.1.291.g4437f3f132-goog
#1 lore raw

Ack. Agree this is needed for pre-4.14.

Quoted 37 lines · Eric Biggers

From: Eric Biggers <[email protected]>

[Please apply to 4.4-stable and 4.9-stable.]

When commit 4be5a2810489 ("binder: check for binder_thread allocation failure in binder_poll()") was applied to 4.4-stable and 4.9-stable it was forgotten to release the global binder lock in the new error path. The global binder lock wasn't removed until v4.14, by commit a60b890f607d ("binder: remove global binder lock").

Fix the new error path to release the lock.

---
 drivers/android/binder.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/android/binder.c +3 -2
index 3b6ac80b2127..49199bd2ab93 100644
@@ -2628,8 +2628,10 @@ static unsigned int binder_poll(struct file *filp,
        binder_lock(__func__);
 
        thread = binder_get_thread(proc);
-       if (!thread)
+       if (!thread) {
+               binder_unlock(__func__);
                return POLLERR;
+       }
 
        wait_for_proc_work = thread->transaction_stack == NULL &&
                list_empty(&thread->todo) && thread->return_error == BR_OK;
--

2.16.1.291.g4437f3f132-goog

maintainer Applied
#2 lore raw

Patch "binder: add missing binder_unlock()" has been added to the 4.4-stable tree

In reply to Eric Biggers

This is a note to let you know that I've just added the patch titled

binder: add missing binder_unlock()

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
binder-add-missing-binder_unlock.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From [email protected] Mon Feb 26 20:36:21 2018

From: Eric Biggers <[email protected]>
Date: Mon, 26 Feb 2018 10:56:45 -0800
Subject: binder: add missing binder_unlock()
To: [email protected], Greg Kroah-Hartman <[email protected]>
Cc: Guenter Roeck <[email protected]>, Todd Kjos <[email protected]>, Eric Biggers <[email protected]>
Message-ID: <[email protected]>

From: Eric Biggers <[email protected]>

When commit 4be5a2810489 ("binder: check for binder_thread allocation failure in binder_poll()") was applied to 4.4-stable and 4.9-stable it was forgotten to release the global binder lock in the new error path. The global binder lock wasn't removed until v4.14, by commit a60b890f607d ("binder: remove global binder lock").

Fix the new error path to release the lock.

---
 drivers/android/binder.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/android/binder.c +3 -1
@@ -2622,8 +2622,10 @@ static unsigned int binder_poll(struct f
 	binder_lock(__func__);
 
 	thread = binder_get_thread(proc);
-	if (!thread)
+	if (!thread) {
+		binder_unlock(__func__);
 		return POLLERR;
+	}
 
 	wait_for_proc_work = thread->transaction_stack == NULL &&
 		list_empty(&thread->todo) && thread->return_error == BR_OK;

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/binder-add-missing-binder_unlock.patch

#3 lore raw
In reply to Eric Biggers
Quoted 36 lines · Eric Biggers

From: Eric Biggers <[email protected]>

[Please apply to 4.4-stable and 4.9-stable.]

When commit 4be5a2810489 ("binder: check for binder_thread allocation failure in binder_poll()") was applied to 4.4-stable and 4.9-stable it was forgotten to release the global binder lock in the new error path. The global binder lock wasn't removed until v4.14, by commit a60b890f607d ("binder: remove global binder lock").

Fix the new error path to release the lock.

---
 drivers/android/binder.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/android/binder.c +3 -1
index 3b6ac80b2127..49199bd2ab93 100644
@@ -2628,8 +2628,10 @@ static unsigned int binder_poll(struct file *filp,
 	binder_lock(__func__);
 
 	thread = binder_get_thread(proc);
-	if (!thread)
+	if (!thread) {
+		binder_unlock(__func__);
 		return POLLERR;
+	}
 
 	wait_for_proc_work = thread->transaction_stack == NULL &&
 		list_empty(&thread->todo) && thread->return_error == BR_OK;
Signature · 1 line
2.16.1.291.g4437f3f132-goog

Thanks for the patch, all now queued up.

greg k-h

maintainer Applied
#4 lore raw

Patch "binder: add missing binder_unlock()" has been added to the 4.9-stable tree

In reply to Eric Biggers

This is a note to let you know that I've just added the patch titled

binder: add missing binder_unlock()

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
binder-add-missing-binder_unlock.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From [email protected] Mon Feb 26 20:36:21 2018

From: Eric Biggers <[email protected]>
Date: Mon, 26 Feb 2018 10:56:45 -0800
Subject: binder: add missing binder_unlock()
To: [email protected], Greg Kroah-Hartman <[email protected]>
Cc: Guenter Roeck <[email protected]>, Todd Kjos <[email protected]>, Eric Biggers <[email protected]>
Message-ID: <[email protected]>

From: Eric Biggers <[email protected]>

When commit 4be5a2810489 ("binder: check for binder_thread allocation failure in binder_poll()") was applied to 4.4-stable and 4.9-stable it was forgotten to release the global binder lock in the new error path. The global binder lock wasn't removed until v4.14, by commit a60b890f607d ("binder: remove global binder lock").

Fix the new error path to release the lock.

---
 drivers/android/binder.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/android/binder.c +3 -1
@@ -2628,8 +2628,10 @@ static unsigned int binder_poll(struct f
 	binder_lock(__func__);
 
 	thread = binder_get_thread(proc);
-	if (!thread)
+	if (!thread) {
+		binder_unlock(__func__);
 		return POLLERR;
+	}
 
 	wait_for_proc_work = thread->transaction_stack == NULL &&
 		list_empty(&thread->todo) && thread->return_error == BR_OK;

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/binder-add-missing-binder_unlock.patch