binder: avoid race conditions when enqueuing txn
authorTodd Kjos <tkjos@android.com>
Thu, 29 Jun 2017 19:01:48 +0000 (12:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jul 2017 12:47:29 +0000 (14:47 +0200)
commitccae6f676001d00efd1a4626773d1577e53188f7
tree0770cf708b7e91b70c29c8b6e72f0546dc6ed989
parent26b47d8a16a72878228aeaed573786825b7ca204
binder: avoid race conditions when enqueuing txn

Currently, the transaction complete work item is queued
after the transaction. This means that it is possible
for the transaction to be handled and a reply to be
enqueued in the current thread before the transaction
complete is enqueued, which violates the protocol
with userspace who may not expect the transaction
complete. Fixed by always enqueing the transaction
complete first.

Also, once the transaction is enqueued, it is unsafe
to access since it might be freed. Currently,
t->flags is accessed to determine whether a sync
wake is needed. Changed to access tr->flags
instead.

Signed-off-by: Todd Kjos <tkjos@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder.c