[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191006172018.533551246@linuxfoundation.org>
Date: Sun, 6 Oct 2019 19:21:18 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org,
syzbot+a2a3c4909716e271487e@...kaller.appspotmail.com,
Martijn Coenen <maco@...roid.com>,
Mattias Nissler <mnissler@...omium.org>
Subject: [PATCH 4.9 31/47] ANDROID: binder: synchronize_rcu() when using POLLFREE.
From: Martijn Coenen <maco@...roid.com>
commit 5eeb2ca02a2f6084fc57ae5c244a38baab07033a upstream.
To prevent races with ep_remove_waitqueue() removing the
waitqueue at the same time.
Reported-by: syzbot+a2a3c4909716e271487e@...kaller.appspotmail.com
Signed-off-by: Martijn Coenen <maco@...roid.com>
Cc: stable <stable@...r.kernel.org> # 4.14+
Signed-off-by: Mattias Nissler <mnissler@...omium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
drivers/android/binder.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2641,6 +2641,15 @@ static int binder_free_thread(struct bin
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);
Powered by blists - more mailing lists