From 69cf0fac6052c5bd3fb3469a41d4216e926028f8 Mon Sep 17 00:00:00 2001 From: Hugh Dickins Date: Mon, 17 Apr 2006 22:46:32 +0100 Subject: [PATCH] Fix MADV_REMOVE protection checking madvise_remove needs to respect file and mmap protections. Signed-off-by: Hugh Dickins [ Will the real CVE-2006-1524 stand up, please.. ] Signed-off-by: Linus Torvalds --- mm/madvise.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mm/madvise.c') diff --git a/mm/madvise.c b/mm/madvise.c index af3d573b014..4e196155a0c 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -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) -- cgit v1.2.3-70-g09d2