Thread (12 messages) flat view 12 messages, 4 authors, 2017-09-01

Re: [PATCH 2/2] mm: introduce MAP_VALIDATE, a mechanism for for safely defining new mmap flags

From: Linus Torvalds <hidden>
Date: 2017-09-01 01:27:33
Also in: linux-mm, nvdimm

On Thu, Aug 31, 2017 at 6:01 PM, Dan Williams [off-list ref] wrote:
Ugh, nommu defeats the MAP_SHARED_VALIDATE proposal from Linus.

        if ((flags & MAP_TYPE) != MAP_PRIVATE &&
            (flags & MAP_TYPE) != MAP_SHARED)
                return -EINVAL;

...parisc strikes again.
Why? That's no different from the case statement for the mmu case,
just written differently.

You *want* existing kernels to fail, since they don't test the bits
you want to test.

So you just want to rewrite these all as

    switch (flags & MAP_TYPE) {
    case MAP_SHARED_VALIDATE:
        .. validate the other bits...
        /* fallhtough */
    case MAP_SHARED:
        .. do the shared case ..
    case MAP_PRIVATE:
        .. do the private case ..
    default:
        return -EINVAL;
    }

and you're all good.

I'm not seeing the problem.

Of course, I also suspect that for nommu you might as well just always
return -EINVAL anyway. The only people who would ever use
MAP_SHARED_VALIDATE are the kinds of people who do things that just
aren't likely relevant on nommu, but whatever..

               Linus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help