summaryrefslogtreecommitdiff
path: root/drivers/android
diff options
context:
space:
mode:
authorMartijn Coenen <maco@android.com>2018-02-16 09:47:15 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-07 21:01:03 +0200
commitfcf46dcedbc419633771e16bfdf97a528f4d7dab (patch)
tree326656e14ab65edac2310117d0b58772aa66a72d /drivers/android
parent80eb98a4ee70428d5b4b7202195a916385a76809 (diff)
ANDROID: binder: synchronize_rcu() when using POLLFREE.
commit 5eeb2ca02a2f6084fc57ae5c244a38baab07033a upstream. To prevent races with ep_remove_waitqueue() removing the waitqueue at the same time. Reported-by: syzbot+a2a3c4909716e271487e@syzkaller.appspotmail.com Signed-off-by: Martijn Coenen <maco@android.com> Cc: stable <stable@vger.kernel.org> # 4.14+ Signed-off-by: Mattias Nissler <mnissler@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android')
-rw-r--r--drivers/android/binder.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 5c13a6eb4fea..39e458b3c532 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2623,6 +2623,15 @@ static int binder_free_thread(struct binder_proc *proc,
wake_up_poll(&thread->wait, POLLHUP | POLLFREE);
}
+ /*
+ * This is needed to avoid races between wake_up_poll() above and
+ * and ep_remove_waitqueue() called for other reasons (eg the epoll file
+ * descriptor being closed); ep_remove_waitqueue() holds an RCU read
+ * lock, so we can be sure it's done after calling synchronize_rcu().
+ */
+ if (thread->looper & BINDER_LOOPER_STATE_POLL)
+ synchronize_rcu();
+
if (send_reply)
binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
binder_release_work(&thread->todo);