From nobody Fri Jun 19 19:36:32 2026 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA17C23EAAD for ; Wed, 22 Apr 2026 15:59:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776873543; cv=none; b=KyvAvwEgev8RD+RdUolbBGlRr0pgWTTSGeXYplIm1//NxSHU5vn332i+lxg+BurGpzO+byPmyCR6FkFQ2l3H9B/8bQ9MF8XCR2umsd13JtjBFj1jlqQ4L2TXbCMWZRTS7cPZ/A5/17SXY5Bao1eKlao4FqRLY2yO+D/H81MJ9Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776873543; c=relaxed/simple; bh=1EyxcKO/nUApGhARmp1AedGru9RgJuydJVerpTfmZPY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lHcwbswlnwQBujMYecUIxMsu+1BjVCQZOzdBXoJ99faQk3mCbCgkzCLs2cSHY/QyLdYmezLnPP+XAmhpvCb38p3JVODINS+DxzGjIVHtnYlA3sKeqY/0hiHLHAdBTEo6tN8gGH5ZybTPA6DeEkhzPln3TReSzzmLTSkx4JWWUBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kAi5i+VD; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kAi5i+VD" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-8ec9f099fc6so309157785a.0 for ; Wed, 22 Apr 2026 08:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776873541; x=1777478341; 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; bh=hkTj2C9YliubRyWKE8nCInm/VBiYVrnMT7BPVcl4dBw=; b=kAi5i+VDkwGNcovTuJR8aeog2qupFbdR30y0/17VxvEhBhkQkmbR16cipYs+AmUXTk o/mh98OgmkDY0dmJ45tGP84t0Sz8pDaMK2U/9R6h/sbKq5sHXx1jfbB8OPjBMxSAZa+i eQJiPatNL6ZaR/SnoXYJuq4liGsvVGCxME0vFoNghcl4hIt2YcbBHtK4RXF4mSueQNy/ 0aKmTgAVjInAaIoiAoYkTMk9hiVk/9CJzNrXD2khBejk3tHxSKS35S1Q6c4mqeGn5gBw +4rprbkwt42M9jF8akFgHwpuX9qd71sY0OTySsA6B4VHcdBqrl4nQKNPzJ/CV5KdCS2C LkmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776873541; x=1777478341; 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; bh=hkTj2C9YliubRyWKE8nCInm/VBiYVrnMT7BPVcl4dBw=; b=XiLYeXcqw+ZMe3l99pABzZn8r9DY1cUVCkSPJSxe8RLLgM/18vqeNM/P0RnaVnApry 7gBcgF7nZwJW2DXOxeY7FBdiEddqktwXU1a84pRQGsQUqFM27Xyta6n9TY+t4KtTbNng NPlzd2PCXXt0NOvUG299PSaDS6GEqrSRazw3vWIOtSbLd+dEaKMafNaAfQ4fE1f9aGLl Z7riEYu7faGwKH9EuDUsBFI5JoePSvpQhAvfd84W5Avtlrl4TtIdTynCOkVRACrPyKG7 T1JiTTwXKjUx3eE7CQ03oWo+b2EFw8eEBTIXqER5rMRizx8oBf1avoh7owhmGpt+kTVi vPBg== X-Forwarded-Encrypted: i=1; AFNElJ8jbV8smVUhyWnE55Ck6EAODc0svvkDWXXx/0/keYWZywNggfzZRa5qwNYR83NwbPkcR33LeQG/KyIbgCA=@vger.kernel.org X-Gm-Message-State: AOJu0YxBcZabx0+Ie6V0k3gIhqQl9Ht2ZETVEG4ugSG1ShHCBnBG+ie6 JQxysJHaRxgzV0Onf0vM/5+GV/cJaguqltFK9jLLnD3VgzP/aZd/N3UD X-Gm-Gg: AeBDietUpaiOKoZmXMW0X/i+/VVqNEo75I8DgPQM5y7wo5s7uGKstKHOJjcv+4ErlQJ oSAw1WmsA9ktc4ruqdNvDu9YYCxF9UJivZVJQS31V664yA5rALXv1xEFzv5swJVg6L9qozLEOEU mERNJnIPY1ARN4tI+HUiQi25er2PvhpjlAlCvvlm5l6dtYIpIzu11crxMLwg8MQjsQToKHdPh8d ood8HTG9tZJKH59lpqb2STioGD4k1PN5jNNi6N88Xk9blp3Qao6vqOfC41gR/Rdt8v0XIX+QYSW J7PP0D9qWyxVHbHrG3orL0Kt50lBFw7/vVgCQmzLchA8MkqL19Un5HM8QK+1IiFIvJLDHu5B3h1 icX8hqKoX5dVcH9TH4CtvGFvCVx5Ygf7F8oCs/CLvU0vbiZMAcuGruxy+Aca1/ZGT3EODL/tdOh OoPa8xNtyW7uCZ5z+yf68QUrupiP4SWR9ipGh/rx4/3kWwHs+Y5NgOT2CnQ6MH1jhb4iNWlkqJN MUttdKueJVZt1m7DQf9BkdNQiJEJgI= X-Received: by 2002:a05:620a:46a9:b0:8cf:d70d:cf0e with SMTP id af79cd13be357-8e79236d606mr3376452385a.47.1776873540726; Wed, 22 Apr 2026 08:59:00 -0700 (PDT) Received: from server0 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ee585e9fcdsm496696885a.16.2026.04.22.08.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 08:59:00 -0700 (PDT) From: Michael Bommarito To: Namjae Jeon , Sungjong Seo , Yuezhang Mo Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] exfat: fix potential use-after-free in exfat_find_dir_entry() Date: Wed, 22 Apr 2026 11:58:44 -0400 Message-ID: <20260422155844.1967148-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In exfat_find_dir_entry(), the buffer_head obtained from exfat_get_dentry() is released with brelse(bh) before the fall-through TYPE_EXTEND branch reads the directory entry through ep (which points into bh->b_data): brelse(bh); if (entry_type =3D=3D TYPE_EXTEND) { ... len =3D exfat_extract_uni_name(ep, entry_uniname); ... } After brelse() drops our reference, nothing guarantees that the underlying page backing bh->b_data remains valid for the subsequent exfat_extract_uni_name() read. This is the same pattern fixed in commit fc961522ddbd ("exfat: Fix potential use after free in exfat_load_upcase_table()"). Move brelse(bh) so it runs after ep is no longer dereferenced on each branch. Confirmed on QEMU x86_64 with CONFIG_KASAN=3Dy + CONFIG_DEBUG_PAGEALLOC=3Dy + CONFIG_PAGE_POISONING=3Dy on linux-next, using a crafted exFAT image (long filename with same-hash collisions forcing the TYPE_EXTEND path). With a debug-only invalidate_bdev() inserted between brelse(bh) and the ep read to make the stale-deref window deterministic, the unpatched kernel faults: BUG: KASAN: use-after-free in exfat_find_dir_entry+0x133b/0x15a0 BUG: unable to handle page fault for address: ffff88801a5fa0c2 Oops: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN NOPTI RIP: 0010:exfat_find_dir_entry+0x1188/0x15a0 With this patch applied, the same instrumented harness completes cleanly under the same sanitizer stack. I have not reproduced a crash on an uninstrumented kernel under ordinary reclaim; the instrumented A/B establishes the lifetime violation and that the patch closes it, not an unaided triggerability claim. Fixes: ca06197382bd ("exfat: add directory operations") Cc: stable@vger.kernel.org Signed-off-by: Michael Bommarito Assisted-by: Claude:claude-opus-4-7 --- fs/exfat/dir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index ac008ccaa97d..561fd2349218 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -1027,12 +1027,12 @@ int exfat_find_dir_entry(struct super_block *sb, st= ruct exfat_inode_info *ei, continue; } =20 - brelse(bh); if (entry_type =3D=3D TYPE_EXTEND) { unsigned short entry_uniname[16], unichar; =20 if (step !=3D DIRENT_STEP_NAME || name_len >=3D MAX_NAME_LENGTH) { + brelse(bh); step =3D DIRENT_STEP_FILE; continue; } @@ -1043,6 +1043,7 @@ int exfat_find_dir_entry(struct super_block *sb, stru= ct exfat_inode_info *ei, uniname +=3D EXFAT_FILE_NAME_LEN; =20 len =3D exfat_extract_uni_name(ep, entry_uniname); + brelse(bh); name_len +=3D len; =20 unichar =3D *(uniname+len); @@ -1061,6 +1062,7 @@ int exfat_find_dir_entry(struct super_block *sb, stru= ct exfat_inode_info *ei, continue; } =20 + brelse(bh); if (entry_type & (TYPE_CRITICAL_SEC | TYPE_BENIGN_SEC)) { if (step =3D=3D DIRENT_STEP_SECD) { --=20 2.53.0