* [PATCH] fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename
@ 2026-04-22 15:20 Zhan Xusheng
2026-05-06 7:55 ` Zhan Xusheng
0 siblings, 1 reply; 3+ messages in thread
From: Zhan Xusheng @ 2026-04-22 15:20 UTC (permalink / raw)
To: Konstantin Komarov; +Cc: linux-kernel, Zhan Xusheng
In ntfs3_rename(), when IS_DIRSYNC(new_dir) is true, the code syncs
the renamed file inode instead of the target directory new_dir:
if (IS_DIRSYNC(new_dir))
ntfs_sync_inode(inode); /* should be new_dir */
DIRSYNC requires that directory metadata changes are written to disk
synchronously. Since new_dir was modified (a new directory entry was
added), it is new_dir that must be synced to satisfy the guarantee,
not the renamed file itself.
This bug has existed since the initial ntfs3 implementation and was
carried through the refactoring in commit 78ab59fee07f
("fs/ntfs3: Rework file operations").
Fix by syncing new_dir instead of inode.
Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
fs/ntfs3/namei.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index b2af8f695e60..64cde1a856f4 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -340,7 +340,7 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,
ntfs_sync_inode(dir);
if (IS_DIRSYNC(new_dir))
- ntfs_sync_inode(inode);
+ ntfs_sync_inode(new_dir);
}
if (dir_ni != new_dir_ni)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename
2026-04-22 15:20 [PATCH] fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename Zhan Xusheng
@ 2026-05-06 7:55 ` Zhan Xusheng
2026-05-22 15:24 ` Konstantin Komarov
0 siblings, 1 reply; 3+ messages in thread
From: Zhan Xusheng @ 2026-05-06 7:55 UTC (permalink / raw)
To: almaz.alexandrovich; +Cc: ntfs3, linux-kernel, stable, Zhan Xusheng
In ntfs3_rename(), when IS_DIRSYNC(new_dir) is true, the code syncs
the renamed file inode instead of the target directory new_dir:
if (IS_DIRSYNC(new_dir))
ntfs_sync_inode(inode); /* should be new_dir */
DIRSYNC requires that directory metadata changes are written to disk
synchronously. Since new_dir was modified (a new directory entry was
added), it is new_dir that must be synced to satisfy the guarantee,
not the renamed file itself.
This bug has existed since the initial ntfs3 implementation and was
carried through the refactoring in commit 78ab59fee07f
("fs/ntfs3: Rework file operations").
Fix by syncing new_dir instead of inode.
Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
v2:
- Cc ntfs3@lists.linux.dev (was missing in v1, see
https://lore.kernel.org/all/20260422152010.205694-1-zhanxusheng@xiaomi.com/).
- Add Cc: stable@vger.kernel.org; this is a data-persistence bug under
DIRSYNC and affects all ntfs3 since 4342306f0f0d.
v1: https://lore.kernel.org/all/20260422152010.205694-1-zhanxusheng@xiaomi.com/
---
fs/ntfs3/namei.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index b2af8f695e60..64cde1a856f4 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -340,7 +340,7 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,
ntfs_sync_inode(dir);
if (IS_DIRSYNC(new_dir))
- ntfs_sync_inode(inode);
+ ntfs_sync_inode(new_dir);
}
if (dir_ni != new_dir_ni)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename
2026-05-06 7:55 ` Zhan Xusheng
@ 2026-05-22 15:24 ` Konstantin Komarov
0 siblings, 0 replies; 3+ messages in thread
From: Konstantin Komarov @ 2026-05-22 15:24 UTC (permalink / raw)
To: Zhan Xusheng; +Cc: ntfs3, linux-kernel, stable, Zhan Xusheng
On 5/6/26 09:55, Zhan Xusheng wrote:
> In ntfs3_rename(), when IS_DIRSYNC(new_dir) is true, the code syncs
> the renamed file inode instead of the target directory new_dir:
> if (IS_DIRSYNC(new_dir))
> ntfs_sync_inode(inode); /* should be new_dir */
>
> DIRSYNC requires that directory metadata changes are written to disk
> synchronously. Since new_dir was modified (a new directory entry was
> added), it is new_dir that must be synced to satisfy the guarantee,
> not the renamed file itself.
>
> This bug has existed since the initial ntfs3 implementation and was
> carried through the refactoring in commit 78ab59fee07f
> ("fs/ntfs3: Rework file operations").
>
> Fix by syncing new_dir instead of inode.
>
> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
> ---
> v2:
> - Cc ntfs3@lists.linux.dev (was missing in v1, see
> https://lore.kernel.org/all/20260422152010.205694-1-zhanxusheng@xiaomi.com/).
> - Add Cc: stable@vger.kernel.org; this is a data-persistence bug under
> DIRSYNC and affects all ntfs3 since 4342306f0f0d.
> v1: https://lore.kernel.org/all/20260422152010.205694-1-zhanxusheng@xiaomi.com/
> ---
> fs/ntfs3/namei.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
> index b2af8f695e60..64cde1a856f4 100644
> --- a/fs/ntfs3/namei.c
> +++ b/fs/ntfs3/namei.c
> @@ -340,7 +340,7 @@ static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,
> ntfs_sync_inode(dir);
>
> if (IS_DIRSYNC(new_dir))
> - ntfs_sync_inode(inode);
> + ntfs_sync_inode(new_dir);
> }
>
> if (dir_ni != new_dir_ni)
Hello,
Sorry for the delay.
Applied, thank you.
Regards,
Konstantin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-22 15:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-22 15:20 [PATCH] fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename Zhan Xusheng
2026-05-06 7:55 ` Zhan Xusheng
2026-05-22 15:24 ` Konstantin Komarov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®