ntfs: fix mmap_prepare writable check for shared mappings
Subsystems (2)
Namjae Jeon
maintainerPATCH 1/1 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.
--- fs/ntfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs/file.c +1 -1
@@ -650,7 +650,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;
Signature · 1 line
2.25.1
2026년 4월 21일 (화) 오후 7:00, Namjae Jeon <[email protected]>님이 작성:
Quoted 11 lines
Linus pointed out that checking only
VMA_WRITE_BITis incorrect. Private writable mappings (MAP_PRIVATE) setVM_WRITEbut do not write back to the filesystem. Also, mappings that can become writable viamprotect()(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 <[email protected]>Signed-off-by Namjae Jeon <[email protected]>
Looks good to me.
Quoted 20 lines
--- fs/ntfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ntfs/file.c +1
-2@@ -650,7 +650,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; --2.25.1
Signature · 2 lines
Thanks, Hyunchul