|
|
5a015b |
From f703950fc461d87b9833246be8721593aa5ec460 Mon Sep 17 00:00:00 2001
|
|
|
5a015b |
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
|
|
|
5a015b |
Date: Thu, 8 Aug 2019 16:59:54 +0200
|
|
|
5a015b |
Subject: [PATCH 2/6] mmap.2: fix EINVAL conditions
|
|
|
5a015b |
---
|
|
|
5a015b |
man-pages/man2/mmap.2 | 60 +++++++++++++++++++++++++++++++++++++------
|
|
|
5a015b |
1 file changed, 52 insertions(+), 8 deletions(-)
|
|
|
5a015b |
|
|
|
5a015b |
diff --git a/man-pages/man2/mmap.2 b/man-pages/man2/mmap.2
|
|
|
5a015b |
index 798e0dd..6a9248c 100644
|
|
|
5a015b |
--- a/man-pages/man2/mmap.2
|
|
|
5a015b |
+++ b/man-pages/man2/mmap.2
|
|
|
5a015b |
@@ -126,6 +126,23 @@ or
|
|
|
5a015b |
.BR munmap ()
|
|
|
5a015b |
is called.
|
|
|
5a015b |
.TP
|
|
|
5a015b |
+.BR MAP_SHARED_VALIDATE " (since Linux 4.15)"
|
|
|
5a015b |
+This flag provides the same behavior as
|
|
|
5a015b |
+.B MAP_SHARED
|
|
|
5a015b |
+except that
|
|
|
5a015b |
+.B MAP_SHARED
|
|
|
5a015b |
+mappings ignore unknown flags in
|
|
|
5a015b |
+.IR flags .
|
|
|
5a015b |
+By contrast, when creating a mapping using
|
|
|
5a015b |
+.BR MAP_SHARED_VALIDATE ,
|
|
|
5a015b |
+the kernel verifies all passed flags are known and fails the
|
|
|
5a015b |
+mapping with the error
|
|
|
5a015b |
+.BR EOPNOTSUPP
|
|
|
5a015b |
+for unknown flags.
|
|
|
5a015b |
+This mapping type is also required to be able to use some mapping flags
|
|
|
5a015b |
+(e.g.,
|
|
|
5a015b |
+.BR MAP_SYNC ).
|
|
|
5a015b |
+.TP
|
|
|
5a015b |
.B MAP_PRIVATE
|
|
|
5a015b |
Create a private copy-on-write mapping.
|
|
|
5a015b |
Updates to the mapping are not visible to other processes
|
|
|
5a015b |
@@ -135,8 +152,14 @@ It is unspecified whether changes made to the file after the
|
|
|
5a015b |
.BR mmap ()
|
|
|
5a015b |
call are visible in the mapped region.
|
|
|
5a015b |
.LP
|
|
|
5a015b |
-Both of these flags are described in POSIX.1-2001.
|
|
|
5a015b |
-
|
|
|
5a015b |
+Both
|
|
|
5a015b |
+.B MAP_SHARED
|
|
|
5a015b |
+and
|
|
|
5a015b |
+.B MAP_PRIVATE
|
|
|
5a015b |
+are described in POSIX.1-2001 and POSIX.1-2008.
|
|
|
5a015b |
+.B MAP_SHARED_VALIDATE
|
|
|
5a015b |
+is a Linux extension.
|
|
|
5a015b |
+.LP
|
|
|
5a015b |
In addition, zero or more of the following values can be ORed in
|
|
|
5a015b |
.IR flags :
|
|
|
5a015b |
.TP
|
|
|
5a015b |
@@ -290,6 +313,27 @@ support can later be transparently implemented for glibc.
|
|
|
5a015b |
.\" "pthread_create() slow for many threads; also time to revisit 64b
|
|
|
5a015b |
.\" context switch optimization?"
|
|
|
5a015b |
.TP
|
|
|
5a015b |
+.BR MAP_SYNC " (since Linux 4.15)"
|
|
|
5a015b |
+This flag is available only with the
|
|
|
5a015b |
+.B MAP_SHARED_VALIDATE
|
|
|
5a015b |
+mapping type;
|
|
|
5a015b |
+mappings of type
|
|
|
5a015b |
+.B MAP_SHARED
|
|
|
5a015b |
+will silently ignore this flag.
|
|
|
5a015b |
+This flag is supported only for files supporting DAX
|
|
|
5a015b |
+(direct mapping of persistent memory).
|
|
|
5a015b |
+For other files, creating a mapping with this flag results in an
|
|
|
5a015b |
+.B EOPNOTSUPP
|
|
|
5a015b |
+error.
|
|
|
5a015b |
+.IP
|
|
|
5a015b |
+Shared file mappings with this flag provide the guarantee that while
|
|
|
5a015b |
+some memory is writably mapped in the address space of the process,
|
|
|
5a015b |
+it will be visible in the same file at the same offset even after
|
|
|
5a015b |
+the system crashes or is rebooted.
|
|
|
5a015b |
+In conjunction with the use of appropriate CPU instructions,
|
|
|
5a015b |
+this provides users of such mappings with a more efficient way
|
|
|
5a015b |
+of making data modifications persistent.
|
|
|
5a015b |
+.TP
|
|
|
5a015b |
.BR MAP_UNINITIALIZED " (since Linux 2.6.33)"
|
|
|
5a015b |
Don't clear anonymous pages.
|
|
|
5a015b |
This flag is intended to improve performance on embedded devices.
|
|
|
5a015b |
@@ -302,7 +346,7 @@ that option is normally enabled only on embedded devices
|
|
|
5a015b |
.LP
|
|
|
5a015b |
Of the above flags, only
|
|
|
5a015b |
.B MAP_FIXED
|
|
|
5a015b |
-is specified in POSIX.1-2001.
|
|
|
5a015b |
+is specified in POSIX.1-2001 and POSIX.1-2008.
|
|
|
5a015b |
However, most systems also support
|
|
|
5a015b |
.B MAP_ANONYMOUS
|
|
|
5a015b |
(or its synonym
|
|
|
5a015b |
@@ -436,11 +480,11 @@ was 0.
|
|
|
5a015b |
.TP
|
|
|
5a015b |
.B EINVAL
|
|
|
5a015b |
.I flags
|
|
|
5a015b |
-contained neither
|
|
|
5a015b |
-.B MAP_PRIVATE
|
|
|
5a015b |
+contained none of
|
|
|
5a015b |
+.BR MAP_PRIVATE ,
|
|
|
5a015b |
+.B MAP_SHARED
|
|
|
5a015b |
or
|
|
|
5a015b |
-.BR MAP_SHARED ,
|
|
|
5a015b |
-or contained both of these values.
|
|
|
5a015b |
+.BR MAP_SHARED_VALIDATE .
|
|
|
5a015b |
.TP
|
|
|
5a015b |
.B ENFILE
|
|
|
5a015b |
.\" This is for shared anonymous segments
|
|
|
5a015b |
@@ -495,7 +539,7 @@ Attempted access to a portion of the buffer that does not correspond
|
|
|
5a015b |
to the file (for example, beyond the end of the file, including the
|
|
|
5a015b |
case where another process has truncated the file).
|
|
|
5a015b |
.SH CONFORMING TO
|
|
|
5a015b |
-SVr4, 4.4BSD, POSIX.1-2001.
|
|
|
5a015b |
+POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD.
|
|
|
5a015b |
.\" SVr4 documents additional error codes ENXIO and ENODEV.
|
|
|
5a015b |
.\" SUSv2 documents additional error codes EMFILE and EOVERFLOW.
|
|
|
5a015b |
.SH AVAILABILITY
|
|
|
5a015b |
--
|
|
|
5a015b |
2.21.0
|
|
|
5a015b |
|