* [PATCH v4 4/7] rust_binder: forbid vma splitting
[not found] <20260901205250.1638304-1-cmllamas@google.com>
@ 2026-09-01 20:52 ` Carlos Llamas
2026-09-01 20:52 ` [PATCH v4 7/7] rust_binder: reject mremap() Carlos Llamas
1 sibling, 0 replies; 2+ messages in thread
From: Carlos Llamas @ 2026-09-01 20:52 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 splitting its mappings. Allowing so, leads to
potential attacks that stem from a partial munmap(), such as closing the
tail range and replacing it with a new mapping.
Close the loophole by explicitly rejecting vma splitting.
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/20260901163521.1355535-1-cmllamas@google.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..d260b009c184 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_vma_may_split(_: *mut bindings::vm_area_struct, _: c_ulong) -> c_int {
+ EINVAL.to_errno()
+}
+
+static BINDER_VM_OPS: AssertSync<bindings::vm_operations_struct> = {
+ let ops = bindings::vm_operations_struct {
+ may_split: Some(binder_vma_may_split),
+ ..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.966.g6673acef38-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v4 7/7] rust_binder: reject mremap()
[not found] <20260901205250.1638304-1-cmllamas@google.com>
2026-09-01 20:52 ` [PATCH v4 4/7] rust_binder: forbid vma splitting Carlos Llamas
@ 2026-09-01 20:52 ` Carlos Llamas
1 sibling, 0 replies; 2+ messages in thread
From: Carlos Llamas @ 2026-09-01 20:52 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@google.com?part=2
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
drivers/android/binder/page_range.rs | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/android/binder/page_range.rs b/drivers/android/binder/page_range.rs
index d260b009c184..c6247ba03313 100644
--- a/drivers/android/binder/page_range.rs
+++ b/drivers/android/binder/page_range.rs
@@ -148,9 +148,14 @@ pub(crate) struct ShrinkablePageRange {
EINVAL.to_errno()
}
+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 {
may_split: Some(binder_vma_may_split),
+ mremap: Some(binder_mremap),
..pin_init::zeroed()
};
AssertSync(ops)
--
2.55.0.966.g6673acef38-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-01 20:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260901205250.1638304-1-cmllamas@google.com>
2026-09-01 20:52 ` [PATCH v4 4/7] rust_binder: forbid vma splitting Carlos Llamas
2026-09-01 20:52 ` [PATCH v4 7/7] rust_binder: reject mremap() Carlos Llamas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox