]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntfs: fix mmap_prepare writable check for shared mappings
authorNamjae Jeon <linkinjeon@kernel.org>
Mon, 20 Apr 2026 23:13:57 +0000 (08:13 +0900)
committerNamjae Jeon <linkinjeon@kernel.org>
Wed, 22 Apr 2026 09:33:15 +0000 (18:33 +0900)
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 <torvalds@linux-foundation.org>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/ntfs/file.c

index ffd753740fcf0f1c3a824e2f10050783e6006d68..e8bea22b81a75564647b9a5306f3ea7c002094d9 100644 (file)
@@ -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;