* [PATCH] exfat: fix upcase table validation to require all entries consumed
@ 2026-10-25 12:26 Reid Downing
2026-10-27 8:01 ` David Timber
0 siblings, 1 reply; 2+ messages in thread
From: Reid Downing @ 2026-10-25 12:26 UTC (permalink / raw)
To: linkinjeon, sj1557.seo
Cc: yuezhang.mo, linux-fsdevel, linux-kernel, Reid Downing
exfat_load_upcase_table() and exfat_load_default_upcase_table()
accept the table when index >= 0xFFFF, but a correct table must
process all 0x10000 entries, leaving index at 0x10000.
a crafted filesystem image can use the compressed skip encoding
to advance index to exactly 0xFFFF without filling the remaining
entries. the checksum covers only the on-disk bytes so it can be
made to match. the kernel accepts the table while the unfilled
entries silently remain zero, causing incorrect uppercase mappings
for the affected codepoints and breaking case-insensitive filename
comparison for non-ascii characters.
fix both checks to require index >= UTBL_COUNT.
Fixes: 370e812b3ec1 ("exfat: add nls operations")
Signed-off-by: Reid Downing <skibletz@gmail.com>
---
fs/exfat/nls.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/exfat/nls.c b/fs/exfat/nls.c
index 055447edc..7afc86ea2 100644
--- a/fs/exfat/nls.c
+++ b/fs/exfat/nls.c
@@ -691,7 +691,7 @@ static int exfat_load_upcase_table(struct super_block *sb,
brelse(bh);
}
- if (index >= 0xFFFF && utbl_checksum == chksum)
+ if (index >= UTBL_COUNT && utbl_checksum == chksum)
return 0;
exfat_err(sb, "failed to load upcase table (idx : 0x%08x, chksum : 0x%08x, utbl_chksum : 0x%08x)",
@@ -728,7 +728,7 @@ static int exfat_load_default_upcase_table(struct super_block *sb)
}
}
- if (index >= 0xFFFF)
+ if (index >= UTBL_COUNT)
return 0;
/* FATAL error: default upcase table has error */
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] exfat: fix upcase table validation to require all entries consumed
2026-10-25 12:26 [PATCH] exfat: fix upcase table validation to require all entries consumed Reid Downing
@ 2026-10-27 8:01 ` David Timber
0 siblings, 0 replies; 2+ messages in thread
From: David Timber @ 2026-10-27 8:01 UTC (permalink / raw)
To: Reid Downing, linkinjeon, sj1557.seo
Cc: yuezhang.mo, linux-fsdevel, linux-kernel
On 10/25/26 12:26, Reid Downing wrote:
> exfat_load_upcase_table() and exfat_load_default_upcase_table()
> accept the table when index >= 0xFFFF, but a correct table must
> process all 0x10000 entries, leaving index at 0x10000.
>
> a crafted filesystem image can use the compressed skip encoding
> to advance index to exactly 0xFFFF without filling the remaining
> entries. the checksum covers only the on-disk bytes so it can be
> made to match. the kernel accepts the table while the unfilled
> entries silently remain zero, causing incorrect uppercase mappings
> for the affected codepoints and breaking case-insensitive filename
> comparison for non-ascii characters.
>
> fix both checks to require index >= UTBL_COUNT.
>
> Fixes: 370e812b3ec1 ("exfat: add nls operations")
> Signed-off-by: Reid Downing <skibletz@gmail.com>
> ---
> fs/exfat/nls.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/exfat/nls.c b/fs/exfat/nls.c
> index 055447edc..7afc86ea2 100644
> --- a/fs/exfat/nls.c
> +++ b/fs/exfat/nls.c
> @@ -691,7 +691,7 @@ static int exfat_load_upcase_table(struct super_block *sb,
> brelse(bh);
> }
>
> - if (index >= 0xFFFF && utbl_checksum == chksum)
> + if (index >= UTBL_COUNT && utbl_checksum == chksum)
> return 0;
>
> exfat_err(sb, "failed to load upcase table (idx : 0x%08x, chksum : 0x%08x, utbl_chksum : 0x%08x)",
> @@ -728,7 +728,7 @@ static int exfat_load_default_upcase_table(struct super_block *sb)
> }
> }
>
> - if (index >= 0xFFFF)
> + if (index >= UTBL_COUNT)
> return 0;
>
> /* FATAL error: default upcase table has error */
Please see the following unmerged patch:
https://lore.kernel.org/linux-fsdevel/20260414055643.1833401-5-dxdt@dev.snart.me/
How about
index == UTBL_COUNT
This is more of a compatibility issue than a security issue. A bit rot
in the storage hardware can definitely cause benign corruption. I've
observed that EXFAT.sys(the Windows implementation) strictly expects the
table to end exactly with 0x1000.
Also, expect the size of the table aligned to 2 bytes, as per my
original patch. You're more than welcome to cc me in the commit message.
I was just too busy to get back working on my patches.
Thanks,
Davo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-27 8:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25 12:26 [PATCH] exfat: fix upcase table validation to require all entries consumed Reid Downing
2026-10-27 8:01 ` David Timber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®