Skip to content

Commit 1ddd439

Browse files
Hugh DickinsLinus Torvalds
authored andcommitted
fix mprotect vma_wants_writenotify prot
Fix mprotect bug in recent commit 3ed75eb (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> Cc: Coly Li <coyli@suse.de> Cc: Tony Luck <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4ae3f84 commit 1ddd439

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

‎mm/mmap.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
11711171
vm_flags = vma->vm_flags;
11721172

11731173
if (vma_wants_writenotify(vma))
1174-
vma->vm_page_prot =
1175-
protection_map[vm_flags & (VM_READ|VM_WRITE|VM_EXEC)];
1174+
vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
11761175

11771176
if (!file || !vma_merge(mm, prev, addr, vma->vm_end,
11781177
vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) {

‎mm/mprotect.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
194194
vma->vm_flags = newflags;
195195
vma->vm_page_prot = vm_get_page_prot(newflags);
196196
if (vma_wants_writenotify(vma)) {
197-
vma->vm_page_prot = vm_get_page_prot(newflags);
197+
vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
198198
dirty_accountable = 1;
199199
}
200200

0 commit comments

Comments
 (0)