CVE-2022-50128: android: binder: stop saving a pointer to the VMA
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
android: binder: stop saving a pointer to the VMA
Do not record a pointer to a VMA outside of the mmap_lock for later use. This is unsafe and there are a number of failure paths *after* the recorded VMA pointer may be freed during setup. There is no callback to the driver to clear the saved pointer from generic mm code. Furthermore, the VMA pointer may become stale if any number of VMA operations end up freeing the VMA so saving it was fragile to being with.
Instead, change the binder_alloc struct to record the start address of the VMA and use vma_lookup() to get the vma when needed. Add lockdep mmap_lock checks on updates to the vma pointer to ensure the lock is held and depend on that lock for synchronization of readers and writers - which was already the case anyways, so the smp_wmb()/smp_rmb() was not necessary.
[[email protected]: fix drivers/android/binder_alloc_selftest.c]
The Linux kernel CVE team has assigned CVE-2022-50128 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.19 with commit da1b9564e85b1d7baf66cbfabcab27e183a1db63 and fixed in 5.15.61 with commit 622ef885a89ad04cfb76ee478fb44f051125d1f1 Issue introduced in 4.19 with commit da1b9564e85b1d7baf66cbfabcab27e183a1db63 and fixed in 5.18.18 with commit 925e6b6f82c9c80ab3c17acbde8d16f349da7d26 Issue introduced in 4.19 with commit da1b9564e85b1d7baf66cbfabcab27e183a1db63 and fixed in 5.19.2 with commit 1ec3f76a436d750fd5023caec5da0494fc2870d2 Issue introduced in 4.19 with commit da1b9564e85b1d7baf66cbfabcab27e183a1db63 and fixed in 6.0 with commit a43cfc87caaf46710c8027a8c23b8a55f1078f19 Issue introduced in 4.14.71 with commit 492519107c9d5ecfe3298586e3f5a33ac968b62c Issue introduced in 4.18.9 with commit 67b9876482580914cfd99d49b54c9b0ed88581a6
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2022-50128
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/android/binder_alloc.c
drivers/android/binder_alloc.h
drivers/android/binder_alloc_selftest.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/622ef885a89ad04cfb76ee478fb44f051125d1f1 https://git.kernel.org/stable/c/925e6b6f82c9c80ab3c17acbde8d16f349da7d26 https://git.kernel.org/stable/c/1ec3f76a436d750fd5023caec5da0494fc2870d2 https://git.kernel.org/stable/c/a43cfc87caaf46710c8027a8c23b8a55f1078f19