From f8930c4360847d3d347c30971e71ad9510cbbfac Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 24 Jul 2020 11:43:09 +0200 Subject: [PATCH] 5.7-stable patches added patches: exfat-fix-name_hash-computation-on-big-endian-systems.patch exfat-fix-overflow-issue-in-exfat_cluster_to_sector.patch exfat-fix-wrong-hint_stat-initialization-in-exfat_find_dir_entry.patch exfat-fix-wrong-size-update-of-stream-entry-by-typo.patch --- ...sh-computation-on-big-endian-systems.patch | 62 +++++++++++++++++++ ...low-issue-in-exfat_cluster_to_sector.patch | 34 ++++++++++ ...itialization-in-exfat_find_dir_entry.patch | 33 ++++++++++ ...-size-update-of-stream-entry-by-typo.patch | 32 ++++++++++ queue-5.7/series | 4 ++ 5 files changed, 165 insertions(+) create mode 100644 queue-5.7/exfat-fix-name_hash-computation-on-big-endian-systems.patch create mode 100644 queue-5.7/exfat-fix-overflow-issue-in-exfat_cluster_to_sector.patch create mode 100644 queue-5.7/exfat-fix-wrong-hint_stat-initialization-in-exfat_find_dir_entry.patch create mode 100644 queue-5.7/exfat-fix-wrong-size-update-of-stream-entry-by-typo.patch diff --git a/queue-5.7/exfat-fix-name_hash-computation-on-big-endian-systems.patch b/queue-5.7/exfat-fix-name_hash-computation-on-big-endian-systems.patch new file mode 100644 index 00000000000..06eeb251706 --- /dev/null +++ b/queue-5.7/exfat-fix-name_hash-computation-on-big-endian-systems.patch @@ -0,0 +1,62 @@ +From db415f7aae07cadcabd5d2a659f8ad825c905299 Mon Sep 17 00:00:00 2001 +From: Ilya Ponetayev +Date: Thu, 16 Jul 2020 17:27:53 +0900 +Subject: exfat: fix name_hash computation on big endian systems + +From: Ilya Ponetayev + +commit db415f7aae07cadcabd5d2a659f8ad825c905299 upstream. + +On-disk format for name_hash field is LE, so it must be explicitly +transformed on BE system for proper result. + +Fixes: 370e812b3ec1 ("exfat: add nls operations") +Cc: stable@vger.kernel.org # v5.7 +Signed-off-by: Chen Minqiang +Signed-off-by: Ilya Ponetayev +Reviewed-by: Sungjong Seo +Signed-off-by: Namjae Jeon +Signed-off-by: Greg Kroah-Hartman + +--- + fs/exfat/nls.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/fs/exfat/nls.c ++++ b/fs/exfat/nls.c +@@ -495,7 +495,7 @@ static int exfat_utf8_to_utf16(struct su + struct exfat_uni_name *p_uniname, int *p_lossy) + { + int i, unilen, lossy = NLS_NAME_NO_LOSSY; +- unsigned short upname[MAX_NAME_LENGTH + 1]; ++ __le16 upname[MAX_NAME_LENGTH + 1]; + unsigned short *uniname = p_uniname->name; + + WARN_ON(!len); +@@ -523,7 +523,7 @@ static int exfat_utf8_to_utf16(struct su + exfat_wstrchr(bad_uni_chars, *uniname)) + lossy |= NLS_NAME_LOSSY; + +- upname[i] = exfat_toupper(sb, *uniname); ++ upname[i] = cpu_to_le16(exfat_toupper(sb, *uniname)); + uniname++; + } + +@@ -614,7 +614,7 @@ static int exfat_nls_to_ucs2(struct supe + struct exfat_uni_name *p_uniname, int *p_lossy) + { + int i = 0, unilen = 0, lossy = NLS_NAME_NO_LOSSY; +- unsigned short upname[MAX_NAME_LENGTH + 1]; ++ __le16 upname[MAX_NAME_LENGTH + 1]; + unsigned short *uniname = p_uniname->name; + struct nls_table *nls = EXFAT_SB(sb)->nls_io; + +@@ -628,7 +628,7 @@ static int exfat_nls_to_ucs2(struct supe + exfat_wstrchr(bad_uni_chars, *uniname)) + lossy |= NLS_NAME_LOSSY; + +- upname[unilen] = exfat_toupper(sb, *uniname); ++ upname[unilen] = cpu_to_le16(exfat_toupper(sb, *uniname)); + uniname++; + unilen++; + } diff --git a/queue-5.7/exfat-fix-overflow-issue-in-exfat_cluster_to_sector.patch b/queue-5.7/exfat-fix-overflow-issue-in-exfat_cluster_to_sector.patch new file mode 100644 index 00000000000..06840122072 --- /dev/null +++ b/queue-5.7/exfat-fix-overflow-issue-in-exfat_cluster_to_sector.patch @@ -0,0 +1,34 @@ +From 43946b70494beefe40ec1b2ba4744c0f294d7736 Mon Sep 17 00:00:00 2001 +From: Namjae Jeon +Date: Fri, 3 Jul 2020 11:16:32 +0900 +Subject: exfat: fix overflow issue in exfat_cluster_to_sector() + +From: Namjae Jeon + +commit 43946b70494beefe40ec1b2ba4744c0f294d7736 upstream. + +An overflow issue can occur while calculating sector in +exfat_cluster_to_sector(). It needs to cast clus's type to sector_t +before left shifting. + +Fixes: 1acf1a564b60 ("exfat: add in-memory and on-disk structures and headers") +Cc: stable@vger.kernel.org # v5.7 +Reviewed-by: Sungjong Seo +Signed-off-by: Namjae Jeon +Signed-off-by: Greg Kroah-Hartman + +--- + fs/exfat/exfat_fs.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/exfat/exfat_fs.h ++++ b/fs/exfat/exfat_fs.h +@@ -375,7 +375,7 @@ static inline bool exfat_is_last_sector_ + static inline sector_t exfat_cluster_to_sector(struct exfat_sb_info *sbi, + unsigned int clus) + { +- return ((clus - EXFAT_RESERVED_CLUSTERS) << sbi->sect_per_clus_bits) + ++ return ((sector_t)(clus - EXFAT_RESERVED_CLUSTERS) << sbi->sect_per_clus_bits) + + sbi->data_start_sector; + } + diff --git a/queue-5.7/exfat-fix-wrong-hint_stat-initialization-in-exfat_find_dir_entry.patch b/queue-5.7/exfat-fix-wrong-hint_stat-initialization-in-exfat_find_dir_entry.patch new file mode 100644 index 00000000000..a30114c6915 --- /dev/null +++ b/queue-5.7/exfat-fix-wrong-hint_stat-initialization-in-exfat_find_dir_entry.patch @@ -0,0 +1,33 @@ +From d2fa0c337d97a5490190b9f3b9c73c8f9f3602a1 Mon Sep 17 00:00:00 2001 +From: Namjae Jeon +Date: Fri, 3 Jul 2020 11:19:46 +0900 +Subject: exfat: fix wrong hint_stat initialization in exfat_find_dir_entry() + +From: Namjae Jeon + +commit d2fa0c337d97a5490190b9f3b9c73c8f9f3602a1 upstream. + +We found the wrong hint_stat initialization in exfat_find_dir_entry(). +It should be initialized when cluster is EXFAT_EOF_CLUSTER. + +Fixes: ca06197382bd ("exfat: add directory operations") +Cc: stable@vger.kernel.org # v5.7 +Reviewed-by: Sungjong Seo +Signed-off-by: Namjae Jeon +Signed-off-by: Greg Kroah-Hartman + +--- + fs/exfat/dir.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/exfat/dir.c ++++ b/fs/exfat/dir.c +@@ -1160,7 +1160,7 @@ found: + ret = exfat_get_next_cluster(sb, &clu.dir); + } + +- if (ret || clu.dir != EXFAT_EOF_CLUSTER) { ++ if (ret || clu.dir == EXFAT_EOF_CLUSTER) { + /* just initialized hint_stat */ + hint_stat->clu = p_dir->dir; + hint_stat->eidx = 0; diff --git a/queue-5.7/exfat-fix-wrong-size-update-of-stream-entry-by-typo.patch b/queue-5.7/exfat-fix-wrong-size-update-of-stream-entry-by-typo.patch new file mode 100644 index 00000000000..cba829f5493 --- /dev/null +++ b/queue-5.7/exfat-fix-wrong-size-update-of-stream-entry-by-typo.patch @@ -0,0 +1,32 @@ +From 41e3928f8c58184fcf0bb22e822af39a436370c7 Mon Sep 17 00:00:00 2001 +From: Hyeongseok Kim +Date: Wed, 8 Jul 2020 18:52:33 +0900 +Subject: exfat: fix wrong size update of stream entry by typo + +From: Hyeongseok Kim + +commit 41e3928f8c58184fcf0bb22e822af39a436370c7 upstream. + +The stream.size field is updated to the value of create timestamp +of the file entry. Fix this to use correct stream entry pointer. + +Fixes: 29bbb14bfc80 ("exfat: fix incorrect update of stream entry in __exfat_truncate()") +Signed-off-by: Hyeongseok Kim +Signed-off-by: Namjae Jeon +Signed-off-by: Greg Kroah-Hartman + +--- + fs/exfat/file.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/exfat/file.c ++++ b/fs/exfat/file.c +@@ -175,7 +175,7 @@ int __exfat_truncate(struct inode *inode + ep2->dentry.stream.size = 0; + } else { + ep2->dentry.stream.valid_size = cpu_to_le64(new_size); +- ep2->dentry.stream.size = ep->dentry.stream.valid_size; ++ ep2->dentry.stream.size = ep2->dentry.stream.valid_size; + } + + if (new_size == 0) { diff --git a/queue-5.7/series b/queue-5.7/series index 7964cc31e42..e7f9cb82e24 100644 --- a/queue-5.7/series +++ b/queue-5.7/series @@ -24,3 +24,7 @@ drm-amd-display-add-dmcub-check-on-renoir.patch dm-mpath-pass-io-start-time-to-path-selector.patch dm-do-not-use-waitqueue-for-request-based-dm.patch sunrpc-reverting-d03727b248d0-nfsv4-fix-close-not-waiting-for-direct-io-compeletion.patch +exfat-fix-overflow-issue-in-exfat_cluster_to_sector.patch +exfat-fix-wrong-hint_stat-initialization-in-exfat_find_dir_entry.patch +exfat-fix-wrong-size-update-of-stream-entry-by-typo.patch +exfat-fix-name_hash-computation-on-big-endian-systems.patch -- 2.47.3