public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ntfs: fix mmap_prepare writable check for shared mappings
@ 2026-04-21  9:59 Namjae Jeon
  2026-04-22  0:06 ` Hyunchul Lee
  0 siblings, 1 reply; 2+ messages in thread
From: Namjae Jeon @ 2026-04-21  9:59 UTC (permalink / raw)
  To: hyc.lee; +Cc: linux-fsdevel, Namjae Jeon, Linus Torvalds

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>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/ntfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index f55f55d4ca9a..e0265a8825f2 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ntfs: fix mmap_prepare writable check for shared mappings
  2026-04-21  9:59 [PATCH] ntfs: fix mmap_prepare writable check for shared mappings Namjae Jeon
@ 2026-04-22  0:06 ` Hyunchul Lee
  0 siblings, 0 replies; 2+ messages in thread
From: Hyunchul Lee @ 2026-04-22  0:06 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: linux-fsdevel, Linus Torvalds

2026년 4월 21일 (화) 오후 7:00, Namjae Jeon <linkinjeon@kernel.org>님이 작성:
>
> 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>
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

Looks good to me.

Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>

> ---
>  fs/ntfs/file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index f55f55d4ca9a..e0265a8825f2 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -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
>


-- 
Thanks,
Hyunchul

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-22  0:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-21  9:59 [PATCH] ntfs: fix mmap_prepare writable check for shared mappings Namjae Jeon
2026-04-22  0:06 ` Hyunchul Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox