From 8f92bc0deb40070afbb3ba55b522a188e54d0a28 Mon Sep 17 00:00:00 2001 From: Hyeongseok Kim Date: Fri, 10 Jul 2020 10:14:15 +0900 Subject: [PATCH 1/4] exfat: fix wrong size update of stream entry by typo 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 --- file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file.c b/file.c index 99026432a114..999a30407561 100644 --- a/file.c +++ b/file.c @@ -194,7 +194,7 @@ int __exfat_truncate(struct inode *inode, loff_t new_size) 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) { From 01a7b8c4943fcfd563fdfb97c794d92b2b2d5fed Mon Sep 17 00:00:00 2001 From: Ilya Ponetayev Date: Fri, 17 Jul 2020 08:59:39 +0900 Subject: [PATCH 2/4] exfat: fix name_hash computation on big endian systems On-disk format for name_hash field is LE, so it must be explicitly transformed on BE system for proper result. Signed-off-by: Chen Minqiang Signed-off-by: Ilya Ponetayev Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- nls.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nls.c b/nls.c index 57b5a7a4d1f7..a3c927501e67 100644 --- a/nls.c +++ b/nls.c @@ -495,7 +495,7 @@ static int exfat_utf8_to_utf16(struct super_block *sb, 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); @@ -519,7 +519,7 @@ static int exfat_utf8_to_utf16(struct super_block *sb, 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++; } @@ -597,7 +597,7 @@ static int exfat_nls_to_ucs2(struct super_block *sb, 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; @@ -611,7 +611,7 @@ static int exfat_nls_to_ucs2(struct super_block *sb, 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++; } From 93e2334e76b685fe92114a0db6f6ca43e94f19cb Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Mon, 20 Jul 2020 14:08:44 +0900 Subject: [PATCH 3/4] exfat: fix build error on linux-5.4,5.5 kernel Signed-off-by: Namjae Jeon --- super.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/super.c b/super.c index 3993b7e34bb6..52a81898eab9 100644 --- a/super.c +++ b/super.c @@ -4,7 +4,7 @@ */ #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) #include #include #else @@ -237,7 +237,7 @@ static const struct super_operations exfat_sops = { .show_options = exfat_show_options, }; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) enum { Opt_uid, Opt_gid, @@ -303,7 +303,7 @@ static const struct fs_parameter_spec exfat_param_specs[] = { {} }; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 5, 0) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 6, 0) static const struct fs_parameter_description exfat_parameters = { .name = "exfat", .specs = exfat_param_specs, @@ -824,7 +824,7 @@ static int __exfat_fill_super(struct super_block *sb) return ret; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) static int exfat_fill_super(struct super_block *sb, struct fs_context *fc) #else static int exfat_fill_super(struct super_block *sb, void *data, int silent) @@ -832,7 +832,7 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) { struct inode *root_inode; int err; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) struct exfat_sb_info *sbi = sb->s_fs_info; struct exfat_mount_options *opts = &sbi->options; @@ -895,7 +895,7 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) exfat_hash_init(sb); if (!strcmp(sbi->options.iocharset, "utf8")) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) opts->utf8 = 1; #else sbi->options.utf8 = 1; @@ -964,7 +964,7 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) return err; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) static int exfat_get_tree(struct fs_context *fc) { return get_tree_bdev(fc, exfat_fill_super); @@ -1031,13 +1031,9 @@ static struct dentry *exfat_fs_mount(struct file_system_type *fs_type, static struct file_system_type exfat_fs_type = { .owner = THIS_MODULE, .name = "exfat", -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) - .init_fs_context = exfat_init_fs_context, #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) + .init_fs_context = exfat_init_fs_context, .parameters = exfat_parameters, -#else - .parameters = &exfat_parameters, -#endif #else .mount = exfat_fs_mount, #endif From bb455acd1f14a6d10d7657a9e9877a640b579927 Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Sat, 25 Jul 2020 16:48:08 -0700 Subject: [PATCH 4/4] exfat: release 5.8.7 version Description for this pull request: - fix wrong size update of stream entry. - fix endianness of upname in name_hash computation. Signed-off-by: Namjae Jeon --- exfat_fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exfat_fs.h b/exfat_fs.h index b82e60fff7e3..5e77d021f39a 100644 --- a/exfat_fs.h +++ b/exfat_fs.h @@ -11,7 +11,7 @@ #include #include -#define EXFAT_VERSION "5.8.4" +#define EXFAT_VERSION "5.8.7" #define EXFAT_SUPER_MAGIC 0x2011BAB0UL #define EXFAT_ROOT_INO 1