lkml.org 
[lkml]   [2002]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: RFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage.
Date
In article <24305.1036795742@passion.cambridge.redhat.com>,
David Woodhouse <dwmw2@infradead.org> wrote:
>Why does a _readonly_ mapping fail if the file system has no writepage
>method?
>
>do_mmap_pgoff() sets VM_MAYWRITE on the vma and then generic_file_mmap()
>refuses to allow it.
>
>Suggested patch below.... or should I just hack fsx-linux to use
>MAP_PRIVATE for its readonly mappings and ignore it?

This is broken. Since it has VM_MAYWRITE, a subsequent mprotect() may
mark it writable, and you you went boom.

If you really want a shared mapping, you'd better open with O_RDONLY, at
which point the existing code should be perfectly happy and does the
right thing.

In other words: the code is correct as-is.

Linus
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:30    [W:0.052 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site