Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81ED75FDA7 for ; Thu, 4 Dec 2025 16:07:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764864472; cv=none; b=bEmOtLi28oqyskIRq9tvH5Nvsc70rW6GlJGoBSTxROYDt1CFNftkjS8woF+jCVKn2j17b1651Mez1BFawXmBlRVoRxGso0LwHz/xdCglfjaJ98qYZJ/e+h0yXcBDJdnbZucY/OKFnxPbSSKbYxKwwZY1SfNS6a0YLtp/DNMKmvM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764864472; c=relaxed/simple; bh=EnEanNh6mXeSOkCIgUZhBEmC5RPB79FeqZANdW6aWV0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gR3jOkpiGngKitgLf3YaXvn4G+xJqIVm0Fgw1Ketx3WWEZqF81mGIFjUxiwm448XZAKE72uEY6JYkhGWp6e1DjCMjSW+B79ytsCBbpAUHzONslTyVaE5hgD+ppOQp5UxV0OgmNR0YKvRybRlNJXOEujLQRr3yR34xczHJrJxLs8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ER74nZus; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ER74nZus" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A22FBC4CEFB; Thu, 4 Dec 2025 16:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764864472; bh=EnEanNh6mXeSOkCIgUZhBEmC5RPB79FeqZANdW6aWV0=; h=From:To:Cc:Subject:Date:Reply-To:From; b=ER74nZusLWIWTmdpR0DXh0KHNH65I8BEBNMsvz89X9P3iDoBVomk17Zpk3vg1bk90 L/1lmedz2fzrtF23Zy1BJZBE1OKSTzbcgVIPRNp/b+vRBASh2W3/Q45zYRI1BTYQ/J wRhiZtsSLko7s4wyyChlyVh2FT+ZQ5Vsv8t8Xhao= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-40246: xfs: fix out of bounds memory read error in symlink repair Date: Thu, 4 Dec 2025 16:57:27 +0100 Message-ID: <2025120427-CVE-2025-40246-7e80@gregkh> X-Mailer: git-send-email 2.52.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4414; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=TQAfKDm8hktu/c1WrbvJ5KU8acoSx6skLWiLR8wa47A=; b=owGbwMvMwCRo6H6F97bub03G02pJDJmG69NF/+3oOGPQNlGvRyhd/6nnDJGlrC1tCU49M5+0n i6Tfb+5I5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACYid4xhnsIZbsGgnSkCfBOj PK8ybPwkfrvWi2HBVHs+u9e5eZMXxU33k+tc3h/8hSEJAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: xfs: fix out of bounds memory read error in symlink repair xfs/286 produced this report on my test fleet: ================================================================== BUG: KFENCE: out-of-bounds read in memcpy_orig+0x54/0x110 Out-of-bounds read at 0xffff88843fe9e038 (184B right of kfence-#184): memcpy_orig+0x54/0x110 xrep_symlink_salvage_inline+0xb3/0xf0 [xfs] xrep_symlink_salvage+0x100/0x110 [xfs] xrep_symlink+0x2e/0x80 [xfs] xrep_attempt+0x61/0x1f0 [xfs] xfs_scrub_metadata+0x34f/0x5c0 [xfs] xfs_ioc_scrubv_metadata+0x387/0x560 [xfs] xfs_file_ioctl+0xe23/0x10e0 [xfs] __x64_sys_ioctl+0x76/0xc0 do_syscall_64+0x4e/0x1e0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 kfence-#184: 0xffff88843fe9df80-0xffff88843fe9dfea, size=107, cache=kmalloc-128 allocated by task 3470 on cpu 1 at 263329.131592s (192823.508886s ago): xfs_init_local_fork+0x79/0xe0 [xfs] xfs_iformat_local+0xa4/0x170 [xfs] xfs_iformat_data_fork+0x148/0x180 [xfs] xfs_inode_from_disk+0x2cd/0x480 [xfs] xfs_iget+0x450/0xd60 [xfs] xfs_bulkstat_one_int+0x6b/0x510 [xfs] xfs_bulkstat_iwalk+0x1e/0x30 [xfs] xfs_iwalk_ag_recs+0xdf/0x150 [xfs] xfs_iwalk_run_callbacks+0xb9/0x190 [xfs] xfs_iwalk_ag+0x1dc/0x2f0 [xfs] xfs_iwalk_args.constprop.0+0x6a/0x120 [xfs] xfs_iwalk+0xa4/0xd0 [xfs] xfs_bulkstat+0xfa/0x170 [xfs] xfs_ioc_fsbulkstat.isra.0+0x13a/0x230 [xfs] xfs_file_ioctl+0xbf2/0x10e0 [xfs] __x64_sys_ioctl+0x76/0xc0 do_syscall_64+0x4e/0x1e0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 CPU: 1 UID: 0 PID: 1300113 Comm: xfs_scrub Not tainted 6.18.0-rc4-djwx #rc4 PREEMPT(lazy) 3d744dd94e92690f00a04398d2bd8631dcef1954 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-4.module+el8.8.0+21164+ed375313 04/01/2014 ================================================================== On further analysis, I realized that the second parameter to min() is not correct. xfs_ifork::if_bytes is the size of the xfs_ifork::if_data buffer. if_bytes can be smaller than the data fork size because: (a) the forkoff code tries to keep the data area as large as possible (b) for symbolic links, if_bytes is the ondisk file size + 1 (c) forkoff is always a multiple of 8. Case in point: for a single-byte symlink target, forkoff will be 8 but the buffer will only be 2 bytes long. In other words, the logic here is wrong and we walk off the end of the incore buffer. Fix that. The Linux kernel CVE team has assigned CVE-2025-40246 to this issue. Affected and fixed versions =========================== Issue introduced in 6.10 with commit 2651923d8d8db00a57665822f017fa7c76758044 and fixed in 6.12.60 with commit 7c2d68e091584149fe89bcbaf9b99b3162d46ee7 Issue introduced in 6.10 with commit 2651923d8d8db00a57665822f017fa7c76758044 and fixed in 6.17.10 with commit 81a8685cac4bf081c93a7df591644f4f80240bb9 Issue introduced in 6.10 with commit 2651923d8d8db00a57665822f017fa7c76758044 and fixed in 6.18 with commit 678e1cc2f482e0985a0613ab4a5bf89c497e5acc Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2025-40246 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: fs/xfs/scrub/symlink_repair.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/7c2d68e091584149fe89bcbaf9b99b3162d46ee7 https://git.kernel.org/stable/c/81a8685cac4bf081c93a7df591644f4f80240bb9 https://git.kernel.org/stable/c/678e1cc2f482e0985a0613ab4a5bf89c497e5acc