* [PATCH 2/2] rust_binder: reject mremap()
[not found] <20260831224145.169403-1-cmllamas@google.com>
@ 2026-08-31 22:41 ` Carlos Llamas
2026-09-01 2:37 ` Carlos Llamas
0 siblings, 1 reply; 2+ messages in thread
From: Carlos Llamas @ 2026-08-31 22:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Christian Brauner, Carlos Llamas, Alice Ryhl, Benno Lossin,
Gary Guo
Cc: kernel-team, linux-kernel, Suren Baghdasaryan, stable, Sashiko,
open list:RUST [PIN-INIT]:Keyword:bpin-initb|pin_initb|PinInit
Binder does not support mremap() as it caches the mapping address in
Inner::vma_addr. Moving the mapping breaks the IPC communication for the
process and can temporarily leak pages during a shrinker reclaim.
Fix this by explicitly rejecting the .mremap() operation.
Cc: stable@vger.kernel.org
Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260813193433.3318288-1-surenb%40google.com?part=2
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
drivers/android/binder/page_range.rs | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/android/binder/page_range.rs b/drivers/android/binder/page_range.rs
index 52ffbf3504e7..411efcc2116f 100644
--- a/drivers/android/binder/page_range.rs
+++ b/drivers/android/binder/page_range.rs
@@ -24,7 +24,7 @@
use kernel::{
bindings,
error::Result,
- ffi::{c_ulong, c_void},
+ ffi::{c_int, c_ulong, c_void},
mm::{virt, Mm, MmWithUser},
new_mutex, new_spinlock,
page::{Page, PAGE_SHIFT, PAGE_SIZE},
@@ -144,8 +144,17 @@ pub(crate) struct ShrinkablePageRange {
_pin: PhantomPinned,
}
-// We do not define any ops. For now, used only to check identity of vmas.
-static BINDER_VM_OPS: AssertSync<bindings::vm_operations_struct> = AssertSync(pin_init::zeroed());
+unsafe extern "C" fn binder_mremap(_: *mut bindings::vm_area_struct) -> c_int {
+ EINVAL.to_errno()
+}
+
+static BINDER_VM_OPS: AssertSync<bindings::vm_operations_struct> = {
+ let ops = bindings::vm_operations_struct {
+ mremap: Some(binder_mremap),
+ ..pin_init::zeroed()
+ };
+ AssertSync(ops)
+};
// To ensure that we do not accidentally install pages into or zap pages from the wrong vma, we
// check its vm_ops and private data before using it.
--
2.55.0.897.gb25b4bd76c-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] rust_binder: reject mremap()
2026-08-31 22:41 ` [PATCH 2/2] rust_binder: reject mremap() Carlos Llamas
@ 2026-09-01 2:37 ` Carlos Llamas
0 siblings, 0 replies; 2+ messages in thread
From: Carlos Llamas @ 2026-09-01 2:37 UTC (permalink / raw)
To: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Christian Brauner, Alice Ryhl, Benno Lossin, Gary Guo
Cc: kernel-team, linux-kernel, Suren Baghdasaryan, stable, Sashiko,
open list:RUST [PIN-INIT]:Keyword:bpin-initb|pin_initb|PinInit
On Mon, Aug 31, 2026 at 10:41:43PM +0000, Carlos Llamas wrote:
> Binder does not support mremap() as it caches the mapping address in
> Inner::vma_addr. Moving the mapping breaks the IPC communication for the
> process and can temporarily leak pages during a shrinker reclaim.
>
> Fix this by explicitly rejecting the .mremap() operation.
>
> Cc: stable@vger.kernel.org
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260813193433.3318288-1-surenb%40google.com?part=2
> Signed-off-by: Carlos Llamas <cmllamas@google.com>
> ---
Sashiko had a couple of good points that I'll be addressing in v2.
--
Carlos Llamas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-01 2:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260831224145.169403-1-cmllamas@google.com>
2026-08-31 22:41 ` [PATCH 2/2] rust_binder: reject mremap() Carlos Llamas
2026-09-01 2:37 ` Carlos Llamas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox