From: Oleg Nesterov <oleg@redhat.com>
To: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Colin Cross <ccross@android.com>,
David Rientjes <rientjes@google.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/1] mm: shift VM_GROWS* check from mmap_region() to do_mmap_pgoff()
Date: Sat, 20 Jul 2013 17:22:46 +0200 [thread overview]
Message-ID: <20130720152246.GA588@redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1307191900390.986@eggly.anvils>
Andrew,
This patch replaces the buggy
mm-shift-vm_grows-check-from-mmap_region-to-do_mmap_pgoff.patch
I do not send the *-fix.patch because I'd like to update the changelog.
However it needs the explicit ack from Hugh.
On 07/19, Hugh Dickins wrote:
>
> On Tue, 16 Jul 2013, Andrew Morton wrote:
> > On Sun, 14 Jul 2013 18:54:51 +0200 Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > > mmap() doesn't allow the non-anonymous mappings with VM_GROWS* bit set.
> > > In particular this means that mmap_region()->vma_merge(file, vm_flags)
> > > must always fail if vm_flags & VM_GROWS.
>
> I didn't understand that sentence: if file is non-NULL perhaps?
Yes, this looks confusing, sorry.
I meant, vma_merge() must fail if "vm_flags & VM_GROWS" is set incorrectly.
is_mergeable_vma() compares both vm_file and vm_flags.
Even if file == NULL (at this stage), "VM_SHARED | VM_GROWS" is not correct
too, and vma_merge() can't succeed.
And, to clarify, I only mentioned this because I tried to convince myself
that this change (if correct) can't make any difference except "avoid the
not-really-correct do_munmap".
> > > So it does not make sense to
> > > check VM_GROWS* after we already allocated the new vma, the only caller,
> > > do_mmap_pgoff(), which can pass this flag can do the check itself.
> > >
> > > And this looks a bit more correct, mmap_region() already unmapped the
> > > old mapping at this stage. But if mmap() is going to fail, it should
> > > avoid do_munmap() if possible.
>
> I agree with the sentiment, but the patch looks wrong to me.
Heh. You are right of course.
> It did need staring, yes, but it looks NOK to me: this change permits
> mmap(addr, len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_GROWSDOWN, fd, off)
> where fd is for a real file:
And note that "Only MAP_PRIVATE|MAP_ANONYMOUS can use MAP_GROWS" even
tries to document that "MAP_PRIVATE && file" is not allowed too.
I have no idea how I managed to forget that MAP_PRIVATE never sets
VM_MAYSHARE.
Thanks a lot Hugh.
Oleg.
next prev parent reply other threads:[~2013-07-20 15:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-14 16:54 [PATCH 0/3] simple mmap() cleanups Oleg Nesterov
2013-07-14 16:54 ` [PATCH 1/3] mm: shift VM_GROWS* check from mmap_region() to do_mmap_pgoff() Oleg Nesterov
2013-07-16 21:43 ` Andrew Morton
2013-07-20 2:02 ` Hugh Dickins
2013-07-20 15:22 ` Oleg Nesterov [this message]
2013-07-20 15:23 ` [PATCH v2 1/1] " Oleg Nesterov
2013-07-22 23:30 ` Hugh Dickins
2013-07-14 16:54 ` [PATCH 2/3] mm: do_mmap_pgoff: cleanup the usage of file_inode() Oleg Nesterov
2013-07-14 16:54 ` [PATCH 3/3] mm: mmap_region: kill correct_wcount/inode, use allow_write_access() Oleg Nesterov
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=20130720152246.GA588@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ccross@android.com \
--cc=hughd@google.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).