<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/android/binder.c, branch linux-4.20.y</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=linux-4.20.y</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=linux-4.20.y'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2019-03-10T06:10:09+00:00</updated>
<entry>
<title>binder: create node flag to request sender's security context</title>
<updated>2019-03-10T06:10:09+00:00</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@android.com</email>
</author>
<published>2019-01-14T17:10:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=569666a370d493d75325f6a7b0dd70e90e6f7188'/>
<id>urn:sha1:569666a370d493d75325f6a7b0dd70e90e6f7188</id>
<content type='text'>
commit ec74136ded792deed80780a2f8baf3521eeb72f9 upstream.

To allow servers to verify client identity, allow a node
flag to be set that causes the sender's security context
to be delivered with the transaction. The BR_TRANSACTION
command is extended in BR_TRANSACTION_SEC_CTX to
contain a pointer to the security context string.

Signed-off-by: Todd Kjos &lt;tkjos@google.com&gt;
Reviewed-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>binder: fix use-after-free due to ksys_close() during fdget()</title>
<updated>2019-01-09T16:45:59+00:00</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@android.com</email>
</author>
<published>2018-12-14T23:58:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=27564d8d5d12d2ff197055346069c6bdbe08a8c2'/>
<id>urn:sha1:27564d8d5d12d2ff197055346069c6bdbe08a8c2</id>
<content type='text'>
commit 80cd795630d6526ba729a089a435bf74a57af927 upstream.

44d8047f1d8 ("binder: use standard functions to allocate fds")
exposed a pre-existing issue in the binder driver.

fdget() is used in ksys_ioctl() as a performance optimization.
One of the rules associated with fdget() is that ksys_close() must
not be called between the fdget() and the fdput(). There is a case
where this requirement is not met in the binder driver which results
in the reference count dropping to 0 when the device is still in
use. This can result in use-after-free or other issues.

If userpace has passed a file-descriptor for the binder driver using
a BINDER_TYPE_FDA object, then kys_close() is called on it when
handling a binder_ioctl(BC_FREE_BUFFER) command. This violates
the assumptions for using fdget().

The problem is fixed by deferring the close using task_work_add(). A
new variant of __close_fd() was created that returns a struct file
with a reference. The fput() is deferred instead of using ksys_close().

Fixes: 44d8047f1d87a ("binder: use standard functions to allocate fds")
Suggested-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
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 race that allows malicious free of live buffer</title>
<updated>2018-11-26T19:01:47+00:00</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@android.com</email>
</author>
<published>2018-11-06T23:55:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7bada55ab50697861eee6bb7d60b41e68a961a9c'/>
<id>urn:sha1:7bada55ab50697861eee6bb7d60b41e68a961a9c</id>
<content type='text'>
Malicious code can attempt to free buffers using the BC_FREE_BUFFER
ioctl to binder. There are protections against a user freeing a buffer
while in use by the kernel, however there was a window where
BC_FREE_BUFFER could be used to free a recently allocated buffer that
was not completely initialized. This resulted in a use-after-free
detected by KASAN with a malicious test program.

This window is closed by setting the buffer's allow_user_free attribute
to 0 when the buffer is allocated or when the user has previously freed
it instead of waiting for the caller to set it. The problem was that
when the struct buffer was recycled, allow_user_free was stale and set
to 1 allowing a free to go through.

Signed-off-by: Todd Kjos &lt;tkjos@google.com&gt;
Acked-by: Arve Hjønnevåg &lt;arve@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>binder: make symbol 'binder_free_buf' static</title>
<updated>2018-10-02T22:53:53+00:00</updated>
<author>
<name>Wei Yongjun</name>
<email>weiyongjun1@huawei.com</email>
</author>
<published>2018-09-25T14:30:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f4608ce917d6f50824f4c609d52a3c8900c59164'/>
<id>urn:sha1:f4608ce917d6f50824f4c609d52a3c8900c59164</id>
<content type='text'>
Fixes the following sparse warning:

drivers/android/binder.c:3312:1: warning:
 symbol 'binder_free_buf' was not declared. Should it be static?

Signed-off-by: Wei Yongjun &lt;weiyongjun1@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>binder: Add BINDER_GET_NODE_INFO_FOR_REF ioctl.</title>
<updated>2018-09-14T13:22:48+00:00</updated>
<author>
<name>Martijn Coenen</name>
<email>maco@android.com</email>
</author>
<published>2018-09-07T13:38:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b7e6a8961b5d6dd3fc535970e65d497d868bb49f'/>
<id>urn:sha1:b7e6a8961b5d6dd3fc535970e65d497d868bb49f</id>
<content type='text'>
This allows the context manager to retrieve information about nodes
that it holds a reference to, such as the current number of
references to those nodes.

Such information can for example be used to determine whether the
servicemanager is the only process holding a reference to a node.
This information can then be passed on to the process holding the
node, which can in turn decide whether it wants to shut down to
reduce resource usage.

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>android: binder: use kstrdup instead of open-coding it</title>
<updated>2018-09-14T13:22:36+00:00</updated>
<author>
<name>Rasmus Villemoes</name>
<email>linux@rasmusvillemoes.dk</email>
</author>
<published>2018-09-07T08:01:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6b6642dadd685af885367d6e30f18553e2a23b22'/>
<id>urn:sha1:6b6642dadd685af885367d6e30f18553e2a23b22</id>
<content type='text'>
Signed-off-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>binder: use standard functions to allocate fds</title>
<updated>2018-09-14T13:22:36+00:00</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@android.com</email>
</author>
<published>2018-08-28T20:46:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=44d8047f1d87adc2fd7eccc88533794f6d88c15e'/>
<id>urn:sha1:44d8047f1d87adc2fd7eccc88533794f6d88c15e</id>
<content type='text'>
Binder uses internal fs interfaces to allocate and install fds:

__alloc_fd
__fd_install
__close_fd
get_files_struct
put_files_struct

These were used to support the passing of fds between processes
as part of a transaction. The actual allocation and installation
of the fds in the target process was handled by the sending
process so the standard functions, alloc_fd() and fd_install()
which assume task==current couldn't be used.

This patch refactors this mechanism so that the fds are
allocated and installed by the target process allowing the
standard functions to be used.

The sender now creates a list of fd fixups that contains the
struct *file and the address to fixup with the new fd once
it is allocated. This list is processed by the target process
when the transaction is dequeued.

A new error case is introduced by this change. If an async
transaction with file descriptors cannot allocate new
fds in the target (probably due to out of file descriptors),
the transaction is discarded with a log message. In the old
implementation this would have been detected in the sender
context and failed prior to sending.

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: no outgoing transaction when thread todo has transaction</title>
<updated>2018-09-14T13:22:36+00:00</updated>
<author>
<name>Sherry Yang</name>
<email>sherryy@android.com</email>
</author>
<published>2018-08-14T00:28:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=44b73962cb25f1c8170ea695c4564b05a75e1fd4'/>
<id>urn:sha1:44b73962cb25f1c8170ea695c4564b05a75e1fd4</id>
<content type='text'>
When a process dies, failed reply is sent to the sender of any transaction
queued on a dead thread's todo list. The sender asserts that the
received failed reply corresponds to the head of the transaction stack.
This assert can fail if the dead thread is allowed to send outgoing
transactions when there is already a transaction on its todo list,
because this new transaction can end up on the transaction stack of the
original sender. The following steps illustrate how this assertion can
fail.

1. Thread1 sends txn19 to Thread2
   (T1-&gt;transaction_stack=txn19, T2-&gt;todo+=txn19)
2. Without processing todo list, Thread2 sends txn20 to Thread1
   (T1-&gt;todo+=txn20, T2-&gt;transaction_stack=txn20)
3. T1 processes txn20 on its todo list
   (T1-&gt;transaction_stack=txn20-&gt;txn19, T1-&gt;todo=&lt;empty&gt;)
4. T2 dies, T2-&gt;todo cleanup attempts to send failed reply for txn19, but
   T1-&gt;transaction_stack points to txn20 -- assertion failes

Step 2. is the incorrect behavior. When there is a transaction on a
thread's todo list, this thread should not be able to send any outgoing
synchronous transactions. Only the head of the todo list needs to be
checked because only threads that are waiting for proc work can directly
receive work from another thread, and no work is allowed to be queued
on such a thread without waking up the thread. This patch also enforces
that a thread is not waiting for proc work when a work is directly
enqueued to its todo list.

Acked-by: Arve Hjønnevåg &lt;arve@android.com&gt;
Signed-off-by: Sherry Yang &lt;sherryy@android.com&gt;
Reviewed-by: Martijn Coenen &lt;maco@android.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>android: binder: Rate-limit debug and userspace triggered err msgs</title>
<updated>2018-08-08T09:05:47+00:00</updated>
<author>
<name>Sherry Yang</name>
<email>sherryy@android.com</email>
</author>
<published>2018-08-07T19:57:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=128f38041035001276e964cda1cf951f218d965d'/>
<id>urn:sha1:128f38041035001276e964cda1cf951f218d965d</id>
<content type='text'>
Use rate-limited debug messages where userspace can trigger
excessive log spams.

Acked-by: Arve Hjønnevåg &lt;arve@android.com&gt;
Signed-off-by: Sherry Yang &lt;sherryy@android.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>android: binder: Include asm/cacheflush.h after linux/ include files</title>
<updated>2018-07-24T12:23:00+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2018-07-23T21:41:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f371a7c17aaa47dd7aedc89ef3cd1d5638c03f5e'/>
<id>urn:sha1:f371a7c17aaa47dd7aedc89ef3cd1d5638c03f5e</id>
<content type='text'>
If asm/cacheflush.h is included first, the following build warnings are
seen with sparc32 builds.

In file included from arch/sparc/include/asm/cacheflush.h:11:0,
        from drivers/android/binder.c:54:
arch/sparc/include/asm/cacheflush_32.h:40:37: warning:
	'struct page' declared inside parameter list will not be visible
	outside of this definition or declaration

Moving the asm/ include after linux/ includes solves the problem.

Suggested-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
