]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs/ntfs3: fix syncing wrong inode on DIRSYNC cross-directory rename
authorZhan Xusheng <zhanxusheng1024@gmail.com>
Wed, 6 May 2026 07:55:54 +0000 (15:55 +0800)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Tue, 2 Jun 2026 15:02:27 +0000 (17:02 +0200)
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>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/namei.c

index b2af8f695e60fc314986f7b277a02faf0cd50f71..64cde1a856f4477a02b4619f3fa32c12a8c01098 100644 (file)
@@ -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)