Skip to contentSkip to conversation

CVE-2024-56761: x86/fred: Clear WFE in missing-ENDBRANCH #CPs

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Jan 6, 2025

lore
Share & tools
lore
#0 lore raw

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

x86/fred: Clear WFE in missing-ENDBRANCH #CPs

An indirect branch instruction sets the CPU indirect branch tracker (IBT) into WAIT_FOR_ENDBRANCH (WFE) state and WFE stays asserted across the instruction boundary. When the decoder finds an inappropriate instruction while WFE is set ENDBR, the CPU raises a #CP fault.

For the "kernel IBT no ENDBR" selftest where #CPs are deliberately triggered, the WFE state of the interrupted context needs to be cleared to let execution continue. Otherwise when the CPU resumes from the instruction that just caused the previous #CP, another missing-ENDBRANCH #CP is raised and the CPU enters a dead loop.

This is not a problem with IDT because it doesn't preserve WFE and IRET doesn't set WFE. But FRED provides space on the entry stack (in an expanded CS area) to save and restore the WFE state, thus the WFE state is no longer clobbered, so software must clear it.

Clear WFE to avoid dead looping in ibt_clear_fred_wfe() and the !ibt_fatal code path when execution is allowed to continue.

Clobbering WFE in any other circumstance is a security-relevant bug.

[ dhansen: changelog rewording ]

The Linux kernel CVE team has assigned CVE-2024-56761 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.6 with commit a5f6c2ace9974adf92ce65dacca8126d90adabfe and fixed in 6.12.8 with commit b939f108e86b76119428a6fa4e92491e09ac7867
	Issue introduced in 6.6 with commit a5f6c2ace9974adf92ce65dacca8126d90adabfe and fixed in 6.13-rc5 with commit dc81e556f2a017d681251ace21bf06c126d5a192

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-56761

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/x86/kernel/cet.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/b939f108e86b76119428a6fa4e92491e09ac7867
	https://git.kernel.org/stable/c/dc81e556f2a017d681251ace21bf06c126d5a192