[PATCH] rust_binder: check VMA bounds before calling zap_vma_range()

From: Alice Ryhl

Date: Tue Dec 01 2026 - 05:19:54 EST


If userspace partially unmaps the tail of a binder VMA, the shrinker
still finds the shortened VMA at `vma_addr` and passes an out-of-bounds
`user_page_addr` to zap_vma_range().

Currently this out-of-bounds operation leads to zap_vma_range() printing
a warning and doing nothing. However, this warning has a TODO to replace
it with a WARN_ONCE(), which must not be reachable from userspace.
Another patch series has been posted [1] to fix this TODO, thus, check
that the page falls within the vma before calling zap_vma_range().

Note that Binder doesn't really support remapping or punching holes in
its VMA, so we accept that pages in the VMA aren't reachable for removal
by the shrinker when this occurs. But we must still ensure that it
cannot be used to trigger a WARN_ON() or other bad behavior.

Reported-by: FUJITA Tomonori <tomo@xxxxxxxxxxxx>
Closes: https://lore.kernel.org/r/20261201.110643.1613182710699989646.tomo@xxxxxxxxxxxx
Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Cc: stable@xxxxxxxxxxxxxxx
Link: https://lore.kernel.org/rust-for-linux/20261130230914.739923-1-tomo@xxxxxxxxxxxx/ [1]
Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
---
drivers/android/binder/page_range.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/android/binder/page_range.rs b/drivers/android/binder/page_range.rs
index b0c797523bc2..422ceff7e887 100644
--- a/drivers/android/binder/page_range.rs
+++ b/drivers/android/binder/page_range.rs
@@ -750,7 +750,9 @@ fn drop(self: Pin<&mut Self>) {

if let Some(vma) = check_vma(&vma_read, range_ptr) {
let user_page_addr = vma_addr + (page_index << PAGE_SHIFT);
- vma.zap_vma_range(user_page_addr, PAGE_SIZE);
+ if user_page_addr < vma.end() {
+ vma.zap_vma_range(user_page_addr, PAGE_SIZE);
+ }
}

drop(vma_read);

---
base-commit: 89f33682b2c34b12b3a7a549ba94a808f0c7c98d
change-id: 20261201-binder-vma-lookup-ce9d22eb3dd6

Best regards,
--
Alice Ryhl <aliceryhl@xxxxxxxxxx>