Skip to content

Commit 6e0152c

Browse files
committed
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 <torvalds@linux-foundation.org> Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 660b982 commit 6e0152c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/ntfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ static int ntfs_file_mmap_prepare(struct vm_area_desc *desc)
644644
if (NInoCompressed(NTFS_I(inode)))
645645
return -EOPNOTSUPP;
646646

647-
if (vma_desc_test(desc, VMA_WRITE_BIT)) {
647+
if (vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT)) {
648648
struct inode *inode = file_inode(file);
649649
loff_t from, to;
650650
int err;

0 commit comments

Comments
 (0)