<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/android, branch v5.9.8</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.9.8</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.9.8'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2020-10-29T09:11:16Z</updated>
<entry>
<title>binder: Remove bogus warning on failed same-process transaction</title>
<updated>2020-10-29T09:11:16Z</updated>
<author>
<name>Jann Horn</name>
<email>jannh@google.com</email>
</author>
<published>2020-08-06T16:53:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e18e0361124d84f899877c6b891e8d7d0a20a1ff'/>
<id>urn:sha1:e18e0361124d84f899877c6b891e8d7d0a20a1ff</id>
<content type='text'>
[ Upstream commit e8b8ae7ce32e17a5c29f0289e9e2a39c7dcaa1b8 ]

While binder transactions with the same binder_proc as sender and recipient
are forbidden, transactions with the same task_struct as sender and
recipient are possible (even though currently there is a weird check in
binder_transaction() that rejects them in the target==0 case).
Therefore, task_struct identities can't be used to distinguish whether
the caller is running in the context of the sender or the recipient.

Since I see no easy way to make this WARN_ON() useful and correct, let's
just remove it.

Fixes: 44d8047f1d87 ("binder: use standard functions to allocate fds")
Reported-by: syzbot+e113a0b970b7b3f394ba@syzkaller.appspotmail.com
Acked-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
Acked-by: Todd Kjos &lt;tkjos@google.com&gt;
Signed-off-by: Jann Horn &lt;jannh@google.com&gt;
Link: https://lore.kernel.org/r/20200806165359.2381483-1-jannh@google.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>binder: fix UAF when releasing todo list</title>
<updated>2020-10-29T09:10:52Z</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@google.com</email>
</author>
<published>2020-10-09T23:24:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2144f0b90aeb2ead33d590f2e45f9be185b93009'/>
<id>urn:sha1:2144f0b90aeb2ead33d590f2e45f9be185b93009</id>
<content type='text'>
commit f3277cbfba763cd2826396521b9296de67cf1bbc upstream.

When releasing a thread todo list when tearing down
a binder_proc, the following race was possible which
could result in a use-after-free:

1.  Thread 1: enter binder_release_work from binder_thread_release
2.  Thread 2: binder_update_ref_for_handle() -&gt; binder_dec_node_ilocked()
3.  Thread 2: dec nodeA --&gt; 0 (will free node)
4.  Thread 1: ACQ inner_proc_lock
5.  Thread 2: block on inner_proc_lock
6.  Thread 1: dequeue work (BINDER_WORK_NODE, part of nodeA)
7.  Thread 1: REL inner_proc_lock
8.  Thread 2: ACQ inner_proc_lock
9.  Thread 2: todo list cleanup, but work was already dequeued
10. Thread 2: free node
11. Thread 2: REL inner_proc_lock
12. Thread 1: deref w-&gt;type (UAF)

The problem was that for a BINDER_WORK_NODE, the binder_work element
must not be accessed after releasing the inner_proc_lock while
processing the todo list elements since another thread might be
handling a deref on the node containing the binder_work element
leading to the node being freed.

Signed-off-by: Todd Kjos &lt;tkjos@google.com&gt;
Link: https://lore.kernel.org/r/20201009232455.4054810-1-tkjos@google.com
Cc: &lt;stable@vger.kernel.org&gt; # 4.14, 4.19, 5.4, 5.8
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>drivers: android: Fix the SPDX comment style</title>
<updated>2020-07-29T15:05:44Z</updated>
<author>
<name>Mrinal Pandey</name>
<email>mrinalmni@gmail.com</email>
</author>
<published>2020-07-24T13:14:49Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7e84522cd089c6ef3e6adc7f1c9a5b2f705ccd9b'/>
<id>urn:sha1:7e84522cd089c6ef3e6adc7f1c9a5b2f705ccd9b</id>
<content type='text'>
C source files should have `//` as SPDX comment and not `/**/`. Fix this
by running checkpatch on the file.

Signed-off-by: Mrinal Pandey &lt;mrinalmni@gmail.com&gt;
Link: https://lore.kernel.org/r/20200724131449.zvjutbemg3vqhrzh@mrinalpandey
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>drivers: android: Fix a variable declaration coding style issue</title>
<updated>2020-07-29T15:05:44Z</updated>
<author>
<name>Mrinal Pandey</name>
<email>mrinalmni@gmail.com</email>
</author>
<published>2020-07-24T13:14:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=81195f9689ac16c01c894c756b925e28e546b123'/>
<id>urn:sha1:81195f9689ac16c01c894c756b925e28e546b123</id>
<content type='text'>
Add a blank line after variable declarations as suggested by checkpatch.

Signed-off-by: Mrinal Pandey &lt;mrinalmni@gmail.com&gt;
Link: https://lore.kernel.org/r/20200724131433.stf3ycooogawyzb3@mrinalpandey
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>drivers: android: Remove braces for a single statement if-else block</title>
<updated>2020-07-29T15:05:38Z</updated>
<author>
<name>Mrinal Pandey</name>
<email>mrinalmni@gmail.com</email>
</author>
<published>2020-07-24T13:14:03Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8df5b9492202e9cac9917465e945fcf478d55404'/>
<id>urn:sha1:8df5b9492202e9cac9917465e945fcf478d55404</id>
<content type='text'>
Remove braces for both if and else block as suggested by checkpatch.

Signed-off-by: Mrinal Pandey &lt;mrinalmni@gmail.com&gt;
Link: https://lore.kernel.org/r/20200724131403.dahfhdwa3wirzkxj@mrinalpandey
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>drivers: android: Remove the use of else after return</title>
<updated>2020-07-29T15:05:38Z</updated>
<author>
<name>Mrinal Pandey</name>
<email>mrinalmni@gmail.com</email>
</author>
<published>2020-07-24T13:13:48Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=72b93c79dbbe261371abb1bf3cf7302cfe31e8d9'/>
<id>urn:sha1:72b93c79dbbe261371abb1bf3cf7302cfe31e8d9</id>
<content type='text'>
Remove the unnecessary else branch after return statement as suggested by
checkpatch.

Signed-off-by: Mrinal Pandey &lt;mrinalmni@gmail.com&gt;
Link: https://lore.kernel.org/r/20200724131348.haz4ocxcferdcsgn@mrinalpandey
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>drivers: android: Fix a variable declaration coding style issue</title>
<updated>2020-07-29T15:04:40Z</updated>
<author>
<name>Mrinal Pandey</name>
<email>mrinalmni@gmail.com</email>
</author>
<published>2020-07-24T13:12:54Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4df9772c8489b7d626db0ee307e029aea66db260'/>
<id>urn:sha1:4df9772c8489b7d626db0ee307e029aea66db260</id>
<content type='text'>
Add a blank line after variable declarations as suggested by checkpatch.

Signed-off-by: Mrinal Pandey &lt;mrinalmni@gmail.com&gt;
Link: https://lore.kernel.org/r/20200724131254.qxbvderrws36dzzq@mrinalpandey
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>binder: Prevent context manager from incrementing ref 0</title>
<updated>2020-07-29T15:04:40Z</updated>
<author>
<name>Jann Horn</name>
<email>jannh@google.com</email>
</author>
<published>2020-07-27T12:04:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4b836a1426cb0f1ef2a6e211d7e553221594f8fc'/>
<id>urn:sha1:4b836a1426cb0f1ef2a6e211d7e553221594f8fc</id>
<content type='text'>
Binder is designed such that a binder_proc never has references to
itself. If this rule is violated, memory corruption can occur when a
process sends a transaction to itself; see e.g.
&lt;https://syzkaller.appspot.com/bug?extid=09e05aba06723a94d43d&gt;.

There is a remaining edgecase through which such a transaction-to-self
can still occur from the context of a task with BINDER_SET_CONTEXT_MGR
access:

 - task A opens /dev/binder twice, creating binder_proc instances P1
   and P2
 - P1 becomes context manager
 - P2 calls ACQUIRE on the magic handle 0, allocating index 0 in its
   handle table
 - P1 dies (by closing the /dev/binder fd and waiting a bit)
 - P2 becomes context manager
 - P2 calls ACQUIRE on the magic handle 0, allocating index 1 in its
   handle table
   [this triggers a warning: "binder: 1974:1974 tried to acquire
   reference to desc 0, got 1 instead"]
 - task B opens /dev/binder once, creating binder_proc instance P3
 - P3 calls P2 (via magic handle 0) with (void*)1 as argument (two-way
   transaction)
 - P2 receives the handle and uses it to call P3 (two-way transaction)
 - P3 calls P2 (via magic handle 0) (two-way transaction)
 - P2 calls P2 (via handle 1) (two-way transaction)

And then, if P2 does *NOT* accept the incoming transaction work, but
instead closes the binder fd, we get a crash.

Solve it by preventing the context manager from using ACQUIRE on ref 0.
There shouldn't be any legitimate reason for the context manager to do
that.

Additionally, print a warning if someone manages to find another way to
trigger a transaction-to-self bug in the future.

Cc: stable@vger.kernel.org
Fixes: 457b9a6f09f0 ("Staging: android: add binder driver")
Acked-by: Todd Kjos &lt;tkjos@google.com&gt;
Signed-off-by: Jann Horn &lt;jannh@google.com&gt;
Reviewed-by: Martijn Coenen &lt;maco@android.com&gt;
Link: https://lore.kernel.org/r/20200727120424.1627555-1-jannh@google.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>binder: Don't use mmput() from shrinker function.</title>
<updated>2020-07-23T07:47:12Z</updated>
<author>
<name>Tetsuo Handa</name>
<email>penguin-kernel@i-love.sakura.ne.jp</email>
</author>
<published>2020-07-16T15:12:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f867c771f98891841c217fa8459244ed0dd28921'/>
<id>urn:sha1:f867c771f98891841c217fa8459244ed0dd28921</id>
<content type='text'>
syzbot is reporting that mmput() from shrinker function has a risk of
deadlock [1], for delayed_uprobe_add() from update_ref_ctr() calls
kzalloc(GFP_KERNEL) with delayed_uprobe_lock held, and
uprobe_clear_state() from __mmput() also holds delayed_uprobe_lock.

Commit a1b2289cef92ef0e ("android: binder: drop lru lock in isolate
callback") replaced mmput() with mmput_async() in order to avoid sleeping
with spinlock held. But this patch replaces mmput() with mmput_async() in
order not to start __mmput() from shrinker context.

[1] https://syzkaller.appspot.com/bug?id=bc9e7303f537c41b2b0cc2dfcea3fc42964c2d45

Reported-by: syzbot &lt;syzbot+1068f09c44d151250c33@syzkaller.appspotmail.com&gt;
Reported-by: syzbot &lt;syzbot+e5344baa319c9a96edec@syzkaller.appspotmail.com&gt;
Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Reviewed-by: Michal Hocko &lt;mhocko@suse.com&gt;
Acked-by: Todd Kjos &lt;tkjos@google.com&gt;
Acked-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Link: https://lore.kernel.org/r/4ba9adb2-43f5-2de0-22de-f6075c1fab50@i-love.sakura.ne.jp
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>binder: fix null deref of proc-&gt;context</title>
<updated>2020-06-23T05:54:46Z</updated>
<author>
<name>Todd Kjos</name>
<email>tkjos@google.com</email>
</author>
<published>2020-06-22T20:07:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d35d3660e065b69fdb8bf512f3d899f350afce52'/>
<id>urn:sha1:d35d3660e065b69fdb8bf512f3d899f350afce52</id>
<content type='text'>
The binder driver makes the assumption proc-&gt;context pointer is invariant after
initialization (as documented in the kerneldoc header for struct proc).
However, in commit f0fe2c0f050d ("binder: prevent UAF for binderfs devices II")
proc-&gt;context is set to NULL during binder_deferred_release().

Another proc was in the middle of setting up a transaction to the dying
process and crashed on a NULL pointer deref on "context" which is a local
set to &amp;proc-&gt;context:

    new_ref-&gt;data.desc = (node == context-&gt;binder_context_mgr_node) ? 0 : 1;

Here's the stack:

[ 5237.855435] Call trace:
[ 5237.855441] binder_get_ref_for_node_olocked+0x100/0x2ec
[ 5237.855446] binder_inc_ref_for_node+0x140/0x280
[ 5237.855451] binder_translate_binder+0x1d0/0x388
[ 5237.855456] binder_transaction+0x2228/0x3730
[ 5237.855461] binder_thread_write+0x640/0x25bc
[ 5237.855466] binder_ioctl_write_read+0xb0/0x464
[ 5237.855471] binder_ioctl+0x30c/0x96c
[ 5237.855477] do_vfs_ioctl+0x3e0/0x700
[ 5237.855482] __arm64_sys_ioctl+0x78/0xa4
[ 5237.855488] el0_svc_common+0xb4/0x194
[ 5237.855493] el0_svc_handler+0x74/0x98
[ 5237.855497] el0_svc+0x8/0xc

The fix is to move the kfree of the binder_device to binder_free_proc()
so the binder_device is freed when we know there are no references
remaining on the binder_proc.

Fixes: f0fe2c0f050d ("binder: prevent UAF for binderfs devices II")
Acked-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
Signed-off-by: Todd Kjos &lt;tkjos@google.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Link: https://lore.kernel.org/r/20200622200715.114382-1-tkjos@google.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
