Skip to contentSkip to conversation

ntfs: fix mmap_prepare writable check for shared mappings

PATCH In review Namjae Jeon 2 participants 2 messages Apr 21 – Apr 22

Subsystems (2)
lore
Share & tools
lore

Namjae Jeon

author maintainer
#0 lore raw

PATCH 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
index f55f55d4ca9a..e0265a8825f2 100644
@@ -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
maintainer Reviewed-by on v1 1/1
#1 lore raw

2026년 4월 21일 (화) 오후 7:00, Namjae Jeon <[email protected]>님이 작성:

Quoted 11 lines

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.

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
index f55f55d4ca9a..e0265a8825f2 100644
@@ -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