mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fix mprotect vma_wants_writenotify prot
@ 2007-10-22 18:12 Hugh Dickins
  0 siblings, 0 replies; only message in thread
From: Hugh Dickins @ 2007-10-22 18:12 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Coly Li, Tony Luck, linux-kernel

Fix mprotect bug in recent commit 3ed75eb8f1cd89565966599c4f77d2edb086d5b0
(setup vma->vm_page_prot by vm_get_page_prot()): the vma_wants_writenotify
case was setting the same prot as when not.

Nothing wrong with the use of protection_map[] in mmap_region(),
but use vm_get_page_prot() there too in the same ~VM_SHARED way.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
---

 mm/mmap.c     |    3 +--
 mm/mprotect.c |    2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

--- 2.6.23-git17/mm/mmap.c	2007-10-22 17:07:00.000000000 +0100
+++ linux/mm/mmap.c	2007-10-22 18:25:25.000000000 +0100
@@ -1171,8 +1171,7 @@ munmap_back:
 	vm_flags = vma->vm_flags;
 
 	if (vma_wants_writenotify(vma))
-		vma->vm_page_prot =
-			protection_map[vm_flags & (VM_READ|VM_WRITE|VM_EXEC)];
+		vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
 
 	if (!file || !vma_merge(mm, prev, addr, vma->vm_end,
 			vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) {
--- 2.6.23-git17/mm/mprotect.c	2007-10-22 17:07:00.000000000 +0100
+++ linux/mm/mprotect.c	2007-10-22 18:25:25.000000000 +0100
@@ -194,7 +194,7 @@ success:
 	vma->vm_flags = newflags;
 	vma->vm_page_prot = vm_get_page_prot(newflags);
 	if (vma_wants_writenotify(vma)) {
-		vma->vm_page_prot = vm_get_page_prot(newflags);
+		vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
 		dirty_accountable = 1;
 	}
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-22 18:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-22 18:12 [PATCH] fix mprotect vma_wants_writenotify prot Hugh Dickins

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®