From: Hui Peng <benquike@gmail.com>
To: gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com,
brauner@kernel.org, cmllamas@google.com, aliceryhl@google.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] binder: forbid VMA splitting and mremap on binder mmap
Date: Sat, 19 Sep 2026 21:36:53 +0000 [thread overview]
Message-ID: <20260919213653.3317260-1-benquike@gmail.com> (raw)
`binder_vm_ops` does not implement `.may_split` or `.mremap`, and
`binder_vma_close()` unconditionally calls
`binder_alloc_vma_close(&proc->alloc)` (which sets `alloc->vma = NULL`).
If userspace calls `munmap()` on a sub-range of the binder mapping (or
`mremap()` to move/split a sub-range), the VMA is split into two VMAs
sharing the same `binder_proc`, and `binder_vma_close()` runs on the
unmapped half and clears `alloc->vma = NULL` while the remaining VMA
stays mapped in the process's address space, desynchronizing
`alloc->vma` from the remaining VMA.
Implement `.may_split` and `.mremap` returning `-EINVAL` in
`binder_vm_ops` and check `vma->vm_start == proc->alloc.vm_start` in
`binder_vma_close()`.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
drivers/android/binder.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 8f2ef1bd539f..1c7218e599a1 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -6023,9 +6058,21 @@ static void binder_vma_close(struct vm_area_struct *vma)
proc->pid, vma->vm_start, vma->vm_end,
(vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
(unsigned long)pgprot_val(vma->vm_page_prot));
+ if (vma->vm_start != proc->alloc.vm_start)
+ return;
binder_alloc_vma_close(&proc->alloc);
}
+static int binder_may_split(struct vm_area_struct *vma, unsigned long addr)
+{
+ return -EINVAL;
+}
+
+static int binder_mremap(struct vm_area_struct *vma)
+{
+ return -EINVAL;
+}
+
VISIBLE_IF_KUNIT vm_fault_t binder_vm_fault(struct vm_fault *vmf)
{
return VM_FAULT_SIGBUS;
@@ -6035,6 +6082,8 @@ EXPORT_SYMBOL_IF_KUNIT(binder_vm_fault);
static const struct vm_operations_struct binder_vm_ops = {
.open = binder_vma_open,
.close = binder_vma_close,
+ .may_split = binder_may_split,
+ .mremap = binder_mremap,
.fault = binder_vm_fault,
};
reply other threads:[~2026-09-19 21:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260919213653.3317260-1-benquike@gmail.com \
--to=benquike@gmail.com \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tkjos@android.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®