You are not logged in.

#1 2025-12-07 05:31:30

aleck099
Member
Registered: 2019-07-25
Posts: 8

Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

Mounting an exfat fs on 6.17.9 gives:

mount: /run/media/AWD1T: can't read superblock on /dev/sda1.
       dmesg(1) may have more information after failed mount system call.

Related dmesg message:

[  +3.177475] sd 6:0:0:0: [sda] 1953458176 512-byte logical blocks: (1.00 TB/931 GiB)
[  +0.000560] sd 6:0:0:0: [sda] Write Protect is off
[  +0.000004] sd 6:0:0:0: [sda] Mode Sense: 47 00 10 08
[  +0.000547] sd 6:0:0:0: [sda] No Caching mode page found
[  +0.000002] sd 6:0:0:0: [sda] Assuming drive cache: write through
[  +0.041258]  sda: sda1 sda2
[  +0.000094] sd 6:0:0:0: [sda] Attached SCSI disk
[  +4.240762] exFAT-fs (sda1): failed to load alloc-bitmap
[  +0.000006] exFAT-fs (sda1): failed to recognize exfat type

Everything works well on 6.16.8

Offline

#2 2025-12-07 05:32:25

aleck099
Member
Registered: 2019-07-25
Posts: 8

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

fsck.exfat gives:

failed to init locale/codeset
exfatprogs version : 1.3.0
/dev/disk/by-label/AWD1T: clean. directories 259, files 3744

Offline

#3 2025-12-07 07:05:39

ReDress
Member
From: Nairobi
Registered: 2024-11-30
Posts: 202

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

Seems like there's some changes in the bitmap code, as per git logs.

Particularly here it's failing to load, suspect:

commit 9fd688678dd86e3be32a35e3b2c5cc3ef0c4e257
Author: Namjae Jeon <linkinjeon@kernel.org>
Date:   Sat Sep 6 08:13:04 2025 +0900

    exfat: optimize allocation bitmap loading time
   
    Loading the allocation bitmap is very slow if user set the small cluster
    size on large partition.
   
    For optimizing it, This patch uses sb_breadahead() read the allocation
    bitmap. It will improve the mount time.
   
    The following is the result of about 4TB partition(2KB cluster size)
    on my target.
   
    without patch:
    real 0m41.746s
    user 0m0.011s
    sys 0m0.000s
   
    with patch:
    real 0m2.525s
    user 0m0.008s
    sys 0m0.008s
   
    Reviewed-by: Sungjong Seo <sj1557.seo@...>
    Reviewed-by: Yuezhang Mo <Yuezhang.Mo@...>
    Signed-off-by: Namjae Jeon <linkinjeon@...>

Last edited by ReDress (2025-12-07 09:51:27)

Offline

#4 2025-12-07 09:42:05

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 72,057

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

failed to init locale/codeset

Not saying it's related, but just to be sure:

localectl
locale
locale -a

Offline

#5 2025-12-07 11:46:59

gromit
Administrator
From: Germany
Registered: 2024-02-10
Posts: 1,471
Website

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

Also did you already try to run 6.17.9 with the patch reverted? Also there is 6.17.10 in the meantime (which we didn't package for Arch Linux). If you want I can also prepare you a build with both smile

Offline

#6 2025-12-08 16:36:34

aleck099
Member
Registered: 2019-07-25
Posts: 8

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

I tried 6.18.0 with that patch reverted, doesn't work
Failure

Last edited by aleck099 (2025-12-08 16:38:53)

Offline

#7 2025-12-28 11:41:57

aleck099
Member
Registered: 2019-07-25
Posts: 8

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

Confirmed. The bad commit is

commit 79c1587b6cda74deb0c86fc7ba194b92958c793c
Author: Namjae Jeon <linkinjeon@kernel.org>
Date:   Sat Aug 30 14:44:35 2025 +0900

    exfat: validate cluster allocation bits of the allocation bitmap
    
    syzbot created an exfat image with cluster bits not set for the allocation
    bitmap. exfat-fs reads and uses the allocation bitmap without checking
    this. The problem is that if the start cluster of the allocation bitmap
    is 6, cluster 6 can be allocated when creating a directory with mkdir.
    exfat zeros out this cluster in exfat_mkdir, which can delete existing
    entries. This can reallocate the allocated entries. In addition,
    the allocation bitmap is also zeroed out, so cluster 6 can be reallocated.
    This patch adds exfat_test_bitmap_range to validate that clusters used for
    the allocation bitmap are correctly marked as in-use.
    
    Reported-by: syzbot+a725ab460fc1def9896f@syzkaller.appspotmail.com
    Tested-by: syzbot+a725ab460fc1def9896f@syzkaller.appspotmail.com
    Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
    Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
    Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

A new function is added:

/*
 *  Allocation Bitmap Management Functions
 */
static bool exfat_test_bitmap_range(struct super_block *sb, unsigned int clu,
		unsigned int count)
{
	struct exfat_sb_info *sbi = EXFAT_SB(sb);
	unsigned int start = clu;
	unsigned int end = clu + count;
	unsigned int ent_idx, i, b;
	unsigned int bit_offset, bits_to_check;
	__le_long *bitmap_le;
	unsigned long mask, word;

	if (!is_valid_cluster(sbi, start) || !is_valid_cluster(sbi, end - 1))
		return false;

	while (start < end) {
		ent_idx = CLUSTER_TO_BITMAP_ENT(start);
		i = BITMAP_OFFSET_SECTOR_INDEX(sb, ent_idx);
		b = BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent_idx);
        printk("i = %u, b = %u\n", i, b);

		bitmap_le = (__le_long *)sbi->vol_amap[i]->b_data;

		/* Calculate how many bits we can check in the current word */
		bit_offset = b % BITS_PER_LONG;
        printk("bit_offset = %u\n", bit_offset);
		bits_to_check = min(end - start,
				    (unsigned int)(BITS_PER_LONG - bit_offset));
        printk("bits_to_check = %u\n", bits_to_check);

		/* Create a bitmask for the range of bits to check */
		if (bits_to_check >= BITS_PER_LONG)
			mask = ~0UL;
		else
			mask = ((1UL << bits_to_check) - 1) << bit_offset;
		word = lel_to_cpu(bitmap_le[b / BITS_PER_LONG]);
        printk("word = %016lx, mask = %016lx\n", word, mask);

		/* Check if all bits in the mask are set */
		if ((word & mask) != mask)
			return false;

		start += bits_to_check;
	}

	return true;
}

I inserted several printk to show the details when mounting, and it outputs:

i = 0, b = 96
bit_offset = 32
bits_to_check = 20
word = ffc7ffffffffffff, mask = 000fffff00000000

Offline

#8 2025-12-28 19:00:17

loqs
Member
Registered: 2014-03-06
Posts: 18,735

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

If the issue is still present in the latest mainline release candidate then please consider reporting the issue upstream.

Offline

#9 2026-01-10 04:08:14

aleck099
Member
Registered: 2019-07-25
Posts: 8

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

Fixed by fsck.exfat after upgrading exfatprogs to 1.3.1

Offline

#10 2026-01-10 08:13:36

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 99

Re: Linux 6.17.9 fails to mount exfat, but 6.16.8 succeeds

Please mark the thread as solved by prefixing the first post with [SOLVED]

Offline

Board footer

Powered by FluxBB