Re: 2.5.55-rmk1: user space lossage

From: Hugh Dickins (hugh@veritas.com)
Date: Thu Jan 23 2003 - 12:57:31 EST


On Thu, 23 Jan 2003, Andrew Morton wrote:
>
> We cannot clear VM_MAYWRITE in there - it turns writeable MAP_PRIVATE
> mappings into readonly ones.
>
> So change it back to the 2.4 form - disallow a writeable MAP_SHARED mapping
> against filesystems which do no implement ->writepage().

Sorry for late quibbles, but wouldn't patch below be better? Linus
did intend that change to the occasionally criticized 2.4 behaviour,
this preserves that change while avoiding the bug which hit David.

You may notice I've sneaked a ~VM_SHARED in there too. Not because
I can say it's necessary, but the VM_MAYWRITE, VM_SHARED treatment
is already weird, I'd feel safer if we keep to the same combination
as already exists in the !FMODE_WRITE case (see do_mmap_pgoff).

Hugh

--- 2.5.59-mm2/mm/filemap.c Sat Jan 18 10:37:36 2003
+++ linux/mm/filemap.c Thu Jan 23 16:50:34 2003
@@ -1310,9 +1310,11 @@
 
 int generic_file_readonly_mmap(struct file *file, struct vm_area_struct *vma)
 {
- if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_WRITE))
- return -EINVAL;
- vma->vm_flags &= ~VM_MAYWRITE;
+ if (vma->vm_flags & VM_SHARED) {
+ if (vma->vm_flags & VM_WRITE)
+ return -EINVAL;
+ vma->vm_flags &= ~(VM_MAYWRITE | VM_SHARED);
+ }
         return generic_file_mmap(file, vma);
 }
 #else

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jan 23 2003 - 22:00:32 EST