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 Closes: https://lore.kernel.org/r/20261201.110643.1613182710699989646.tomo@flapping.org Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/rust-for-linux/20261130230914.739923-1-tomo@flapping.org/ [1] Signed-off-by: Alice Ryhl --- 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