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

From: Ivan Tverdokhleb

Date: Tue Dec 01 2026 - 05:35:35 EST


Hi Alice,

I applied your patch on top of Fujita's warn_on_once series and build-tested
it for x86_64 with CONFIG_RUST=y and CONFIG_DEBUG_VM=y. It builds cleanly.
I also ran the rust_kernel_bug KUnit tests, and both subtests passed
(test_warn_on and test_warn_on_once).

I will send v4 for zap_vma_range() once both your patch and Fujita's series
land in linux-next.

Tested-by: Ivan Tverdokhleb <mbkchelofficialdev@xxxxxxxxx>

Thanks,
Ivan

вт, 1 дек. 2026 г. в 12:19, Alice Ryhl <aliceryhl@xxxxxxxxxx>:
>
> 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>
>