From mboxrd@z Thu Jan 1 00:00:00 1970 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 E546C21A0A for ; Tue, 2 Apr 2024 06:43:50 +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=1712040231; cv=none; b=YXaeosqbRCho2higd0j2luDxEZzlEkTyKcxE3wsOuEiBLEQU5LS7mLEIm7opoogIiyPJutDfXxkg0WhObJpnwKDyykGKjh8wM5vd32ZdCCqzICjUs13flP2rsqi2tiGHR9vUKZEvzzxmjSjMSO/b5D7URX6edJZlxizKEIGCpqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712040231; c=relaxed/simple; bh=oHwDpsoS8Tg+wCT6WTRg9U29YW7kD9ut092scBpAm0M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WTelJwO+WOkaWM68CqlPRk3ygaUrVC5KZoh1m/dWURoVhLfPE9pdyYMVeDmx/ozHtJ3/WOkUJBG0Oxv888S2WKXcgjrPAIeWH00eoCJVDyPZg0SD9H00+rkvsJdJ6z94B3ZbJAz/N7jl3zv8QvqvsoNvw3XYGsySl6+Sb6JqjoM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=U4hqTjlu; 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="U4hqTjlu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5236C433F1; Tue, 2 Apr 2024 06:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712040230; bh=oHwDpsoS8Tg+wCT6WTRg9U29YW7kD9ut092scBpAm0M=; h=From:To:Cc:Subject:Date:Reply-to:From; b=U4hqTjlumx6OGDxv8nNJ9DNM1LIbqr0Dt485ixFiURRI6JGEF7OzL0KGGLlqTu86q lN8/1e3/o0YqbMFOp/JVsBD+rUucPTRB00h0oooLA3UhcJs7LDh7litZnSElQVV+3D XCNRelHAzClmTvQ9/7jeovoRbsPZLHQFMH2Q7+DA= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26670: arm64: entry: fix ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD Date: Tue, 2 Apr 2024 08:43:38 +0200 Message-ID: <2024040238-CVE-2024-26670-ecbd@gregkh> X-Mailer: git-send-email 2.44.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=4450; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=oHwDpsoS8Tg+wCT6WTRg9U29YW7kD9ut092scBpAm0M=; b=owGbwMvMwCRo6H6F97bub03G02pJDGncK6Uk+Z8kGuT+tun4f6Dx9u3nnrUz10Z8DN+Zyt6jq 7rk4gS3jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZhI5BeG+Ylv7n/YWaZ7+oys QIrLI7/vM1U8bjHMD9q0RVZX2zj/qXb1038O3XzLbjMWAQA= 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: arm64: entry: fix ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD Currently the ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD workaround isn't quite right, as it is supposed to be applied after the last explicit memory access, but is immediately followed by an LDR. The ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD workaround is used to handle Cortex-A520 erratum 2966298 and Cortex-A510 erratum 3117295, which are described in: * https://developer.arm.com/documentation/SDEN2444153/0600/?lang=en * https://developer.arm.com/documentation/SDEN1873361/1600/?lang=en In both cases the workaround is described as: | If pagetable isolation is disabled, the context switch logic in the | kernel can be updated to execute the following sequence on affected | cores before exiting to EL0, and after all explicit memory accesses: | | 1. A non-shareable TLBI to any context and/or address, including | unused contexts or addresses, such as a `TLBI VALE1 Xzr`. | | 2. A DSB NSH to guarantee completion of the TLBI. The important part being that the TLBI+DSB must be placed "after all explicit memory accesses". Unfortunately, as-implemented, the TLBI+DSB is immediately followed by an LDR, as we have: | alternative_if ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD | tlbi vale1, xzr | dsb nsh | alternative_else_nop_endif | alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0 | ldr lr, [sp, #S_LR] | add sp, sp, #PT_REGS_SIZE // restore sp | eret | alternative_else_nop_endif | | [ ... KPTI exception return path ... ] This patch fixes this by reworking the logic to place the TLBI+DSB immediately before the ERET, after all explicit memory accesses. The ERET is currently in a separate alternative block, and alternatives cannot be nested. To account for this, the alternative block for ARM64_UNMAP_KERNEL_AT_EL0 is replaced with a single alternative branch to skip the KPTI logic, with the new shape of the logic being: | alternative_insn "b .L_skip_tramp_exit_\@", nop, ARM64_UNMAP_KERNEL_AT_EL0 | [ ... KPTI exception return path ... ] | .L_skip_tramp_exit_\@: | | ldr lr, [sp, #S_LR] | add sp, sp, #PT_REGS_SIZE // restore sp | | alternative_if ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD | tlbi vale1, xzr | dsb nsh | alternative_else_nop_endif | eret The new structure means that the workaround is only applied when KPTI is not in use; this is fine as noted in the documented implications of the erratum: | Pagetable isolation between EL0 and higher level ELs prevents the | issue from occurring. ... and as per the workaround description quoted above, the workaround is only necessary "If pagetable isolation is disabled". The Linux kernel CVE team has assigned CVE-2024-26670 to this issue. Affected and fixed versions =========================== Issue introduced in 6.6 with commit 471470bc7052 and fixed in 6.6.15 with commit 58eb5c07f417 Issue introduced in 6.6 with commit 471470bc7052 and fixed in 6.7.3 with commit baa0aaac1643 Issue introduced in 6.6 with commit 471470bc7052 and fixed in 6.8 with commit 832dd634bd1b 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-26670 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/arm64/kernel/entry.S 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/58eb5c07f41704464b9acc09ab0707b6769db6c0 https://git.kernel.org/stable/c/baa0aaac16432019651e0d60c41cd34a0c3c3477 https://git.kernel.org/stable/c/832dd634bd1b4e3bbe9f10b9c9ba5db6f6f2b97f