Re: [PATCH] exfat: do not free clusters from vendor extensions
From: Namjae Jeon
Date: Sat Nov 28 2026 - 21:07:21 EST
On Sat, Nov 28, 2026 at 5:28 PM shaos <shawnq1@xxxxxxx> wrote:
>
> Hello,
>
> exfat_remove_entries() treats every benign secondary entry as a possible
> cluster allocation descriptor. TYPE_VENDOR_EXT is also classified as a
> benign secondary, but a Vendor Extension entry does not describe an
> allocation. The exFAT specification requires AllocationPossible to be
> zero for this entry type (section 7.8.2.1):
>
> https://learn.microsoft.com/en-us/windows/win32/fileio/exfat-specification
>
> A crafted image with a Vendor Extension entry whose AllocationPossible
> bit is set makes exfat_free_benign_secondary_clusters() interpret bytes
> in the extension as a start cluster and size. Removing the entry frees
> those clusters in the allocation bitmap. A later file allocation can
> then reuse and overwrite clusters belonging to another file.
>
> The reproducer mounts a small crafted image writable, removes the planted
> entry, creates a replacement file, and remounts the image. On the
> vulnerable kernel, the replacement data overwrites the original contents
> of /mnt/userdata. The patch excludes only TYPE_VENDOR_EXT; other benign
> secondary entries retain the existing cleanup behavior.
>
> Validation for TYPE_VENDOR_ALLOC is separate: the malformed entry here is
> TYPE_VENDOR_EXT, whose payload does not describe a cluster allocation.
>
> This requires a privileged writable mount of a crafted exFAT image and
> causes data corruption within that volume. It does not demonstrate
> memory corruption or access outside the mounted filesystem.
>
> Tested source revision:
> HEAD commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc
> git tree: fe970b05333fb8e41da21e9e289f652abcc7cba7
> source version: Linux 7.4.0-rc4
> compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0,
> GNU ld 2.38
>
> console output:
> https://gist.githubusercontent.com/shaos26/d37a3a0fa824e655160c05e7ada5fd84/raw/74a0a85aae35462dfd5cdb8dc1ae87ad9226a32a/console-output.txt
> kernel config:
> https://gist.githubusercontent.com/shaos26/d37a3a0fa824e655160c05e7ada5fd84/raw/d63b446bf570fc993d04b3ffeae979b3db4a6eec/kernel-config.txt
> reproducer:
> https://gist.githubusercontent.com/shaos26/d37a3a0fa824e655160c05e7ada5fd84/raw/0f93b4c22ac04f5674776f799e449eef097810b8/poc.c
> patched-kernel config:
> https://gist.githubusercontent.com/shaos26/d37a3a0fa824e655160c05e7ada5fd84/raw/d204ab19c4a8824c83293b94741f80cc0fa52b0a/patched-kernel-config.txt
>
> Build the kernel at the tested revision with the attached configuration.
> The reproducer builds its image and attaches it through /dev/loop0. Build
> it as a static init program and boot it from a minimal initramfs:
>
> gcc -O2 -Wall -Wextra -static -o poc poc.c
> mkdir -p rootfs
> cp poc rootfs/init
> chmod 0755 rootfs/init
> (cd rootfs && find . -print0 | cpio --null -o -H newc) |
> gzip -9 > initramfs.cpio.gz
> timeout 45 qemu-system-x86_64 -m 2G -smp 1 \
> -kernel <linux-tree>/arch/x86/boot/bzImage \
> -initrd initramfs.cpio.gz \
> -append 'console=ttyS0 rdinit=/init panic=-1 oops=panic quiet loglevel=4 acpi=off' \
> -nographic -monitor none -no-reboot
>
> To run the negative control, compile with -DMODE_CONTROL=1 and use that
> binary as /init. On the vulnerable kernel, the trigger reports
> RESULT TRIGGER PASS and /mnt/userdata contains OVERWRITE_PATTERN. With
> this patch, the trigger reports RESULT TRIGGER FAIL because the original
> data remains intact; the negative control reports RESULT CONTROL PASS.
>
> Do not interpret the fixed trigger's FAIL as a patch failure: the
> reproducer defines PASS as observing the corruption. The fixed-kernel
> console log confirms that ORIGINAL_USER_DATA_0123456789AB is preserved.
>
> Do not pass Vendor Extension entries to the cluster-freeing helper:
>
> Fixes: 8258ef28001a ("exfat: handle unreconized benign secondary entries")
> Signed-off-by: shaos <shawnq1@xxxxxxx>
I requested in other patches that you use the real name, but you are
ignoring it.