ntfs_file_mmap_prepare() rejects a writable mmap of compressed files, but leaves VMA_MAYWRITE set in the VMA description. Userspace can map such a file read-only and then upgrade the mapping with mprotect(), writing page-cache pages of a compressed file even though the filesystem explicitly does not support writable mmap for them. Clear VMA_MAYWRITE on that path, so the restriction cannot be bypassed after mmap(). Cc: stable@vger.kernel.org Signed-off-by: Abdifatah Suruur --- diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 1624f9b014e09..a817452ac73fa 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -415,6 +415,8 @@ static int ntfs_file_mmap_prepare(struct vm_area_desc *desc) } /* Turn off readahead for compressed files. */ file->f_ra.ra_pages = 0; + /* Do not allow mprotect() to make this mapping writable. */ + vma_desc_clear_flags(desc, VMA_MAYWRITE_BIT); } if (rw) {