title: binder: fix race between mmput() and do_exit()
description: In the Linux kernel, the following vulnerability has been resolved:
binder: fix race between mmput() and do_exit()
Task A calls binder_update_page_range() to allocate and insert pages on
a remote address space from Task B. For this, Task A pins the remote mm
via mmget_not_zero() first. This can race with Task B do_exit() and the
final mmput() refcount decrement will come from Task A.
Task A            | Task B
------------------+------------------
mmget_not_zero()  |
|  do_exit()
|    exit_mm()
|      mmput()
mmput()           |
exit_mmap()     |
remove_vma()  |
fput()      |
In this case, the work of ____fput() from Task B is queued up in Task A
as TWA_RESUME. So in theory, Task A returns to userspace and the cleanup
work gets executed. However, Task A instead sleep, waiting for a reply
from Task B that never comes (it's dead).
This means the binder_deferred_release() is blocked until an unrelated
binder event forces Task A to go back to userspace. All the associated
death notifications will also be delayed until then.
In order to fix this use mmput_async() that will schedule the work in
the corresponding mm->async_put_work WQ instead of Task A.
affected:
{
product: Linux
vendor: Linux
defaultStatus: unaffected
repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
versions:
version: 457b9a6f09f0, lessThan: 95b1d336b064, status: affected, versionType: git
version: 457b9a6f09f0, lessThan: 252a2a5569eb, status: affected, versionType: git
version: 457b9a6f09f0, lessThan: 7e7a0d86542b, status: affected, versionType: git
version: 457b9a6f09f0, lessThan: 98fee5bee97a, status: affected, versionType: git
version: 457b9a6f09f0, lessThan: 6696f76c32ff, status: affected, versionType: git
version: 457b9a6f09f0, lessThan: 67f16bf2cc16, status: affected, versionType: git
version: 457b9a6f09f0, lessThan: 77d210e8db4d, status: affected, versionType: git
version: 457b9a6f09f0, lessThan: 9a9ab0d96362, status: affected, versionType: git
}
{
product: Linux
vendor: Linux
defaultStatus: affected
repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
versions:
version: 2.6.29, status: affected
version: 0, lessThan: 2.6.29, status: unaffected, versionType: custom
version: 4.19.306, lessThanOrEqual: 4.19.*, status: unaffected, versionType: custom
version: 5.4.268, lessThanOrEqual: 5.4.*, status: unaffected, versionType: custom
version: 5.10.209, lessThanOrEqual: 5.10.*, status: unaffected, versionType: custom
version: 5.15.148, lessThanOrEqual: 5.15.*, status: unaffected, versionType: custom
version: 6.1.75, lessThanOrEqual: 6.1.*, status: unaffected, versionType: custom
version: 6.6.14, lessThanOrEqual: 6.6.*, status: unaffected, versionType: custom
version: 6.7.2, lessThanOrEqual: 6.7.*, status: unaffected, versionType: custom
version: 6.8, lessThanOrEqual: *, status: unaffected, versionType: original_commit_for_fix
}
