Skip to content

Commit

Permalink
mm: ignore MAP_DENYWRITE in ksys_mmap_pgoff()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Hildenbrand committed Sep 3, 2021
1 parent 8d0920b commit 6128b3a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/linux/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 0 additions & 2 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6128b3a

Please sign in to comment.