fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename
Subsystems (2)
PATCH 1/1 fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename
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.
--- fs/ntfs3/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/namei.c +1 -1
@@ -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)
Signature · 1 line
2.43.0
PATCH 1/1 fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename
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.
---
v2:
- Cc [email protected] (was missing in v1, see
https://lore.kernel.org/all/[email protected]/).
- Add Cc: [email protected]; this is a data-persistence bug under DIRSYNC and affects all ntfs3 since 4342306f0f0d.
v1: https://lore.kernel.org/all/[email protected]/
--- fs/ntfs3/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/namei.c +1 -1
@@ -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)
Signature · 1 line
2.43.0
Konstantin Komarov
maintainerQuoted 35 lines · Zhan Xusheng
In
ntfs3_rename(), whenIS_DIRSYNC(new_dir)is true, the code syncs the renamed file inode instead of the target directorynew_dir:
if (IS_DIRSYNC(new_dir))
ntfs_sync_inode(inode); /* should benew_dir*/DIRSYNC requires that directory metadata changes are written to disk synchronously. Since
new_dirwas modified (a new directory entry was added), it isnew_dirthat 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_dirinstead of inode.Fixes 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")Signed-off-by Zhan Xusheng <[email protected]>---
v2:
- Cc [email protected] (was missing in v1, seehttps://lore.kernel.org/all/[email protected]/). - Add Cc: [email protected]; this is a data-persistence bug under DIRSYNC and affects all ntfs3 since 4342306f0f0d. v1: https://lore.kernel.org/all/[email protected]/ --- fs/ntfs3/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ntfs3/namei.c +0
-0
fs/ntfs3/namei.c static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir, · line 346
Quoted 8 lines
fs/ntfs3/namei.c +1
-1@@ -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