exfat: reject cluster counts above the exFAT maximum

exfat_read_boot_sector() adds the two reserved clusters to the on-disk
ClusterCount without a range check, so a ClusterCount of 0xffffffff
wraps num_clusters to 1, and the FAT length check that follows uses the
wrapped value. With a crafted 64 MiB image, a read-only mount got as
far as the allocation bitmap size check, which reported a required size
of 536870912 bytes, before failing.

Reject a ClusterCount above EXFAT_MAX_NUM_CLUSTER before adding the
reserved clusters. This changes behavior for images with a
ClusterCount above that limit: the mount is now rejected at boot-sector
validation.

Tested in an arm64 QEMU guest with KASAN: the crafted image now fails
with "bogus cluster count", and an ordinary image mounts with and
without the patch.

The issue was found by Claude running Quality Playbook, an LLM-driven
code review tool:
https://github.com/andrewstellman/quality-playbook
The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with
Claude Opus 5.5, and both were reviewed by me.

Fixes: 719c1e182916 ("exfat: add super block operations")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 file changed