Skip to contentSkip to conversation

accel: Fix NULL deref in NVMM / WHPX vCPU init

PATCH In review Philippe Mathieu-Daudé 2 participants 4 messages Apr 29, 2024

lore
Share & tools
lore
#0 lore raw

cover accel: Fix NULL deref in NVMM / WHPX vCPU init

Fix recently introduced NULL deref in NVMM/WHPX
vCPU init() handlers.

Philippe Mathieu-Daudé (2):
accel/whpx: Fix NULL dereference in whpx_init_vcpu() accel/nvmm: Fix NULL dereference in nvmm_init_vcpu()

 target/i386/nvmm/nvmm-all.c | 2 +-
 target/i386/whpx/whpx-all.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/2 accel/whpx: Fix NULL dereference in whpx_init_vcpu()

When mechanically moving the @dirty field to AccelCPUState in commit 9ad49538c7, we neglected cpu->accel is still NULL when we want to dereference it.

Fixes 9ad49538c7 ("accel/whpx: Use accel-specific per-vcpu @dirty field")
---
 target/i386/whpx/whpx-all.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/whpx/whpx-all.c +1 -1
index b08e644517..a6674a826d 100644
@@ -2236,7 +2236,7 @@ int whpx_init_vcpu(CPUState *cpu)
     }
 
     vcpu->interruptable = true;
-    cpu->accel->dirty = true;
+    vcpu->dirty = true;
     cpu->accel = vcpu;
     max_vcpu_index = max(max_vcpu_index, cpu->cpu_index);
     qemu_add_vm_change_state_handler(whpx_cpu_update_state, env);
Signature · 1 line
2.41.0
#2 lore raw

PATCH 2/2 accel/nvmm: Fix NULL dereference in nvmm_init_vcpu()

In reply to Philippe Mathieu-Daudé

When mechanically moving the @dirty field to AccelCPUState in commit 79f1926b2d, we neglected cpu->accel is still NULL when we want to dereference it.

Fixes 79f1926b2d ("accel/nvmm: Use accel-specific per-vcpu @dirty field")
---
 target/i386/nvmm/nvmm-all.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/nvmm/nvmm-all.c +1 -1
index f9cced53b3..65768aca03 100644
@@ -982,7 +982,7 @@ nvmm_init_vcpu(CPUState *cpu)
         }
     }
 
-    cpu->accel->dirty = true;
+    qcpu->dirty = true;
     cpu->accel = qcpu;
 
     return 0;
Signature · 1 line
2.41.0