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 A6FBE1F63C8 for ; Fri, 27 Dec 2024 15:01:03 +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=1735311663; cv=none; b=ZXKvePPk+iNvnfAmCz/8r3PZWc7rkfs45wB0c5HhWzjmeXSi/M9oUxHA2BYACxbs2mm19DsZJpXm3OLEUridHDblPqjRfKDTFgn+JYxf11uf5p3y/v5+gByR1UtJNFYeK1qlGtr5FNJKnbLFrfd3tG0p6ap28KIEebiBW3R7OaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735311663; c=relaxed/simple; bh=A6ICSFORMfeTGCNl+kvcaQXvqwopGY2UfIdGB3qU93s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=B1fQ6OiyEG7e4+6kqJLZWYwHZnro+MFeWmuH2HfEAJySjC/H2JgCP0LUde/lDUWbaW5QqIxMAccDh1qixcroLicPissUcdXHSyCM/4KTwrbj/QNR9cDulvuFjz3tNg1X1v2+GpdS4+0y30xYsZ+rvCDJV+4Zug/FHbyyc1VmYtY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kg8sklZq; 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="kg8sklZq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17B60C4CED0; Fri, 27 Dec 2024 15:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735311663; bh=A6ICSFORMfeTGCNl+kvcaQXvqwopGY2UfIdGB3qU93s=; h=From:To:Cc:Subject:Date:Reply-to:From; b=kg8sklZqNp81vdQTjePPh4IeUTzcLLoS+wT6/WpwSoWt09Hlbdeus0PY+vNp2cC+I rr9hECiy+v+6YqS5hVxJ5PyTZDhcqDe2Jj0/Dhqj6wtBsKwut5/RUk5wN6tC9k9A/W zWq7TbVVlKuEo9czmVz2y7XtE036c1KKSB3jkt9E= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-56628: LoongArch: Add architecture specific huge_pte_clear() Date: Fri, 27 Dec 2024 15:51:35 +0100 Message-ID: <2024122712-CVE-2024-56628-c347@gregkh> X-Mailer: git-send-email 2.47.1 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=5505; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=A6ICSFORMfeTGCNl+kvcaQXvqwopGY2UfIdGB3qU93s=; b=owGbwMvMwCRo6H6F97bub03G02pJDOl5+x5oPUpmX7JMjj8hyKf63679z0SzHDnuzfzHvvBQx X73B9kfO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAizO8ZFkzhmZmesN4i5H3E ggVmyk+rzHbN/8mwYM8cppWz7j0uCfCwv9iYfDhtYcrnHAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: LoongArch: Add architecture specific huge_pte_clear() When executing mm selftests run_vmtests.sh, there is such an error: BUG: Bad page state in process uffd-unit-tests pfn:00000 page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x0 flags: 0xffff0000002000(reserved|node=0|zone=0|lastcpupid=0xffff) raw: 00ffff0000002000 ffffbf0000000008 ffffbf0000000008 0000000000000000 raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set Modules linked in: snd_seq_dummy snd_seq snd_seq_device rfkill vfat fat virtio_balloon efi_pstore virtio_net pstore net_failover failover fuse nfnetlink virtio_scsi virtio_gpu virtio_dma_buf dm_multipath efivarfs CPU: 2 UID: 0 PID: 1913 Comm: uffd-unit-tests Not tainted 6.12.0 #184 Hardware name: QEMU QEMU Virtual Machine, BIOS unknown 2/2/2022 Stack : 900000047c8ac000 0000000000000000 9000000000223a7c 900000047c8ac000 900000047c8af690 900000047c8af698 0000000000000000 900000047c8af7d8 900000047c8af7d0 900000047c8af7d0 900000047c8af5b0 0000000000000001 0000000000000001 900000047c8af698 10b3c7d53da40d26 0000010000000000 0000000000000022 0000000fffffffff fffffffffe000000 ffff800000000000 000000000000002f 0000800000000000 000000017a6d4000 90000000028f8940 0000000000000000 0000000000000000 90000000025aa5e0 9000000002905000 0000000000000000 90000000028f8940 ffff800000000000 0000000000000000 0000000000000000 0000000000000000 9000000000223a94 000000012001839c 00000000000000b0 0000000000000004 0000000000000000 0000000000071c1d ... Call Trace: [<9000000000223a94>] show_stack+0x5c/0x180 [<9000000001c3fd64>] dump_stack_lvl+0x6c/0xa0 [<900000000056aa08>] bad_page+0x1a0/0x1f0 [<9000000000574978>] free_unref_folios+0xbf0/0xd20 [<90000000004e65cc>] folios_put_refs+0x1a4/0x2b8 [<9000000000599a0c>] free_pages_and_swap_cache+0x164/0x260 [<9000000000547698>] tlb_batch_pages_flush+0xa8/0x1c0 [<9000000000547f30>] tlb_finish_mmu+0xa8/0x218 [<9000000000543cb8>] exit_mmap+0x1a0/0x360 [<9000000000247658>] __mmput+0x78/0x200 [<900000000025583c>] do_exit+0x43c/0xde8 [<9000000000256490>] do_group_exit+0x68/0x110 [<9000000000256554>] sys_exit_group+0x1c/0x20 [<9000000001c413b4>] do_syscall+0x94/0x130 [<90000000002216d8>] handle_syscall+0xb8/0x158 Disabling lock debugging due to kernel taint BUG: non-zero pgtables_bytes on freeing mm: -16384 On LoongArch system, invalid huge pte entry should be invalid_pte_table or a single _PAGE_HUGE bit rather than a zero value. And it should be the same with invalid pmd entry, since pmd_none() is called by function free_pgd_range() and pmd_none() return 0 by huge_pte_clear(). So single _PAGE_HUGE bit is also treated as a valid pte table and free_pte_range() will be called in free_pmd_range(). free_pmd_range() pmd = pmd_offset(pud, addr); do { next = pmd_addr_end(addr, end); if (pmd_none_or_clear_bad(pmd)) continue; free_pte_range(tlb, pmd, addr); } while (pmd++, addr = next, addr != end); Here invalid_pte_table is used for both invalid huge pte entry and pmd entry. The Linux kernel CVE team has assigned CVE-2024-56628 to this issue. Affected and fixed versions =========================== Issue introduced in 5.19 with commit 09cfefb7fa70c3af011b0db0a513fd80b2f18abc and fixed in 6.1.120 with commit dba3c45e333a3a2a01395b5f5e5f88f8baba74e4 Issue introduced in 5.19 with commit 09cfefb7fa70c3af011b0db0a513fd80b2f18abc and fixed in 6.6.66 with commit 7dfbf011a57b9e1a40f5ce8080a53c497e105c6c Issue introduced in 5.19 with commit 09cfefb7fa70c3af011b0db0a513fd80b2f18abc and fixed in 6.12.5 with commit 9b602190cf2d8ac957be0011e418ed6c3b49b9a3 Issue introduced in 5.19 with commit 09cfefb7fa70c3af011b0db0a513fd80b2f18abc and fixed in 6.13-rc2 with commit 7cd1f5f77925ae905a57296932f0f9ef0dc364f8 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-2024-56628 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: arch/loongarch/include/asm/hugetlb.h 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/dba3c45e333a3a2a01395b5f5e5f88f8baba74e4 https://git.kernel.org/stable/c/7dfbf011a57b9e1a40f5ce8080a53c497e105c6c https://git.kernel.org/stable/c/9b602190cf2d8ac957be0011e418ed6c3b49b9a3 https://git.kernel.org/stable/c/7cd1f5f77925ae905a57296932f0f9ef0dc364f8