[PATCH] Fix MADV_REMOVE protection checking
authorHugh Dickins <hugh@veritas.com>
Mon, 17 Apr 2006 21:46:32 +0000 (22:46 +0100)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 18 Apr 2006 01:22:18 +0000 (18:22 -0700)
madvise_remove needs to respect file and mmap protections.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
[ Will the real CVE-2006-1524 stand up, please.. ]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/madvise.c

index af3d573b014122f7fd2a99c3ee90c3826f70457f..4e196155a0c3635801bd0f8dcff0b18ce1bbcf37 100644 (file)
@@ -168,6 +168,9 @@ static long madvise_remove(struct vm_area_struct *vma,
                        return -EINVAL;
        }
 
+       if ((vma->vm_flags & (VM_SHARED|VM_WRITE)) != (VM_SHARED|VM_WRITE))
+               return -EACCES;
+
        mapping = vma->vm_file->f_mapping;
 
        offset = (loff_t)(start - vma->vm_start)