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 7B39E2236F2 for ; Sat, 6 Dec 2025 21:53:21 +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=1765058001; cv=none; b=iEMeT44xb/UlmlSbE65MjvJKRFVmrsuw7dp79KaWMzj4/Sgh778JTykRicdEkfCzb2hYKTK69wI4bAUaRxzg+IvS3MZ9997IsuOqIx2/QIZsHHlsRQ6277XajiCFkURYuMN90kQ0dgb8VhFRxbKZac1iEsm6FGdIbonsFWrsS88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765058001; c=relaxed/simple; bh=DCcXL0fHv/4UNhrNjtC3h/ROfKhgZoh42ETjtEOHdxs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VH6hsRIRagUmmOcULEx1Ma1FiBa8CqOkw8/SPwNx+hBHF0vZJhHn6rjGfUxZFLvNz56InBq7zu5tcVD0NujvUuZb52klUicU12mz2S5eauSsu4GJnIC+E2BxXgV4IHbed14j8oeuNe7KwVZ+4F5aaRnMrrZcc9BfJNXqhjHLWLY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tjPVxRGY; 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="tjPVxRGY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 658E6C4CEF5; Sat, 6 Dec 2025 21:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765058001; bh=DCcXL0fHv/4UNhrNjtC3h/ROfKhgZoh42ETjtEOHdxs=; h=From:To:Cc:Subject:Date:Reply-To:From; b=tjPVxRGYJYZErdlkjBfsU62p+58kQLFbpev0KIp7cZVd85+E3wcjKt48w3p0+eSSG tPiEd5y00bmh9ML5VAnOmMcjWqyGwwp9Xel4vzF1TikR/CJ+UlMGLFaGxR5WqTp41B +4up3XBusStSzBdu+yRo2A/jer5ErXub2n/dx+ec= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-40272: mm/secretmem: fix use-after-free race in fault handler Date: Sun, 7 Dec 2025 06:52:19 +0900 Message-ID: <2025120716-CVE-2025-40272-507b@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=3649; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=idLo2loI4QEf+uHxWi37CvkOZ9XMNweA6kQhfr6cdm4=; b=owGbwMvMwCRo6H6F97bub03G02pJDJkmSye4FOhKWi475Pi7s1hxhvL8FPNIjk+7FrlwTFiz7 WlSE49zRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEzk/SmGBcfzrspe6Z8gdWf9 jKrEFWGOb89mpjAsmLOye3Lh+jUvK7rm5Z1n33Xhc8GzSQA= 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: mm/secretmem: fix use-after-free race in fault handler When a page fault occurs in a secret memory file created with `memfd_secret(2)`, the kernel will allocate a new folio for it, mark the underlying page as not-present in the direct map, and add it to the file mapping. If two tasks cause a fault in the same page concurrently, both could end up allocating a folio and removing the page from the direct map, but only one would succeed in adding the folio to the file mapping. The task that failed undoes the effects of its attempt by (a) freeing the folio again and (b) putting the page back into the direct map. However, by doing these two operations in this order, the page becomes available to the allocator again before it is placed back in the direct mapping. If another task attempts to allocate the page between (a) and (b), and the kernel tries to access it via the direct map, it would result in a supervisor not-present page fault. Fix the ordering to restore the direct map before the folio is freed. The Linux kernel CVE team has assigned CVE-2025-40272 to this issue. Affected and fixed versions =========================== Issue introduced in 5.14 with commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49 and fixed in 5.15.197 with commit bb1c19636aedae39360e6fdbcaef4f2bcff25785 Issue introduced in 5.14 with commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49 and fixed in 6.1.159 with commit 1e4643d6628edf9c0047b1f8f5bc574665025acb Issue introduced in 5.14 with commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49 and fixed in 6.6.117 with commit 42d486d35a4143cc37fc72ee66edc99d942dd367 Issue introduced in 5.14 with commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49 and fixed in 6.12.59 with commit 52f2d5cf33de9a8f5e72bbb0ed38282ae0bc4649 Issue introduced in 5.14 with commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49 and fixed in 6.17.9 with commit 4444767e625da46009fc94a453fd1967b80ba047 Issue introduced in 5.14 with commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49 and fixed in 6.18 with commit 6f86d0534fddfbd08687fa0f01479d4226bc3c3d 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-40272 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: mm/secretmem.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/bb1c19636aedae39360e6fdbcaef4f2bcff25785 https://git.kernel.org/stable/c/1e4643d6628edf9c0047b1f8f5bc574665025acb https://git.kernel.org/stable/c/42d486d35a4143cc37fc72ee66edc99d942dd367 https://git.kernel.org/stable/c/52f2d5cf33de9a8f5e72bbb0ed38282ae0bc4649 https://git.kernel.org/stable/c/4444767e625da46009fc94a453fd1967b80ba047 https://git.kernel.org/stable/c/6f86d0534fddfbd08687fa0f01479d4226bc3c3d