dl-load.h: Remove MAP_DENYWRITE from MAP_COPY definition

Message ID 1472926278-23144-2-git-send-email-fw.dmitrii@gmail.com
State New, archived
Headers

Commit Message

Dmitrii Shcherbakov Sept. 3, 2016, 6:11 p.m. UTC
  The Linux kernel no longer uses this flag in mmap
other than for compatibility purposes. In fact,
its support was removed many years ago according to
the mmap man page.

Let's remove it to avoid confusing output in strace
and fix a comment about this flag doing what it does
not anymore.

Signed-off-by: Dmitrii Shcherbakov <fw.dmitrii at gmail.com>

ChangeLog:

	* elf/dl-load.h: Remove MAP_DENYWRITE from MAP_COPY d
---
 elf/dl-load.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
  

Patch

diff --git a/elf/dl-load.h b/elf/dl-load.h
index 9fe7118..622c0bc 100644
--- a/elf/dl-load.h
+++ b/elf/dl-load.h
@@ -37,14 +37,13 @@ 
    from the new version after starting with pages from the old version.
 
    To make up for the lack and avoid the overwriting problem,
-   what Linux does have is MAP_DENYWRITE.  This prevents anyone
-   from modifying the file while we have it mapped.  */
+   what Linux used to have was MAP_DENYWRITE.
+   This prevented anyone from modifying the file while it was mapped,
+   creating a denial-of-service attack possibility by using mmap given
+   read permissions to a file.
+   */
 #ifndef MAP_COPY
-# ifdef MAP_DENYWRITE
-#  define MAP_COPY      (MAP_PRIVATE | MAP_DENYWRITE)
-# else
-#  define MAP_COPY      MAP_PRIVATE
-# endif
+# define MAP_COPY      MAP_PRIVATE
 #endif
 
 /* Some systems link their relocatable objects for another base address