Commit 9f46c18
committed
KVM: x86/mmu: fix NULL pointer dereference on guest INVPCID
With shadow paging enabled, the INVPCID instruction results in a call
to kvm_mmu_invpcid_gva. If INVPCID is executed with CR0.PG=0, the
invlpg callback is not set and the result is a NULL pointer dereference.
Fix it trivially by checking for mmu->invlpg before every call.
There are other possibilities:
- check for CR0.PG, because KVM (like all Intel processors after P5)
flushes guest TLB on CR0.PG changes so that INVPCID/INVLPG are a
nop with paging disabled
- check for EFER.LMA, because KVM syncs and flushes when switching
MMU contexts outside of 64-bit mode
All of these are tricky, go for the simple solution. This is CVE-2022-1789.
Reported-by: Yongkang Jia <kangel@zju.edu.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>1 parent ea8c66f commit 9f46c18
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5470 | 5470 | | |
5471 | 5471 | | |
5472 | 5472 | | |
5473 | | - | |
| 5473 | + | |
| 5474 | + | |
5474 | 5475 | | |
5475 | 5476 | | |
5476 | 5477 | | |
5477 | 5478 | | |
5478 | 5479 | | |
5479 | 5480 | | |
5480 | | - | |
| 5481 | + | |
| 5482 | + | |
5481 | 5483 | | |
5482 | 5484 | | |
5483 | 5485 | | |
| |||
0 commit comments