From: Jan Kiszka <jan.kiszka@domain.hid>
To: adeos-main <adeos-main@gna.org>
Subject: [Adeos-main] [PATCH 2/2] ipipe: Pin potential COW pages before applying mprotect changes
Date: Thu, 29 Mar 2012 18:38:39 +0200 [thread overview]
Message-ID: <4F74900F.6030707@domain.hid> (raw)
mprotect may make a region writable that wasn't so far. But non-writable
regions are not subject to COW resolution done via
ipipe_disable_ondemand_mappings. Thus, enabling write may make pages
writable that are not supposed to (e.g. the zero page) as we enforce
write access for writable regions to avoid minor faults.
Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
This applies on core-3.2, but should be backported to maintained
versions as well (just leave out the "__").
mm/mprotect.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 3f234b3..9981d19 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -224,6 +224,24 @@ success:
}
mmu_notifier_invalidate_range_start(mm, start, end);
+#ifdef CONFIG_IPIPE
+ /*
+ * Privatize potential COW pages
+ */
+ if (test_bit(MMF_VM_PINNED, &mm->flags) &&
+ (((vma->vm_flags | mm->def_flags) & (VM_LOCKED | VM_WRITE)) ==
+ (VM_LOCKED | VM_WRITE))) {
+ error = __ipipe_pin_vma(mm, vma);
+ if (error)
+ /*
+ * OOM. Just revert the fake VM_SHARED so that the
+ * zero page cannot be overwritten.
+ */
+ vma->vm_page_prot =
+ pgprot_modify(vma->vm_page_prot,
+ vm_get_page_prot(newflags));
+ }
+#endif
if (is_vm_hugetlb_page(vma))
hugetlb_change_protection(vma, start, end, vma->vm_page_prot);
else
--
1.7.3.4
reply other threads:[~2012-03-29 16:38 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=4F74900F.6030707@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=adeos-main@gna.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.