Skip to content

Commit 204e6ce

Browse files
Sungjong Seonamjaejeon
authored andcommitted
exfat: use updated exfat_chain directly during renaming
In order for a file to access its own directory entry set, exfat_inode_info(ei) has two copied values. One is ei->dir, which is a snapshot of exfat_chain of the parent directory, and the other is ei->entry, which is the offset of the start of the directory entry set in the parent directory. Since the parent directory can be updated after the snapshot point, it should be used only for accessing one's own directory entry set. However, as of now, during renaming, it could try to traverse or to allocate clusters via snapshot values, it does not make sense. This potential problem has been revealed when exfat_update_parent_info() was removed by commit d8dad25 ("exfat: fix referencing wrong parent directory information after renaming"). However, I don't think it's good idea to bring exfat_update_parent_info() back. Instead, let's use the updated exfat_chain of parent directory diectly. Fixes: d8dad25 ("exfat: fix referencing wrong parent directory information after renaming") Reported-by: Wang Yugui <wangyugui@e16-tech.com> Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com> Tested-by: Wang Yugui <wangyugui@e16-tech.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent f2906aa commit 204e6ce

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/exfat/namei.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,9 @@ static int __exfat_rename(struct inode *old_parent_inode,
11981198
return -ENOENT;
11991199
}
12001200

1201-
exfat_chain_dup(&olddir, &ei->dir);
1201+
exfat_chain_set(&olddir, EXFAT_I(old_parent_inode)->start_clu,
1202+
EXFAT_B_TO_CLU_ROUND_UP(i_size_read(old_parent_inode), sbi),
1203+
EXFAT_I(old_parent_inode)->flags);
12021204
dentry = ei->entry;
12031205

12041206
ep = exfat_get_dentry(sb, &olddir, dentry, &old_bh);

0 commit comments

Comments
 (0)