CVE-2024-47717: RISC-V: KVM: Don't zero-out PMU snapshot area before freeing data
In the Linux kernel, the following vulnerability has been resolved:
RISC-V: KVM: Don't zero-out PMU snapshot area before freeing data
With the latest Linux-6.11-rc3, the below NULL pointer crash is observed when SBI PMU snapshot is enabled for the guest and the guest is forcefully powered-off.
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000508 Oops [#1] Modules linked in: kvm CPU: 0 UID: 0 PID: 61 Comm: term-poll Not tainted 6.11.0-rc3-00018-g44d7178dd77a #3 Hardware name: riscv-virtio,qemu (DT) epc : kvmwriteguestpage+0x94/0xa6 [kvm] ra : kvmwriteguestpage+0x54/0xa6 [kvm] epc : ffffffff01590e98 ra : ffffffff01590e58 sp : ffff8f80001f39b0 gp : ffffffff81512a60 tp : ffffaf80024872c0 t0 : ffffaf800247e000 t1 : 00000000000007e0 t2 : 0000000000000000 s0 : ffff8f80001f39f0 s1 : 00007fff89ac4000 a0 : ffffffff015dd7e8 a1 : 0000000000000086 a2 : 0000000000000000 a3 : ffffaf8000000000 a4 : ffffaf80024882c0 a5 : 0000000000000000 a6 : ffffaf800328d780 a7 : 00000000000001cc s2 : ffffaf800197bd00 s3 : 00000000000828c4 s4 : ffffaf800248c000 s5 : ffffaf800247d000 s6 : 0000000000001000 s7 : 0000000000001000 s8 : 0000000000000000 s9 : 00007fff861fd500 s10: 0000000000000001 s11: 0000000000800000 t3 : 00000000000004d3 t4 : 00000000000004d3 t5 : ffffffff814126e0 t6 : ffffffff81412700 status: 0000000200000120 badaddr: 0000000000000508 cause: 000000000000000d [<ffffffff01590e98>] kvmwriteguestpage+0x94/0xa6 [kvm] [<ffffffff015943a6>] kvmvcpuwriteguest+0x56/0x90 [kvm] [<ffffffff015a175c>] kvmpmuclearsnapshotarea+0x42/0x7e [kvm] [<ffffffff015a1972>] kvmriscvvcpupmudeinit.part.0+0xe0/0x14e [kvm] [<ffffffff015a2ad0>] kvmriscvvcpupmudeinit+0x1a/0x24 [kvm] [<ffffffff0159b344>] kvmarchvcpudestroy+0x28/0x4c [kvm] [<ffffffff0158e420>] kvmdestroyvcpus+0x5a/0xda [kvm] [<ffffffff0159930c>] kvmarchdestroyvm+0x14/0x28 [kvm] [<ffffffff01593260>] kvmdestroyvm+0x168/0x2a0 [kvm] [<ffffffff015933d4>] kvmputkvm+0x3c/0x58 [kvm] [<ffffffff01593412>] kvmvmrelease+0x22/0x2e [kvm]
Clearly, the kvmvcpuwriteguest() function is crashing because it is being called from kvmpmuclearsnapshotarea() upon guest tear down.
To address the above issue, simplify the kvmpmuclearsnapshotarea() to not zero-out PMU snapshot area from kvmpmuclearsnapshotarea() because the guest is anyway being tore down.
The kvmpmuclearsnapshotarea() is also called when guest changes PMU snapshot area of a VCPU but even in this case the previous PMU snaphsot area must not be zeroed-out because the guest might have reclaimed the pervious PMU snapshot area for some other purpose.
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2024-47717?
CVE-2024-47717 is classified as a medium severity vulnerability affecting the Linux kernel.
How do I fix CVE-2024-47717?
To fix CVE-2024-47717, upgrade to the latest Linux kernel version above 6.11.2.
What versions of the Linux kernel are affected by CVE-2024-47717?
CVE-2024-47717 affects Linux kernel versions from 6.10 to 6.11, inclusive.
What type of systems are impacted by CVE-2024-47717?
Systems using the RISC-V architecture with enabled SBI PMU snapshots are impacted by CVE-2024-47717.
What issues can arise from CVE-2024-47717?
CVE-2024-47717 can lead to a NULL pointer dereference crash in the Linux kernel.