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 B67E725228E for ; Wed, 18 Jun 2025 09:34:42 +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=1750239282; cv=none; b=iuJnvEDnb4HH0LshAP9Tt4XPl/8dj3GM25D4LusUB4zxqRkiIM3vnvGm5vPREyrWCoHYYapQ32qpOvh41/Ba3KrDPxWW/+Rz13ayrlS5iOVarkXc6k6DK3cDuSNLXKYqqfRoqtv/BGOWvDNGFiXumpqf47weiIUI9duteEksgRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750239282; c=relaxed/simple; bh=qmVo29laZfM0w7Ejyrtz1dFkdy81xnrGHgadMgtvvjs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VKtp7C2QoImzVQVB61ehJjDoA38I9LXp+Jlj9UsoJauelKQ2rv9ACSMbuARsvt6vfe1AKWbgbFiWEA686AropiaBbd+7XjNvTKsvC3tp+J0eQERLSAIFBch2iCS022/vSER6KY6k34kn8GPxn3DsvS9hWMU0rHX7149ZWuU5Yx0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EqCNvNfQ; 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="EqCNvNfQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BACAC4CEE7; Wed, 18 Jun 2025 09:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750239282; bh=qmVo29laZfM0w7Ejyrtz1dFkdy81xnrGHgadMgtvvjs=; h=From:To:Cc:Subject:Date:Reply-to:From; b=EqCNvNfQO4GgRG1pWSn7nwYUkEBwxJizy4OFJlePdxzmjn6HirbnJgBFREFtCZAqk TxNOTjKyXBpV6SKC1URqtzM5IqsWik4GnB/UZIovak0k+k+MSR1j+RjFdn97cEGa2A kdzpYUTL/OlVCjdm6XTDoowLuQV3AMcT1yijiinM= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-38050: mm/hugetlb: fix kernel NULL pointer dereference when replacing free hugetlb folios Date: Wed, 18 Jun 2025 11:33:45 +0200 Message-ID: <2025061831-CVE-2025-38050-421a@gregkh> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4229; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=v7pcfOfFaPvrMiANMwsF3cEKb3om7fHxfHzmhzFZgQg=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlB7a8vfhaMbbqj9oB//WFhFrsIzjvtml7N8mdfRLy7O t9o4QuxjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZhIpSPDgjMpBrcvzLefye/7 dF03f7Pn4Z9csxnmxyRyR7q4zZjybsHBbyn69jt+3/E7DQA= 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/hugetlb: fix kernel NULL pointer dereference when replacing free hugetlb folios A kernel crash was observed when replacing free hugetlb folios: BUG: kernel NULL pointer dereference, address: 0000000000000028 PGD 0 P4D 0 Oops: Oops: 0000 [#1] SMP NOPTI CPU: 28 UID: 0 PID: 29639 Comm: test_cma.sh Tainted 6.15.0-rc6-zp #41 PREEMPT(voluntary) RIP: 0010:alloc_and_dissolve_hugetlb_folio+0x1d/0x1f0 RSP: 0018:ffffc9000b30fa90 EFLAGS: 00010286 RAX: 0000000000000000 RBX: 0000000000342cca RCX: ffffea0043000000 RDX: ffffc9000b30fb08 RSI: ffffea0043000000 RDI: 0000000000000000 RBP: ffffc9000b30fb20 R08: 0000000000001000 R09: 0000000000000000 R10: ffff88886f92eb00 R11: 0000000000000000 R12: ffffea0043000000 R13: 0000000000000000 R14: 00000000010c0200 R15: 0000000000000004 FS: 00007fcda5f14740(0000) GS:ffff8888ec1d8000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000028 CR3: 0000000391402000 CR4: 0000000000350ef0 Call Trace: replace_free_hugepage_folios+0xb6/0x100 alloc_contig_range_noprof+0x18a/0x590 ? srso_return_thunk+0x5/0x5f ? down_read+0x12/0xa0 ? srso_return_thunk+0x5/0x5f cma_range_alloc.constprop.0+0x131/0x290 __cma_alloc+0xcf/0x2c0 cma_alloc_write+0x43/0xb0 simple_attr_write_xsigned.constprop.0.isra.0+0xb2/0x110 debugfs_attr_write+0x46/0x70 full_proxy_write+0x62/0xa0 vfs_write+0xf8/0x420 ? srso_return_thunk+0x5/0x5f ? filp_flush+0x86/0xa0 ? srso_return_thunk+0x5/0x5f ? filp_close+0x1f/0x30 ? srso_return_thunk+0x5/0x5f ? do_dup2+0xaf/0x160 ? srso_return_thunk+0x5/0x5f ksys_write+0x65/0xe0 do_syscall_64+0x64/0x170 entry_SYSCALL_64_after_hwframe+0x76/0x7e There is a potential race between __update_and_free_hugetlb_folio() and replace_free_hugepage_folios(): CPU1 CPU2 __update_and_free_hugetlb_folio replace_free_hugepage_folios folio_test_hugetlb(folio) -- It's still hugetlb folio. __folio_clear_hugetlb(folio) hugetlb_free_folio(folio) h = folio_hstate(folio) -- Here, h is NULL pointer When the above race condition occurs, folio_hstate(folio) returns NULL, and subsequent access to this NULL pointer will cause the system to crash. To resolve this issue, execute folio_hstate(folio) under the protection of the hugetlb_lock lock, ensuring that folio_hstate(folio) does not return NULL. The Linux kernel CVE team has assigned CVE-2025-38050 to this issue. Affected and fixed versions =========================== Issue introduced in 6.14 with commit 04f13d241b8b146b23038bffd907cb8278391d07 and fixed in 6.14.9 with commit e97283978a9848190d451f7038ac399613445f79 Issue introduced in 6.14 with commit 04f13d241b8b146b23038bffd907cb8278391d07 and fixed in 6.15 with commit 113ed54ad276c352ee5ce109bdcf0df118a43bda 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-38050 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/hugetlb.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/e97283978a9848190d451f7038ac399613445f79 https://git.kernel.org/stable/c/113ed54ad276c352ee5ce109bdcf0df118a43bda