linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-mm <linux-mm@kvack.org>, Jan Kara <jack@suse.cz>,
	Arnd Bergmann <arnd@arndb.de>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
	Linux API <linux-api@vger.kernel.org>,
	Andrew Lutomirski <luto@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 2/2] mm: introduce MAP_VALIDATE, a mechanism for for safely defining new mmap flags
Date: Thu, 31 Aug 2017 09:49:52 -0700	[thread overview]
Message-ID: <CA+55aFzo4oV87tVjEzx+cHVxfihm=31+fWtsdWow3AmfsdzJJw@mail.gmail.com> (raw)
In-Reply-To: <150413450616.5923.7069852068237042023.stgit@dwillia2-desk3.amr.corp.intel.com>

This patch strikes me as insane.

On Wed, Aug 30, 2017 at 4:08 PM, Dan Williams <dan.j.williams@intel.com> wrote:
>                 switch (flags & MAP_TYPE) {
> +               case (MAP_SHARED|MAP_VALIDATE):
> +                       /* TODO: new map flags */
> +                       return -EINVAL;
>                 case MAP_SHARED:
>                         if ((prot&PROT_WRITE) && !(file->f_mode&FMODE_WRITE))
>                                 return -EACCES;

So you "add" support for MAP_SHARED|MAP_VALIDATE, but then error out on it.

And you don't add support for MAP_PRIVATE|MAP_VALIDATE at all, so that
errors out too.

Which makes me think that you actually only want MAP:_VALIDATE support
for shared mappings.

Which in turn means that all your blathering about how this cannot
work on HP-UX is just complete garbage, because you might as well just
realize that MAP_TYPE isn't a mask of _bitmasks_, it's a mask of
values.

So just make MAP_VALIDATE be 0x3. Which works for everybody. Make it
mean the same as MAP_SHARED with flag validation. End of story.

None of these stupid games that are complete and utter garbage, and
make people think that the MAP_TYPE bits are somehow a bitmask. They
aren't. The bitmasks are all the *other* bits that aren't in
MAP_TYTPE.

Yes, yes, I see why you *think* you want a bitmap. You think you want
a bitmap because you want to make MAP_VALIDATE be part of MAP_SYNC
etc, so that people can do

    ret = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED |
MAP_SYNC, fd, 0);

and "know" that MAP_SYNC actually takes.

And I'm saying that whole wish is bogus. You're fundamentally
depending on special semantics, just make it explicit. It's already
not portable, so don't try to make it so.

Rename that MAP_VALIDATE as MAP_SHARED_VALIDATE, make it have a valud
of 0x3, and make people do

   ret = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED_VALIDATE
| MAP_SYNC, fd, 0);

and then the kernel side is easier too (none of that random garbage
playing games with looking at the "MAP_VALIDATE bit", but just another
case statement in that map type thing.

Boom. Done.

               Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2017-08-31 16:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 23:08 [PATCH 0/2] MAP_VALIDATE and mmap flags validation Dan Williams
2017-08-30 23:08 ` [PATCH 1/2] vfs: add flags parameter to ->mmap() in 'struct file_operations' Dan Williams
2017-08-31 10:02   ` Christoph Hellwig
2017-09-01  0:54     ` Dan Williams
2017-08-30 23:08 ` [PATCH 2/2] mm: introduce MAP_VALIDATE, a mechanism for for safely defining new mmap flags Dan Williams
2017-08-31 10:03   ` Christoph Hellwig
2017-09-01  1:01     ` Dan Williams
2017-09-01  1:27       ` Linus Torvalds
2017-09-01  1:40         ` Dan Williams
2017-09-01  7:34         ` Christoph Hellwig
2017-08-31 16:49   ` Linus Torvalds [this message]
2017-08-31 21:31     ` Dan Williams

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='CA+55aFzo4oV87tVjEzx+cHVxfihm=31+fWtsdWow3AmfsdzJJw@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=luto@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;
as well as URLs for NNTP newsgroup(s).