Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35CDD34B414 for ; Wed, 24 Dec 2025 13:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766581936; cv=none; b=kCzJ9w5OC9Db6GMLaNkeaxkg5PSS+Ksrbjdn0y084h73yWP4ZUbCuowxZDrTgKrG3ICiccR5fUydBdc4n6PXXY7fXE/lb+hM7JdJDIZZN52aI118/dL9WAkovdqcxq8XMlIvyhcIYSr86ZrG0HvlnIX5EeSMN3ZbmpxwBXCUuNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766581936; c=relaxed/simple; bh=Pd5T12xupWVQTK+28NpyrGFcd17Fz1WXaHZV+Ghu2n8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uJeufoaU0ACGHjlQWywelEHolPd2Sf8QXqXCnT46QqUVoKRQBnvsEL4mnununkk6cpAdLC/q1/yScpZcU9luXUhinIkZaKFEw9n5qbXO4rZOa1kneC26eZHUsTYdOvtXCAGoSxeXXRO96eqzv7YYTR6E2AIN1yQnRSrBskt9VAE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AykDZUwK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AykDZUwK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1A5EC4CEFB; Wed, 24 Dec 2025 13:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1766581936; bh=Pd5T12xupWVQTK+28NpyrGFcd17Fz1WXaHZV+Ghu2n8=; h=From:To:Cc:Subject:Date:Reply-To:From; b=AykDZUwKzIp3ozR6cbDrowawdxD/6D4DKKk5PxYh74g6rFauNy/IMZsj2tdWpXZw8 5iC6Ds/JYy9QpN0XvqVFYpTPnZUpbJv8LB8FOlvWYzuF9m1rPnNMXHGFpmr+1TQTIt FrJO+H7wRU0B1pt4wFtLlx/lvHlJq/LC6gw/ZLvk= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-54157: binder: fix UAF of alloc->vma in race with munmap() Date: Wed, 24 Dec 2025 14:07:54 +0100 Message-ID: <2025122428-CVE-2023-54157-c0c5@gregkh> X-Mailer: git-send-email 2.52.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5497; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=C5ld+pNcu7Kd05ARVjjfBmasAhRbsAbHANtwjAzQSBQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDJneT0NmTawKMVN7qLCytu6kaeMHxd/u7Je5DWvuFO1Wu aE+t/lNRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEzkzzuGBbdMrvkvF3L6033j ZcSnk0FpodekGBnmCh42P9RquVzByobl9fzTtivqXC2uAQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: binder: fix UAF of alloc->vma in race with munmap() [ cmllamas: clean forward port from commit 015ac18be7de ("binder: fix UAF of alloc->vma in race with munmap()") in 5.10 stable. It is needed in mainline after the revert of commit a43cfc87caaf ("android: binder: stop saving a pointer to the VMA") as pointed out by Liam. The commit log and tags have been tweaked to reflect this. ] In commit 720c24192404 ("ANDROID: binder: change down_write to down_read") binder assumed the mmap read lock is sufficient to protect alloc->vma inside binder_update_page_range(). This used to be accurate until commit dd2283f2605e ("mm: mmap: zap pages with read mmap_sem in munmap"), which now downgrades the mmap_lock after detaching the vma from the rbtree in munmap(). Then it proceeds to teardown and free the vma with only the read lock held. This means that accesses to alloc->vma in binder_update_page_range() now will race with vm_area_free() in munmap() and can cause a UAF as shown in the following KASAN trace: ================================================================== BUG: KASAN: use-after-free in vm_insert_page+0x7c/0x1f0 Read of size 8 at addr ffff16204ad00600 by task server/558 CPU: 3 PID: 558 Comm: server Not tainted 5.10.150-00001-gdc8dcf942daa #1 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x0/0x2a0 show_stack+0x18/0x2c dump_stack+0xf8/0x164 print_address_description.constprop.0+0x9c/0x538 kasan_report+0x120/0x200 __asan_load8+0xa0/0xc4 vm_insert_page+0x7c/0x1f0 binder_update_page_range+0x278/0x50c binder_alloc_new_buf+0x3f0/0xba0 binder_transaction+0x64c/0x3040 binder_thread_write+0x924/0x2020 binder_ioctl+0x1610/0x2e5c __arm64_sys_ioctl+0xd4/0x120 el0_svc_common.constprop.0+0xac/0x270 do_el0_svc+0x38/0xa0 el0_svc+0x1c/0x2c el0_sync_handler+0xe8/0x114 el0_sync+0x180/0x1c0 Allocated by task 559: kasan_save_stack+0x38/0x6c __kasan_kmalloc.constprop.0+0xe4/0xf0 kasan_slab_alloc+0x18/0x2c kmem_cache_alloc+0x1b0/0x2d0 vm_area_alloc+0x28/0x94 mmap_region+0x378/0x920 do_mmap+0x3f0/0x600 vm_mmap_pgoff+0x150/0x17c ksys_mmap_pgoff+0x284/0x2dc __arm64_sys_mmap+0x84/0xa4 el0_svc_common.constprop.0+0xac/0x270 do_el0_svc+0x38/0xa0 el0_svc+0x1c/0x2c el0_sync_handler+0xe8/0x114 el0_sync+0x180/0x1c0 Freed by task 560: kasan_save_stack+0x38/0x6c kasan_set_track+0x28/0x40 kasan_set_free_info+0x24/0x4c __kasan_slab_free+0x100/0x164 kasan_slab_free+0x14/0x20 kmem_cache_free+0xc4/0x34c vm_area_free+0x1c/0x2c remove_vma+0x7c/0x94 __do_munmap+0x358/0x710 __vm_munmap+0xbc/0x130 __arm64_sys_munmap+0x4c/0x64 el0_svc_common.constprop.0+0xac/0x270 do_el0_svc+0x38/0xa0 el0_svc+0x1c/0x2c el0_sync_handler+0xe8/0x114 el0_sync+0x180/0x1c0 [...] ================================================================== To prevent the race above, revert back to taking the mmap write lock inside binder_update_page_range(). One might expect an increase of mmap lock contention. However, binder already serializes these calls via top level alloc->mutex. Also, there was no performance impact shown when running the binder benchmark tests. The Linux kernel CVE team has assigned CVE-2023-54157 to this issue. Affected and fixed versions =========================== Issue introduced in 4.20 with commit dd2283f2605e3b3e9c61bcae844b34f2afa4813f and fixed in 5.15.115 with commit 1bb8a65190d45cd5c7dbc85e29b9102110cd6be6 Issue introduced in 4.20 with commit dd2283f2605e3b3e9c61bcae844b34f2afa4813f and fixed in 6.1.31 with commit 931ea1ed31be939c1efdbc49bc66d2a45684f9b4 Issue introduced in 4.20 with commit dd2283f2605e3b3e9c61bcae844b34f2afa4813f and fixed in 6.3.5 with commit ca0cc0a9c6e56c699e2acbb93d8024523021f3c3 Issue introduced in 4.20 with commit dd2283f2605e3b3e9c61bcae844b34f2afa4813f and fixed in 6.4 with commit d1d8875c8c13517f6fd1ff8d4d3e1ac366a17e07 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-2023-54157 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 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/1bb8a65190d45cd5c7dbc85e29b9102110cd6be6 https://git.kernel.org/stable/c/931ea1ed31be939c1efdbc49bc66d2a45684f9b4 https://git.kernel.org/stable/c/ca0cc0a9c6e56c699e2acbb93d8024523021f3c3 https://git.kernel.org/stable/c/d1d8875c8c13517f6fd1ff8d4d3e1ac366a17e07