CVE-2021-47230
Severity CVSS v4.0:
Pending analysis
Type:
CWE-476
NULL Pointer Dereference
Publication date:
21/05/2024
Last modified:
04/04/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
KVM: x86: Immediately reset the MMU context when the SMM flag is cleared<br />
<br />
Immediately reset the MMU context when the vCPU&#39;s SMM flag is cleared so<br />
that the SMM flag in the MMU role is always synchronized with the vCPU&#39;s<br />
flag. If RSM fails (which isn&#39;t correctly emulated), KVM will bail<br />
without calling post_leave_smm() and leave the MMU in a bad state.<br />
<br />
The bad MMU role can lead to a NULL pointer dereference when grabbing a<br />
shadow page&#39;s rmap for a page fault as the initial lookups for the gfn<br />
will happen with the vCPU&#39;s SMM flag (=0), whereas the rmap lookup will<br />
use the shadow page&#39;s SMM flag, which comes from the MMU (=1). SMM has<br />
an entirely different set of memslots, and so the initial lookup can find<br />
a memslot (SMM=0) and then explode on the rmap memslot lookup (SMM=1).<br />
<br />
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN<br />
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]<br />
CPU: 1 PID: 8410 Comm: syz-executor382 Not tainted 5.13.0-rc5-syzkaller #0<br />
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011<br />
RIP: 0010:__gfn_to_rmap arch/x86/kvm/mmu/mmu.c:935 [inline]<br />
RIP: 0010:gfn_to_rmap+0x2b0/0x4d0 arch/x86/kvm/mmu/mmu.c:947<br />
Code: 80 3c 20 00 74 08 4c 89 ff e8 f1 79 a9 00 4c 89 fb 4d 8b 37 44<br />
RSP: 0018:ffffc90000ffef98 EFLAGS: 00010246<br />
RAX: 0000000000000000 RBX: ffff888015b9f414 RCX: ffff888019669c40<br />
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001<br />
RBP: 0000000000000001 R08: ffffffff811d9cdb R09: ffffed10065a6002<br />
R10: ffffed10065a6002 R11: 0000000000000000 R12: dffffc0000000000<br />
R13: 0000000000000003 R14: 0000000000000001 R15: 0000000000000000<br />
FS: 000000000124b300(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000<br />
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033<br />
CR2: 0000000000000000 CR3: 0000000028e31000 CR4: 00000000001526e0<br />
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000<br />
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400<br />
Call Trace:<br />
rmap_add arch/x86/kvm/mmu/mmu.c:965 [inline]<br />
mmu_set_spte+0x862/0xe60 arch/x86/kvm/mmu/mmu.c:2604<br />
__direct_map arch/x86/kvm/mmu/mmu.c:2862 [inline]<br />
direct_page_fault+0x1f74/0x2b70 arch/x86/kvm/mmu/mmu.c:3769<br />
kvm_mmu_do_page_fault arch/x86/kvm/mmu.h:124 [inline]<br />
kvm_mmu_page_fault+0x199/0x1440 arch/x86/kvm/mmu/mmu.c:5065<br />
vmx_handle_exit+0x26/0x160 arch/x86/kvm/vmx/vmx.c:6122<br />
vcpu_enter_guest+0x3bdd/0x9630 arch/x86/kvm/x86.c:9428<br />
vcpu_run+0x416/0xc20 arch/x86/kvm/x86.c:9494<br />
kvm_arch_vcpu_ioctl_run+0x4e8/0xa40 arch/x86/kvm/x86.c:9722<br />
kvm_vcpu_ioctl+0x70f/0xbb0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3460<br />
vfs_ioctl fs/ioctl.c:51 [inline]<br />
__do_sys_ioctl fs/ioctl.c:1069 [inline]<br />
__se_sys_ioctl+0xfb/0x170 fs/ioctl.c:1055<br />
do_syscall_64+0x3f/0xb0 arch/x86/entry/common.c:47<br />
entry_SYSCALL_64_after_hwframe+0x44/0xae<br />
RIP: 0033:0x440ce9
Impact
Base Score 3.x
6.60
Severity 3.x
MEDIUM
Vulnerable products and versions
| CPE | From | Up to |
|---|---|---|
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.1 (including) | 5.4.128 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.5 (including) | 5.10.46 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.11 (including) | 5.12.13 (excluding) |
| cpe:2.3:o:linux:linux_kernel:5.13:rc1:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc2:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc3:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc4:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc5:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.13:rc6:*:*:*:*:*:* |
To consult the complete list of CPE names with products and versions, see this page
References to Advisories, Solutions, and Tools
- https://git.kernel.org/stable/c/669a8866e468fd020d34eb00e08cb41d3774b71b
- https://git.kernel.org/stable/c/78fcb2c91adfec8ce3a2ba6b4d0dda89f2f4a7c6
- https://git.kernel.org/stable/c/cbb425f62df9df7abee4b3f068f7ed6ffc3561e2
- https://git.kernel.org/stable/c/df9a40cfb3be2cbeb1c17bb67c59251ba16630f3
- https://git.kernel.org/stable/c/669a8866e468fd020d34eb00e08cb41d3774b71b
- https://git.kernel.org/stable/c/78fcb2c91adfec8ce3a2ba6b4d0dda89f2f4a7c6
- https://git.kernel.org/stable/c/cbb425f62df9df7abee4b3f068f7ed6ffc3561e2
- https://git.kernel.org/stable/c/df9a40cfb3be2cbeb1c17bb67c59251ba16630f3



