CVE-2021-47465: KVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest()
In the Linux kernel, the following vulnerability has been resolved:
KVM: PPC: Book3S HV: Fix stack handling in idle_kvm_start_guest()
In commit 10d91611f426 ("powerpc/64s: Reimplement book3s idle code in
C") kvm_start_guest() became idle_kvm_start_guest(). The old code
allocated a stack frame on the emergency stack, but didn't use the
frame to store anything, and also didn't store anything in its caller's
frame.
idle_kvm_start_guest() on the other hand is written more like a normal C
function, it creates a frame on entry, and also stores CR/LR into its
callers frame (per the ABI). The problem is that there is no caller
frame on the emergency stack.
The emergency stack for a given CPU is allocated with:
paca_ptrs[i]->emergency_sp = alloc_stack(limit, i) + THREAD_SIZE;
So emergency_sp actually points to the first address above the emergency
stack allocation for a given CPU, we must not store above it without
first decrementing it to create a frame. This is different to the
regular kernel stack, paca->kstack, which is initialised to point at an
initial frame that is ready to use.
idle_kvm_start_guest() stores the backchain, CR and LR all of which
write outside the allocation for the emergency stack. It then creates a
stack frame and saves the non-volatile registers. Unfortunately the
frame it creates is not large enough to fit the non-volatiles, and so
the saving of the non-volatile registers also writes outside the
emergency stack allocation.
The end result is that we corrupt whatever is at 0-24 bytes, and 112-248
bytes above the emergency stack allocation.
In practice this has gone unnoticed because the memory immediately above
the emergency stack happens to be used for other stack allocations,
either another CPUs mc_emergency_sp or an IRQ stack. See the order of
calls to irqstack_early_init() and emergency_stack_init().
The low addresses of another stack are the top of that stack, and so are
only used if that stack is under extreme pressue, which essentially
never happens in practice - and if it did there's a high likelyhood we'd
crash due to that stack overflowing.
Still, we shouldn't be corrupting someone else's stack, and it is purely
luck that we aren't corrupting something else.
To fix it we save CR/LR into the caller's frame using the existing r1 on
entry, we then create a SWITCH_FRAME_SIZE frame (which has space for
pt_regs) on the emergency stack with the backchain pointing to the
existing stack, and then finally we switch to the new frame on the
emergency stack.
Security readout for executives and security teams
Plain-English summary
A Linux kernel KVM bug on PowerPC Book3S HV can write outside a CPU emergency stack during guest start from idle. That can corrupt nearby stack memory, risking host integrity and availability. The CVE is high severity, but the supplied sources do not show active exploitation or a public exploit.
Executive priority
Treat as a high-priority infrastructure maintenance issue for PowerPC KVM environments. Urgency is lower for organizations without PowerPC Book3S HV KVM exposure, and the sources do not support an emergency active-exploitation response.
Technical view
idle_kvm_start_guest() behaved like a normal C function on an emergency stack that lacked a caller frame. It saved backchain, CR/LR, and non-volatile registers outside the allocation, corrupting memory above the stack. Fixes adjust frame creation and switching on the emergency stack.
Likely exposure
Exposure appears limited to Linux systems using KVM on PowerPC Book3S HV with affected Linux kernel versions or descendants of commit 10d91611f426. General x86 virtualization hosts are not identified as affected in the supplied sources.
Exploitation context
The CVSS vector is local, low complexity, low privileges, no user interaction, with high integrity and availability impact. CISA KEV status is false in the bundle, and no cited source states active exploitation.
Researcher notes
The bug is a kernel stack handling flaw, not a remotely reachable service issue. The description suggests accidental adjacent stack corruption that historically went unnoticed, but still creates integrity and availability risk. Evidence is insufficient to claim practical exploitability or exploitation in the wild.
Mitigation direction
Update affected Linux kernels using vendor or distribution guidance.
Confirm the fix is present through the linked stable kernel commits.
Prioritize PowerPC KVM hosts that run untrusted or multi-tenant workloads.
Track distro advisories for backported fixes and package-specific version mapping.
Validation and detection
Inventory Linux virtualization hosts using PowerPC Book3S HV KVM.
Compare running kernel source or package changelog against the linked stable fixes.
Check whether kernels descend from the affected commit or affected version ranges.
Review vendor advisories before treating a version number as definitively fixed.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2021-47465 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.