Skip to content

Commit d52b45c

Browse files
yonghuahwenlingz
authored andcommitted
hv:fix crash issue when handling HC_NOTIFY_REQUEST_FINISH
Input 'vcpu_id' and the state of target vCPU should be validated properly: - 'vcpu_id' shall be less than 'vm->hw.created_vcpus' instead of 'MAX_VCPUS_PER_VM'. - The state of target vCPU should be "VCPU_PAUSED", and reject all other states. Tracked-On: #4245 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 78139b9 commit d52b45c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hypervisor/common/hypercall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,12 @@ int32_t hcall_notify_ioreq_finish(uint16_t vmid, uint16_t vcpu_id)
548548
dev_dbg(ACRN_DBG_HYCALL, "[%d] NOTIFY_FINISH for vcpu %d",
549549
vmid, vcpu_id);
550550

551-
if (vcpu_id >= MAX_VCPUS_PER_VM) {
551+
if (vcpu_id >= target_vm->hw.created_vcpus) {
552552
pr_err("%s, failed to get VCPU %d context from VM %d\n",
553553
__func__, vcpu_id, target_vm->vm_id);
554554
} else {
555555
vcpu = vcpu_from_vid(target_vm, vcpu_id);
556-
if (vcpu->state != VCPU_OFFLINE) {
556+
if (vcpu->state == VCPU_PAUSED) {
557557
if (!vcpu->vm->sw.is_completion_polling) {
558558
resume_vcpu(vcpu);
559559
}

0 commit comments

Comments
 (0)