* [PATCH 1/2] binder: reject mremap()
@ 2026-08-31 22:41 Carlos Llamas
2026-08-31 22:41 ` [PATCH 2/2] rust_binder: " Carlos Llamas
0 siblings, 1 reply; 3+ 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
Cc: kernel-team, linux-kernel, Suren Baghdasaryan, stable, Sashiko
Binder does not support mremap() as it caches the mapping address in
alloc->vm_start. 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: 457b9a6f09f0 ("Staging: android: add 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.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 8f2ef1bd539f..6c12e502740f 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -6032,10 +6032,16 @@ VISIBLE_IF_KUNIT vm_fault_t binder_vm_fault(struct vm_fault *vmf)
}
EXPORT_SYMBOL_IF_KUNIT(binder_vm_fault);
+static int binder_mremap(struct vm_area_struct *vma)
+{
+ return -EINVAL;
+}
+
static const struct vm_operations_struct binder_vm_ops = {
.open = binder_vma_open,
.close = binder_vma_close,
.fault = binder_vm_fault,
+ .mremap = binder_mremap,
};
static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
--
2.55.0.897.gb25b4bd76c-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] rust_binder: reject mremap()
2026-08-31 22:41 [PATCH 1/2] binder: reject mremap() Carlos Llamas
@ 2026-08-31 22:41 ` Carlos Llamas
2026-09-01 2:37 ` Carlos Llamas
0 siblings, 1 reply; 3+ 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 [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] rust_binder: reject mremap()
2026-08-31 22:41 ` [PATCH 2/2] rust_binder: " Carlos Llamas
@ 2026-09-01 2:37 ` Carlos Llamas
0 siblings, 0 replies; 3+ 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] 3+ messages in thread
end of thread, other threads:[~2026-09-01 2:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-31 22:41 [PATCH 1/2] binder: reject mremap() Carlos Llamas
2026-08-31 22:41 ` [PATCH 2/2] rust_binder: " 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
all inboxes | Powered by JetHome®