linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] permit write-sealed memfd read-only shared mappings
@ 2023-04-03 22:28 Lorenzo Stoakes
  2023-04-03 22:28 ` [RFC PATCH 1/3] mm: drop the assumption that VM_SHARED always implies writable Lorenzo Stoakes
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Lorenzo Stoakes @ 2023-04-03 22:28 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linux-fsdevel, Andrew Morton
  Cc: Matthew Wilcox, Mike Kravetz, Muchun Song, Alexander Viro,
	Christian Brauner, Andy Lutomirski, Lorenzo Stoakes

This patch series is in two parts:-

1. Currently there are a number of places in the kernel where we assume
   VM_SHARED implies that a mapping is writable. Let's be slightly less
   strict and relax this restriction in the case that VM_MAYWRITE is not
   set.

   This should have no noticeable impact as the lack of VM_MAYWRITE implies
   that the mapping can not be made writable via mprotect() or any other
   means.

2. Align the behaviour of F_SEAL_WRITE and F_SEAL_FUTURE_WRITE on mmap().
   The latter already clears the VM_MAYWRITE flag for a sealed read-only
   mapping, we simply extend this to F_SEAL_WRITE too.

   For this to have effect, we must also invoke call_mmap() before
   mapping_map_writable().

As this is quite a fundamental change on the assumptions around VM_SHARED
and since this causes a visible change to userland (in permitting read-only
shared mappings on F_SEAL_WRITE mappings), I am putting forward as an RFC
to see if there is anything terribly wrong with it.

I suspect even if the patch series as a whole is unpalatable, there are
probably things we can salvage from it in any case.

Thanks to Andy Lutomirski who inspired the series!

Lorenzo Stoakes (3):
  mm: drop the assumption that VM_SHARED always implies writable
  mm: update seal_check_[future_]write() to include F_SEAL_WRITE as well
  mm: perform the mapping_map_writable() check after call_mmap()

 fs/hugetlbfs/inode.c |  2 +-
 include/linux/fs.h   |  4 ++--
 include/linux/mm.h   | 24 ++++++++++++++++++------
 kernel/fork.c        |  2 +-
 mm/filemap.c         |  2 +-
 mm/madvise.c         |  2 +-
 mm/mmap.c            | 22 +++++++++++-----------
 mm/shmem.c           |  2 +-
 8 files changed, 36 insertions(+), 24 deletions(-)

--
2.40.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-04-24 12:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03 22:28 [RFC PATCH 0/3] permit write-sealed memfd read-only shared mappings Lorenzo Stoakes
2023-04-03 22:28 ` [RFC PATCH 1/3] mm: drop the assumption that VM_SHARED always implies writable Lorenzo Stoakes
2023-04-03 22:28 ` [RFC PATCH 2/3] mm: update seal_check_[future_]write() to include F_SEAL_WRITE as well Lorenzo Stoakes
2023-04-03 22:28 ` [RFC PATCH 3/3] mm: perform the mapping_map_writable() check after call_mmap() Lorenzo Stoakes
2023-04-21  9:06   ` Jan Kara
2023-04-21 21:15     ` Lorenzo Stoakes
2023-04-21  9:01 ` [RFC PATCH 0/3] permit write-sealed memfd read-only shared mappings Jan Kara
2023-04-21 21:23   ` Lorenzo Stoakes
2023-04-24 12:19     ` Jan Kara
2023-04-24 12:23       ` Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox