Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5eeb2ca0 authored by Martijn Coenen's avatar Martijn Coenen Committed by Greg Kroah-Hartman
Browse files

ANDROID: binder: synchronize_rcu() when using POLLFREE.



To prevent races with ep_remove_waitqueue() removing the
waitqueue at the same time.

Reported-by: default avatar <syzbot+a2a3c4909716e271487e@syzkaller.appspotmail.com>
Signed-off-by: default avatarMartijn Coenen <maco@android.com>
Cc: stable <stable@vger.kernel.org> # 4.14+
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8ca86f16
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -4382,6 +4382,15 @@ static int binder_thread_release(struct binder_proc *proc,


	binder_inner_proc_unlock(thread->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)
	if (send_reply)
		binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
		binder_send_failed_reply(send_reply, BR_DEAD_REPLY);
	binder_release_work(proc, &thread->todo);
	binder_release_work(proc, &thread->todo);