mm: ignore MAP_DENYWRITE in ksys_mmap_pgoff()
authorDavid Hildenbrand <david@redhat.com>
Fri, 23 Apr 2021 07:38:14 +0000 (09:38 +0200)
committerDavid Hildenbrand <david@redhat.com>
Fri, 3 Sep 2021 16:42:01 +0000 (18:42 +0200)
Let's also remove masking off MAP_DENYWRITE from ksys_mmap_pgoff():
the last in-tree occurrence of MAP_DENYWRITE is now in LEGACY_MAP_MASK,
which accepts the flag e.g., for MAP_SHARED_VALIDATE; however, the flag
is ignored throughout the kernel now.

Add a comment to LEGACY_MAP_MASK stating that MAP_DENYWRITE is ignored.

Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
include/linux/mman.h
mm/mmap.c
mm/nommu.c

index bd9aadda047be50cb24a7eaf3f1dd8d02d04fccd..b66e91b8176cdc75f83107daf3f223e2076067f5 100644 (file)
@@ -32,7 +32,8 @@
  * The historical set of flags that all mmap implementations implicitly
  * support when a ->mmap_validate() op is not provided in file_operations.
  *
- * MAP_EXECUTABLE is completely ignored throughout the kernel.
+ * MAP_EXECUTABLE and MAP_DENYWRITE are completely ignored throughout the
+ * kernel.
  */
 #define LEGACY_MAP_MASK (MAP_SHARED \
                | MAP_PRIVATE \
index 589dc1dc13dbd2ba27d90e3eee70374e9bfd7e30..bf11fc6e831143575e083e164b8e97c0c72bde9d 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1626,8 +1626,6 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len,
                        return PTR_ERR(file);
        }
 
-       flags &= ~MAP_DENYWRITE;
-
        retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff);
 out_fput:
        if (file)
index 3a93d40548104e8e438dbb0b63b6047c8784aea3..0987d131bdfc7c31fb2d3de42d35c43f1ef9b414 100644 (file)
@@ -1296,8 +1296,6 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len,
                        goto out;
        }
 
-       flags &= ~MAP_DENYWRITE;
-
        retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff);
 
        if (file)