<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/android/binder.c, branch v4.14.22</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v4.14.22</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v4.14.22'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2018-02-25T10:07:52+00:00</updated>
<entry>
<title>binder: replace "%p" with "%pK"</title>
<updated>2018-02-25T10:07:52+00:00</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@android.com</email>
</author>
<published>2018-02-07T21:57:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b46af094b82a47ca1cbba9092578f8f96af82798'/>
<id>urn:sha1:b46af094b82a47ca1cbba9092578f8f96af82798</id>
<content type='text'>
commit 8ca86f1639ec5890d400fff9211aca22d0a392eb upstream.

The format specifier "%p" can leak kernel addresses. Use
"%pK" instead. There were 4 remaining cases in binder.c.

Signed-off-by: Todd Kjos &lt;tkjos@google.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>binder: check for binder_thread allocation failure in binder_poll()</title>
<updated>2018-02-25T10:07:52+00:00</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@google.com</email>
</author>
<published>2018-01-31T07:11:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=047ba51a55e369ba2b5a9e7e5dfa179cb10a7569'/>
<id>urn:sha1:047ba51a55e369ba2b5a9e7e5dfa179cb10a7569</id>
<content type='text'>
commit f88982679f54f75daa5b8eff3da72508f1e7422f upstream.

If the kzalloc() in binder_get_thread() fails, binder_poll()
dereferences the resulting NULL pointer.

Fix it by returning POLLERR if the memory allocation failed.

This bug was found by syzkaller using fault injection.

Reported-by: syzbot &lt;syzkaller@googlegroups.com&gt;
Fixes: 457b9a6f09f0 ("Staging: android: add binder driver")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ANDROID: binder: synchronize_rcu() when using POLLFREE.</title>
<updated>2018-02-25T10:07:52+00:00</updated>
<author>
<name>Martijn Coenen</name>
<email>maco@android.com</email>
</author>
<published>2018-02-16T08:47:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=441b5d10e4602b25ad960d1ca1c6bb77e788c220'/>
<id>urn:sha1:441b5d10e4602b25ad960d1ca1c6bb77e788c220</id>
<content type='text'>
commit 5eeb2ca02a2f6084fc57ae5c244a38baab07033a upstream.

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

Reported-by: syzbot+a2a3c4909716e271487e@syzkaller.appspotmail.com
Signed-off-by: Martijn Coenen &lt;maco@android.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; # 4.14+
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ANDROID: binder: remove WARN() for redundant txn error</title>
<updated>2018-02-25T10:07:52+00:00</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@android.com</email>
</author>
<published>2018-02-07T20:38:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=129926c3756ac93c19608f8065d9654a99006fbf'/>
<id>urn:sha1:129926c3756ac93c19608f8065d9654a99006fbf</id>
<content type='text'>
commit e46a3b3ba7509cb7fda0e07bc7c63a2cd90f579b upstream.

binder_send_failed_reply() is called when a synchronous
transaction fails. It reports an error to the thread that
is waiting for the completion. Given that the transaction
is synchronous, there should never be more than 1 error
response to that thread -- this was being asserted with
a WARN().

However, when exercising the driver with syzbot tests, cases
were observed where multiple "synchronous" requests were
sent without waiting for responses, so it is possible that
multiple errors would be reported to the thread. This testing
was conducted with panic_on_warn set which forced the crash.

This is easily reproduced by sending back-to-back
"synchronous" transactions without checking for any
response (eg, set read_size to 0):

    bwr.write_buffer = (uintptr_t)&amp;bc1;
    bwr.write_size = sizeof(bc1);
    bwr.read_buffer = (uintptr_t)&amp;br;
    bwr.read_size = 0;
    ioctl(fd, BINDER_WRITE_READ, &amp;bwr);
    sleep(1);
    bwr2.write_buffer = (uintptr_t)&amp;bc2;
    bwr2.write_size = sizeof(bc2);
    bwr2.read_buffer = (uintptr_t)&amp;br;
    bwr2.read_size = 0;
    ioctl(fd, BINDER_WRITE_READ, &amp;bwr2);
    sleep(1);

The first transaction is sent to the servicemanager and the reply
fails because no VMA is set up by this client. After
binder_send_failed_reply() is called, the BINDER_WORK_RETURN_ERROR
is sitting on the thread's todo list since the read_size was 0 and
the client is not waiting for a response.

The 2nd transaction is sent and the BINDER_WORK_RETURN_ERROR has not
been consumed, so the thread's reply_error.cmd is still set (normally
cleared when the BINDER_WORK_RETURN_ERROR is handled). Therefore
when the servicemanager attempts to reply to the 2nd failed
transaction, the error is already set and it triggers this warning.

This is a user error since it is not waiting for the synchronous
transaction to complete. If it ever does check, it will see an
error.

Changed the WARN() to a pr_warn().

Signed-off-by: Todd Kjos &lt;tkjos@android.com&gt;
Reported-by: syzbot &lt;syzkaller@googlegroups.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ANDROID: binder: remove waitqueue when thread exits.</title>
<updated>2018-02-03T16:39:22+00:00</updated>
<author>
<name>Martijn Coenen</name>
<email>maco@android.com</email>
</author>
<published>2018-01-05T10:27:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7a3cee43e935b9d526ad07f20bf005ba7e74d05b'/>
<id>urn:sha1:7a3cee43e935b9d526ad07f20bf005ba7e74d05b</id>
<content type='text'>
commit f5cb779ba16334b45ba8946d6bfa6d9834d1527f upstream.

binder_poll() passes the thread-&gt;wait waitqueue that
can be slept on for work. When a thread that uses
epoll explicitly exits using BINDER_THREAD_EXIT,
the waitqueue is freed, but it is never removed
from the corresponding epoll data structure. When
the process subsequently exits, the epoll cleanup
code tries to access the waitlist, which results in
a use-after-free.

Prevent this by using POLLFREE when the thread exits.

Signed-off-by: Martijn Coenen &lt;maco@android.com&gt;
Reported-by: syzbot &lt;syzkaller@googlegroups.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>binder: fix proc-&gt;files use-after-free</title>
<updated>2018-01-02T19:31:15+00:00</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@android.com</email>
</author>
<published>2017-11-27T17:32:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d87f1bc7d15b89bd3bcf31020eb7f3b3cd6f84b5'/>
<id>urn:sha1:d87f1bc7d15b89bd3bcf31020eb7f3b3cd6f84b5</id>
<content type='text'>
commit 7f3dc0088b98533f17128058fac73cd8b2752ef1 upstream.

proc-&gt;files cleanup is initiated by binder_vma_close. Therefore
a reference on the binder_proc is not enough to prevent the
files_struct from being released while the binder_proc still has
a reference. This can lead to an attempt to dereference the
stale pointer obtained from proc-&gt;files prior to proc-&gt;files
cleanup. This has been seen once in task_get_unused_fd_flags()
when __alloc_fd() is called with a stale "files".

The fix is to protect proc-&gt;files with a mutex to prevent cleanup
while in use.

Signed-off-by: Todd Kjos &lt;tkjos@google.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ANDROID: binder: fix transaction leak.</title>
<updated>2017-12-10T12:40:37+00:00</updated>
<author>
<name>Martijn Coenen</name>
<email>maco@android.com</email>
</author>
<published>2017-11-13T09:06:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=22ad53793edbc73a5a12f6960749bc967551fde4'/>
<id>urn:sha1:22ad53793edbc73a5a12f6960749bc967551fde4</id>
<content type='text'>
commit fb2c445277e7b0b4ffe10de8114bad4eccaca948 upstream.

If a call to put_user() fails, we failed to
properly free a transaction and send a failed
reply (if necessary).

Signed-off-by: Martijn Coenen &lt;maco@android.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>binder: call poll_wait() unconditionally.</title>
<updated>2017-10-20T10:53:43+00:00</updated>
<author>
<name>Martijn Coenen</name>
<email>maco@android.com</email>
</author>
<published>2017-10-09T12:26:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=66b83a4cdd3b73effdc285d1d66763c69ffe2ee8'/>
<id>urn:sha1:66b83a4cdd3b73effdc285d1d66763c69ffe2ee8</id>
<content type='text'>
Because we're not guaranteed that subsequent calls
to poll() will have a poll_table_struct parameter
with _qproc set. When _qproc is not set, poll_wait()
is a noop, and we won't be woken up correctly.

Signed-off-by: Martijn Coenen &lt;maco@android.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>binder: fix use-after-free in binder_transaction()</title>
<updated>2017-10-04T09:25:10+00:00</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@android.com</email>
</author>
<published>2017-09-29T22:39:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=512cf465ee01eb23936a9e6ed0b6414eccb00853'/>
<id>urn:sha1:512cf465ee01eb23936a9e6ed0b6414eccb00853</id>
<content type='text'>
User-space normally keeps the node alive when creating a transaction
since it has a reference to the target. The local strong ref keeps it
alive if the sending process dies before the target process processes
the transaction. If the source process is malicious or has a reference
counting bug, this can fail.

In this case, when we attempt to decrement the node in the failure
path, the node has already been freed.

This is fixed by taking a tmpref on the node while constructing
the transaction. To avoid re-acquiring the node lock and inner
proc lock to increment the proc's tmpref, a helper is used that
does the ref increments on both the node and proc.

Signed-off-by: Todd Kjos &lt;tkjos@google.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>binder: fix memory corruption in binder_transaction binder</title>
<updated>2017-09-18T14:06:00+00:00</updated>
<author>
<name>Xu YiPing</name>
<email>xuyiping@hisilicon.com</email>
</author>
<published>2017-09-05T17:21:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d53bebdf4d779497b29e1aad26e19cac1d446f42'/>
<id>urn:sha1:d53bebdf4d779497b29e1aad26e19cac1d446f42</id>
<content type='text'>
commit 7a4408c6bd3e ("binder: make sure accesses to proc/thread are
safe") made a change to enqueue tcomplete to thread-&gt;todo before
enqueuing the transaction. However, in err_dead_proc_or_thread case,
the tcomplete is directly freed, without dequeued. It may cause the
thread-&gt;todo list to be corrupted.

So, dequeue it before freeing.

Fixes: 7a4408c6bd3e ("binder: make sure accesses to proc/thread are safe")
Signed-off-by: Xu YiPing &lt;xuyiping@hisilicon.com&gt;
Signed-off-by: Todd Kjos &lt;tkjos@google.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
