[PATCH v4 2/7] rust_binder: set VM_DONTEXPAND

From: Carlos Llamas

Date: Tue Sep 01 2026 - 16:54:01 EST


Binder does not support expanding VMAs. It uses the original size to
create its RangeAllocator during mmap() and expanding the VMA would only
result in a wasted virtual range. Set the VM_DONTEXPAND flag to prevent
the vma from being expanded via mremap().

Cc: stable@xxxxxxxxxxxxxxx
Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://sashiko.dev/#/patchset/20260831224145.169403-1-cmllamas@xxxxxxxxxx?part=1
Signed-off-by: Carlos Llamas <cmllamas@xxxxxxxxxx>
---
drivers/android/binder/process.rs | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index 5372bfbd93b3..9038f3d13cfd 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -1786,6 +1786,7 @@ pub(crate) fn mmap(
vma.try_clear_maywrite().map_err(|_| EPERM)?;
vma.set_dontcopy();
vma.set_mixedmap();
+ vma.set_dontexpand();

// TODO: Set ops. We need to learn when the user unmaps so that we can stop using it.
this.create_mapping(vma)
--
2.55.0.966.g6673acef38-goog