Thread (6 messages) flat view 6 messages, 4 authors, 2017-12-03

Re: [PATCH] mmap.2: MAP_FIXED is no longer discouraged

From: Jann Horn <jannh@google.com>
Date: 2017-12-02 18:49:45
Also in: linux-arch, linux-man, linux-mm, lkml

On Sat, Dec 2, 2017 at 4:05 PM, Matthew Wilcox [off-list ref] wrote:
On Fri, Dec 01, 2017 at 06:16:26PM -0800, john.hubbard@gmail.com wrote:
quoted
MAP_FIXED has been widely used for a very long time, yet the man
page still claims that "the use of this option is discouraged".
I think we should continue to discourage the use of this option, but
I'm going to include some of your text in my replacement paragraph ...

-Because requiring a fixed address for a mapping is less portable,
-the use of this option is discouraged.
+The use of this option is discouraged because it forcibly unmaps any
+existing mapping at that address.  Programs which use this option need
+to be aware that their memory map may change significantly from one run to
+the next, depending on library versions, kernel versions and random numbers.
How about adding something explicit about when it's okay to use MAP_FIXED?
"This option should only be used to displace an existing mapping that is
controlled by the caller, or part of such a mapping." or something like that?
+In a threaded process, checking the existing mappings can race against
+a new dynamic library being loaded
malloc() and its various callers can also cause mmap() calls, which is probably
more relevant than library loading.

--
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>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help