Re: Table of mmap PROT_* implementations by architecture

From: David Mosberger
Date: Tue Jul 06 2004 - 16:30:48 EST


>>>>> On Thu, 1 Jul 2004 04:36:20 +0100, Jamie Lokier <jamie@xxxxxxxxxxxxx> said:

>> From a study of Linux 2.6.5 source code, and some patches.
Jamie> This is based on studying the source, not running tests, so
Jamie> there may be errors.

Jamie> This table shows expected page protections, for different
Jamie> values of PROT_READ, PROT_WRITE and PROT_EXEC passed to
Jamie> mmap() and mprotect().

Jamie> (As noted in a recent mail from me, real behaviour isn't
Jamie> quite this simple. Reading from a write-only page will
Jamie> *sometimes* raise a signal, and sometimes not, possibly
Jamie> dependent on background paging decisions. Therefore some of
Jamie> these entries should say "!w!" instead of "rwx", and "!w-"
Jamie> instead of "rw-". Perhaps there are other combinations too,
Jamie> depending on architecture-specific fault handlers).


Jamie> ==============================================================
Jamie> Requested PROT flags | --- R-- -W- RW- --X R-X -WX RWX
Jamie> ==============================================================
Jamie> ia64 | --- r-- rw- rw- --x(1) r-x rwx rwx
Jamie> --------------------------------------------------------------

Jamie> (1) - In kernel, maybe these pages are readable using
Jamie> "write()"?

That's correct for ia64. The architecture does not support an
"execute-only at all privilege levels" protection per se, so this
behavior is the easiest (most efficient) to implement. If we really
cared about the "read execute-only at kernel-level", we could use
"probe" instructions in the __access_ok() macro to verify (user-level)
access permission.

--david
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/