mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust_binder: check VMA bounds before calling zap_vma_range()
@ 2026-12-01 10:19 Alice Ryhl
  2026-12-01 10:35 ` Ivan Tverdokhleb
  2026-12-01 10:46 ` FUJITA Tomonori
  0 siblings, 2 replies; 3+ messages in thread
From: Alice Ryhl @ 2026-12-01 10:19 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Carlos Llamas, FUJITA Tomonori, Ivan Tverdokhleb
  Cc: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, rust-for-linux, linux-kernel,
	stable

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@flapping.org>
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 <aliceryhl@google.com>
---
 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@google.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01 10:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 10:19 [PATCH] rust_binder: check VMA bounds before calling zap_vma_range() Alice Ryhl
2026-12-01 10:35 ` Ivan Tverdokhleb
2026-12-01 10:46 ` FUJITA Tomonori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®