[SRU N][PATCH 1/1] UBUNTU: SAUCE: Fix read-only mapping of write-sealed pages
Stefan Bader
stefan.bader at canonical.com
Mon Jan 12 17:33:18 UTC 2026
BugLink: https://bugs.launchpad.net/bugs/2138244
When backporting 5de195060b2e (mm: resolve faulty mmap_region() error
path behaviour) we were taking the related 6.6.63 change into account for
guidance. But in 6.6.y this was backported before e8e17ee90eaf (mm: drop
the assumption that VM_SHARED always implies writable) from v6.7.
This re-introduced accidentally the old notion that all shared mappings
are writeable. Upstream 6.6.y picked up the following patch set later:
v6.6.103
5dd481868eb1 selftests/memfd: add test for mapping write-sealed memfd read-only
2e4179698f84 mm: reinstate ability to map write-sealed memfd mappings read-only
87a75f68eaba mm: update memfd seal write check to include F_SEAL_WRITE(1)
17c5d49beb6c mm: drop the assumption that VM_SHARED always implies writable(2)
(1)&(2) Those patches are from v6.7 upstream and thus already included
in noble(6.8). In (2) upstream 6.6.y fixed up the check for writeable
shared mappings but as it was not required in 6.8 it was ignored.
With Ubuntu-6.8.0-60.63 we picked up:
13ce5fc940ea mm: reinstate ability to map write-sealed memfd mappings read-only
and now with Ubuntu-6.8.0-98.98:
5045339a33e8 selftests/memfd: add test for mapping write-sealed memfd read-only
but that depends on the correctness of mmap_region(). Which is what this
change is for.
Fixes: 5de195060b2e (mm: resolve faulty mmap_region() error path behaviour)
Signed-off-by: Stefan Bader <stefan.bader at canonical.com>
---
mm/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index 666416a0948c..fd7d9353fbd5 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2983,7 +2983,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
return -EINVAL;
/* Map writable and ensure this isn't a sealed memfd. */
- if (file && (vm_flags & VM_SHARED)) {
+ if (file && is_shared_maywrite(vm_flags)) {
int error = mapping_map_writable(file->f_mapping);
if (error)
--
2.43.0
More information about the kernel-team
mailing list