ANDROID: binder: remove waitqueue when thread exits.
authorMartijn Coenen <maco@android.com>
Fri, 5 Jan 2018 10:27:07 +0000 (11:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Feb 2018 16:39:22 +0000 (17:39 +0100)
commit7a3cee43e935b9d526ad07f20bf005ba7e74d05b
treea2a30e0b3dceeb1e779311ae76ff45473871e570
parent2ba5966eddefdf04306bd1da36811c8b83a9664d
ANDROID: binder: remove waitqueue when thread exits.

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.

Signed-off-by: Martijn Coenen <maco@android.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder.c