From: Greg Kroah-Hartman Date: Wed, 27 Jul 2022 08:17:21 +0000 (+0200) Subject: 5.18-stable patches X-Git-Tag: v4.9.325~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29cb0a7030a0d0b653014fe9bd56e293f4eb5fd2;p=thirdparty%2Fkernel%2Fstable-queue.git 5.18-stable patches added patches: exfat-use-updated-exfat_chain-directly-during-renaming.patch --- diff --git a/queue-5.18/exfat-use-updated-exfat_chain-directly-during-renaming.patch b/queue-5.18/exfat-use-updated-exfat_chain-directly-during-renaming.patch new file mode 100644 index 00000000000..feb775efe1b --- /dev/null +++ b/queue-5.18/exfat-use-updated-exfat_chain-directly-during-renaming.patch @@ -0,0 +1,51 @@ +From 204e6ceaa1035cb7b92b156517e88842ebb4c7ff Mon Sep 17 00:00:00 2001 +From: Sungjong Seo +Date: Wed, 8 Jun 2022 00:05:21 +0900 +Subject: exfat: use updated exfat_chain directly during renaming + +From: Sungjong Seo + +commit 204e6ceaa1035cb7b92b156517e88842ebb4c7ff upstream. + +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 d8dad2588add ("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: d8dad2588add ("exfat: fix referencing wrong parent directory information after renaming") +Reported-by: Wang Yugui +Signed-off-by: Sungjong Seo +Tested-by: Wang Yugui +Signed-off-by: Namjae Jeon +Signed-off-by: Greg Kroah-Hartman +--- + fs/exfat/namei.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/fs/exfat/namei.c ++++ b/fs/exfat/namei.c +@@ -1198,7 +1198,9 @@ static int __exfat_rename(struct inode * + return -ENOENT; + } + +- exfat_chain_dup(&olddir, &ei->dir); ++ exfat_chain_set(&olddir, EXFAT_I(old_parent_inode)->start_clu, ++ EXFAT_B_TO_CLU_ROUND_UP(i_size_read(old_parent_inode), sbi), ++ EXFAT_I(old_parent_inode)->flags); + dentry = ei->entry; + + ep = exfat_get_dentry(sb, &olddir, dentry, &old_bh); diff --git a/queue-5.18/series b/queue-5.18/series index 6c676f463e2..1572499488c 100644 --- a/queue-5.18/series +++ b/queue-5.18/series @@ -148,3 +148,4 @@ crypto-qat-add-param-check-for-rsa.patch crypto-qat-add-param-check-for-dh.patch crypto-qat-re-enable-registration-of-algorithms.patch exfat-fix-referencing-wrong-parent-directory-informa.patch +exfat-use-updated-exfat_chain-directly-during-renaming.patch