From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795960392; b=mDrt+MjAJ1vJRRoCeCUsuWC0YObZN7q7xUJvBsEAkrziF/sxz/HZwUdyv5epdq1pMYJa p/H9OLl6d+wEAcsOGx6ujG846Vgkq8l04MvKwoRHBzctRe/Z0tBgyyGE47iYTtsH8Pu0p qEZle7aMWB9RAXIRsMHKsLfr3UI19g/LYnk5HmsdZmO4/pi6PvA7ODnvhWNM6SdEgnfx0 GBy0p+QMVLSVQanqpxTR3DX1/A/Em7tmt5H3Fukv+gqiNPp9ES9++Hwt5se741nwMIO2Y WET2j9RbmfeT4bxbKx6VQ0CComBBaWQ+F5ijURLO20/1R5UJ3KAmWfqcaTIJdKVG54Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795960392; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=Hd886ewhcIGblN5lqGEujwhE7FiCd/dwRdIaN1TtJ+U=; b=ObAKXJ30cOeHxWySNWjh0kFrD6w4k3Sz58J8jj+DV4o0EXVJtI9vBrNO2IBt+XZmuyo3 l/CJfn0sLa/jKfqzFIHf5CAsjCXAzWZbudeBsO0I1vM8DupV7bx8kmrCldOs5I0/plNA2 mvu/fRHZF0t+0C1KHu+iueD0j5r7MhvcfkHPUwHixmsEIM0IXyB40TKa7QGgUv7ibKHfZ t3WCkeMA9bhS5VhHCtGOVFZxBQ0ClVNi0fEWQltVd5UcUOhp3uGykF9NL5M0uiqytP/kF u66tK6tw3jg5WOYvY2zGmMlRdzT5GtmtincIVkHZxMuYuhWHOqWk5zJK8bAm5cbCT6Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=stellman-greene.com; spf=none smtp.mailfrom=stellman-greene.com; dkim=pass header.d=stellman-greene-com.20260707.gappssmtp.com header.i=@stellman-greene-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=q+zaHmaY; arc=none smtp.remote-ip=209.85.222.172 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EA66606A323 for ; Sun, 29 Nov 2026 13:53:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6EA66606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stellman-greene.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=stellman-greene.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stellman-greene-com.20260707.gappssmtp.com header.i=@stellman-greene-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=q+zaHmaY Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-949657a20d7so867386985a.1 for ; Sun, 29 Nov 2026 05:53:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stellman-greene-com.20260707.gappssmtp.com; s=20260707; t=1795960391; x=1796565191; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Hd886ewhcIGblN5lqGEujwhE7FiCd/dwRdIaN1TtJ+U=; b=q+zaHmaYUIMPtW3upcg7wmbfS3lVAmL1L1FI1nfth92IjE7ffPBvAAlvpqjQH1tf2w 7r68uLKyeoJR4z7aOfdlrkjv6lFUyXmBsFzQJ3KI1vh4vy/mapekVHV3YT7twPbg6/A/ eJEaXleFoYJaDpyDn27PXVXPRG/LZjQQ1AxZ8Pm17AO9T+TlXJJazTajLfCaMUz6DUeM on8PTlwv+SAZ3pyapMNfw85UEcyOjDrBs9mQhmMgvjVOcH7ZeJk+FIC7BuydXVIQnrD2 /qu5QIUh7TgAiS0CNlKEQqM7JBpxrqx36RHvoTkIq+IvM7e90c6Y65zJpreouKme9jzC Bd4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795960391; x=1796565191; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Hd886ewhcIGblN5lqGEujwhE7FiCd/dwRdIaN1TtJ+U=; b=AxwappBr7zs0KKOx2L9a43j6100mNhjKxFY1V5ZnTU3ZEkP51xDrcKudK6dyUlINVl IlYkXg8D5cFOTK7ITspApv8Qi9Fl1QrR/eyzRsLRTRg9gT/L569RnANvTLIRiSXbg9Vc KoSrM5iaNNtarvE4iQQZQcHEx71wloNEFt1WPsKLWkUQy1960nFN/mNXGEdy6JTP+3dr Vm5gGznb5Fep8YAgQLBKt5Minxwq9Oi1uvFWVoeRWV5pmX20MdXgEQuaEtFlUSdlw7ph x4kAhYizRyb328nxzaAAGlvZnI8l3x3Jb8DouRehbFfexlgS96ROdqOSAzhDuq0XULf2 MerA== X-Forwarded-Encrypted: i=1; AL+hErG4R/p5ktHqliW3bQZl3WH5AmnXqxdeuD/N8L4VGgPLbbI0WYj2bBaBxeu0gP51wipkz0IoFbIrrKi8SO4=@vger.kernel.org X-Gm-Message-State: APuU4Z+r+XhtjnU/cMeozWi2f3FUkabtPJJrHg1wcNWLTJm+EEN59heQ kDoBrkBlyKumvDgjhyEvbMHGhPeFP+O/V93JuJUrK8pVzeBRGBEKuOIADbfpwCLHcCiTTY8Cyyd LxXryflk= X-Gm-Gg: AZFdTZfeR3v4C1VlN1TDlU+LxfxiXisJ1cyufStt6zIeBqqj5iJwn2Hb1jc9eRrDUah Dr+o2jwTedc+YS1p2ztR0GoYy6awD7zqbk+YBqPTxwjhufu6jQsqC7pgmHUNaSgkKi2D6lkqQN/ npJMAQBTm5MjFeX3WkyL1pNyLLvZBQ1v7+mVBecyz871S2sWxN4xy3bpHwRbltYrlNMw/MLwA8e h0P+jlP1MdnqWhndSBFrxVu/WwrbThuiH2TQKhrtNSnEPUsiJ3dIb/gmQqGJlXL3vTJh5bKxgcb +IMM13R/R2kUMku9LrDlOu+LTRTo0YeYpTJSOQqWY72bnEwwTj+++KvdXpDsi3WFsD//Kf4RvPA xO6alNMXSppwJcDQZrp3sCosnKVe0pgLZB90ftlx9vkyAZAagzsV0h8t8wZM9oV7zRJN3I7xUBh aoieR72Ef3xsxWKRIatdfO5QabBn6NQwXt3kVCcoTTEf/HCnINn7ZvnMZ1+DwYn358bseemas+Z yCYTX78EYs2S1REyh9hZM8AyGcB00ciW10clgi+mhxEQFrfvkoTzy4j0ZEs/SvZt1Lwk0h6y4cF muwdUN2BYyHsqRUa+YvN+XAIs3fovj/7e1GVCB3WXwxa9Diu36pK9NckUrF4dn1Rj+fACKwWxWj /Kwc= X-Received: by 2002:a05:620a:4146:b0:949:6841:60d4 with SMTP id af79cd13be357-949ba95e5eamr5414257185a.24.1795960391365; Sun, 29 Nov 2026 05:53:11 -0800 (PST) Received: from Mac.mynetworksettings.com ([2600:4041:5c28:200:3c29:a645:a023:b4a7]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949ca6a0693sm2064327785a.20.2026.11.29.05.53.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 05:53:11 -0800 (PST) From: Andrew Stellman To: Namjae Jeon , Sungjong Seo Cc: Yuezhang Mo , exfat@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] exfat: reject cluster counts above the exFAT maximum Date: Sun, 29 Nov 2026 08:53:09 -0500 Message-ID: <20261129135309.80871-1-bugs@stellman-greene.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Andrew Stellman 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 --- A reproducer is available on request. fs/exfat/super.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/exfat/super.c b/fs/exfat/super.c index 4943cef977418..762ebd14cb43a 100644 --- a/fs/exfat/super.c +++ b/fs/exfat/super.c @@ -444,6 +444,7 @@ static int exfat_read_boot_sector(struct super_block *sb) { struct boot_sector *p_boot; struct exfat_sb_info *sbi = EXFAT_SB(sb); + u32 clu_count; /* set block size to read super block */ if (!sb_min_blocksize(sb, 512)) { @@ -514,9 +515,13 @@ static int exfat_read_boot_sector(struct super_block *sb) sbi->data_start_sector = le32_to_cpu(p_boot->clu_offset); sbi->data_start_bytes = sbi->data_start_sector << p_boot->sect_size_bits; sbi->num_sectors = le64_to_cpu(p_boot->vol_length); + clu_count = le32_to_cpu(p_boot->clu_count); + if (clu_count > EXFAT_MAX_NUM_CLUSTER) { + exfat_err(sb, "bogus cluster count : %u", clu_count); + return -EINVAL; + } /* because the cluster index starts with 2 */ - sbi->num_clusters = le32_to_cpu(p_boot->clu_count) + - EXFAT_RESERVED_CLUSTERS; + sbi->num_clusters = clu_count + EXFAT_RESERVED_CLUSTERS; sbi->root_dir = le32_to_cpu(p_boot->root_cluster); sbi->dentries_per_clu_bits = sbi->cluster_size_bits - DENTRY_SIZE_BITS; base-commit: bb13fcd7f4385fdf64340e5561a26bd951bc3d78 -- 2.53.0