aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Coenen <maco@android.com>2018-02-16 09:47:15 +0100
committerTodd Kjos <tkjos@google.com>2020-01-29 15:02:00 -0800
commit2612b4d01c2144f5a06e8fdd5d7f3ece82575042 (patch)
tree7f0d293cedb1cebc90a50dc8518af24b146eda7b
parent05e657257d663a502a06d2b693a6e72ccf3f6c27 (diff)
ANDROID: binder: synchronize_rcu() when using POLLFREE.ASB-2020-02-05_4.4-o-release
commit 5eeb2ca02a2f6084fc57ae5c244a38baab07033a upstream. To prevent races with ep_remove_waitqueue() removing the waitqueue at the same time. Change-Id: I234192a63e3215646a042d5a3c894304591811a4 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>
-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 f447cae4353b..70a4f2bc6684 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4508,6 +4508,15 @@ static int binder_thread_release(struct binder_proc *proc,
binder_inner_proc_unlock(thread->proc);
+ /*
+ * 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(proc, &thread->todo);