We have moved to a new Sailfish OS Forum. Please start new discussions there.

Remove waitqueue when thread exits in kernel-staging-android-binder CVE-2019-2215 high

asked 2019-10-04 17:00:11 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2020-03-24 10:18:28 +0200

lpr gravatar image


commit f5cb779ba16334b45ba8946d6bfa6d9834d1527f upstream.

binder_poll() passes the thread->wait waitqueue that can be slept on for work. When a thread that uses epoll explicitly exits using BINDER_THREAD_EXIT, the waitqueue is freed, but it is never removed from the corresponding epoll data structure. When the process subsequently exits, the epoll cleanup code tries to access the waitlist, which results in a use-after-free. Prevent this by using POLLFREE when the thread exits.

File affected: kernel-adaptation-sbj- lines 2629-2644

Fix is available and should look like:

diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index f95b559..b2e4f493b 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -2629,16 +2629,28 @@ static int binder_free_thread(struct binder_proc *proc,
                t = t->to_parent;
        } else if (t->from == thread) {
            t->from = NULL;
            t = t->from_parent;
        } else
+   /*
+    * If this thread used poll, make sure we remove the waitqueue  
+    * from any epoll data structures holding it with POLLFREE. 
+    * waitqueue_active() is safe to use here because we're holding 
+    * the inner lock.  
+    */ 
+   if ((thread->looper & BINDER_LOOPER_STATE_NEED_RETURN) &&
+       waitqueue_active(&thread->wait)) {  
+       wake_up_poll(&thread->wait, POLLHUP | POLLFREE);    
+   }
    if (send_reply)
        binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
    return active_transactions;

static unsigned int binder_poll(struct file *filp,
edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted

answered 2019-10-05 09:04:06 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

updated 2019-10-05 12:11:26 +0200

JSEHV gravatar image

Please provide more details...

edit flag offensive delete publish link more



hm, I don't know what... just read the article from arstechnica and follow the link to the Blog-Post of Project-Zero member Maddie Stone...

lpr ( 2019-10-05 15:21:03 +0200 )edit
Login/Signup to Answer

Question tools



Asked: 2019-10-04 17:00:11 +0200

Seen: 763 times

Last updated: Mar 24 '20