From: Namjae Jeon Date: Mon, 20 Apr 2026 23:13:57 +0000 (+0900) Subject: ntfs: fix mmap_prepare writable check for shared mappings X-Git-Tag: v7.1-rc1~14^2~1 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=6e0152c75d70725add4cef3b1cb10abc6efa6ad9;p=thirdparty%2Fkernel%2Flinux.git ntfs: fix mmap_prepare writable check for shared mappings Linus pointed out that checking only VMA_WRITE_BIT is incorrect. Private writable mappings (MAP_PRIVATE) set VM_WRITE but do not write back to the filesystem. Also, mappings that can become writable via mprotect() (VM_MAYWRITE) must be handled. Use vma_desc_test_all(VMA_SHARED_BIT, VMA_MAYWRITE_BIT) instead, which matches what other filesystems do. Suggested-by: Linus Torvalds Reviewed-by: Hyunchul Lee Signed-off-by: Namjae Jeon --- diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index ffd753740fcf..e8bea22b81a7 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c @@ -644,7 +644,7 @@ static int ntfs_file_mmap_prepare(struct vm_area_desc *desc) if (NInoCompressed(NTFS_I(inode))) return -EOPNOTSUPP; - if (vma_desc_test(desc, VMA_WRITE_BIT)) { + if (vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT)) { struct inode *inode = file_inode(file); loff_t from, to; int err;