FROMLIST: binder: avoid race conditions when enqueuing txn
authorTodd Kjos <tkjos@google.com>
Tue, 9 May 2017 15:31:32 +0000 (08:31 -0700)
committerTodd Kjos <tkjos@google.com>
Thu, 13 Jul 2017 15:34:19 +0000 (08:34 -0700)
commit8dedb0ceb63df82fa8621fe8d79eea3908381e1b
tree0fa5d661aa75602f44cf753de710c5749ad3a38b
parent6079261f68ce8aee15f33027c0c2acfbe1159d93
FROMLIST: binder: avoid race conditions when enqueuing txn

(from https://patchwork.kernel.org/patch/9817813/)

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.

Change-Id: I247f25a66cfeac8a1fcb2ad65c6053d51cafe4f3
Signed-off-by: Todd Kjos <tkjos@google.com>
drivers/android/binder.c