From: torvalds@transmeta.com (Linus Torvalds)
To: linux-kernel@vger.kernel.org
Subject: Re: RFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage.
Date: Fri, 8 Nov 2002 23:31:09 +0000 (UTC) [thread overview]
Message-ID: <aqhhft$19b$1@penguin.transmeta.com> (raw)
In-Reply-To: 24305.1036795742@passion.cambridge.redhat.com
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
next prev parent reply other threads:[~2002-11-08 23:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-08 22:49 RFC: mmap(PROT_READ, MAP_SHARED) fails if !writepage David Woodhouse
2002-11-08 23:31 ` Linus Torvalds [this message]
2002-11-08 23:50 ` David Woodhouse
2002-11-09 2:46 ` Linus Torvalds
2002-11-09 16:36 ` David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='aqhhft$19b$1@penguin.transmeta.com' \
--to=torvalds@transmeta.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox