Browse Source

[PATCH] Fix MADV_REMOVE protection checking

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>
Hugh Dickins 19 năm trước cách đây
mục cha
commit
69cf0fac60
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      mm/madvise.c

+ 3 - 0
mm/madvise.c

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