Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Apr 2004 02:12:22 -0400
From:      "Mark W. Krentel" <krentel@dreamscape.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/64573: mmap with PROT_NONE, but still could be read
Message-ID:  <200404150612.i3F6CMaK041191@blue.mwk.domain>

next in thread | raw e-mail | index | archive | help
I'm concerned that my previous message was misleading, so let me
clarify one point.  IEEE Std 1003.1-2003 on mmap() does say:

    If an implementation cannot support the combination of access types
    specified by prot, the call to mmap() shall fail.

But that doesn't mean that if the OS can't support the precise
combination of protection options that mmap() must fail.  mmap() may
add other access beyond what is requested.  In the RATIONALE section,
two cases are handled explicitly:

    implementations are required to disallow write access to mappings
    without write permission and to disallow access to mappings without
    any access permission.

But in general:

    Other than these restrictions, implementations may allow access types
    other than those requested by the application. For example, if the
    application requests only PROT_WRITE, the implementation may also
    allow read access.

See:  http://www.opengroup.org/onlinepubs/007904975/functions/mmap.html

So, to summarize: (1) the OS must allow all access that is explicitly
requested, (2) it may add extra access, except (3) it must not allow
write access without PROT_WRITE and it must disallow all access if
PROT_NONE is given alone.  And if it can't do that, then mmap() should
fail.

Sorry if my previous message was unclear or misleading.

--Mark



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404150612.i3F6CMaK041191>