mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
KVM: Remove CREATE_IRQCHIP/SET_PIT2 race
[ Upstream commit 7289fdb5dc
]
Fixes a NULL pointer dereference, caused by the PIT firing an interrupt
before the interrupt table has been initialized.
SET_PIT2 can race with the creation of the IRQchip. In particular,
if SET_PIT2 is called with a low PIT timer period (after the creation of
the IOAPIC, but before the instantiation of the irq routes), the PIT can
fire an interrupt at an uninitialized table.
Signed-off-by: Steve Rutherford <srutherford@google.com>
Signed-off-by: Jon Cargille <jcargill@google.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Message-Id: <20200416191152.259434-1-jcargill@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
10f5562478
commit
f81fe6eb5b
1 changed files with 8 additions and 2 deletions
|
@ -4370,10 +4370,13 @@ long kvm_arch_vm_ioctl(struct file *filp,
|
||||||
r = -EFAULT;
|
r = -EFAULT;
|
||||||
if (copy_from_user(&u.ps, argp, sizeof u.ps))
|
if (copy_from_user(&u.ps, argp, sizeof u.ps))
|
||||||
goto out;
|
goto out;
|
||||||
|
mutex_lock(&kvm->lock);
|
||||||
r = -ENXIO;
|
r = -ENXIO;
|
||||||
if (!kvm->arch.vpit)
|
if (!kvm->arch.vpit)
|
||||||
goto out;
|
goto set_pit_out;
|
||||||
r = kvm_vm_ioctl_set_pit(kvm, &u.ps);
|
r = kvm_vm_ioctl_set_pit(kvm, &u.ps);
|
||||||
|
set_pit_out:
|
||||||
|
mutex_unlock(&kvm->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KVM_GET_PIT2: {
|
case KVM_GET_PIT2: {
|
||||||
|
@ -4393,10 +4396,13 @@ long kvm_arch_vm_ioctl(struct file *filp,
|
||||||
r = -EFAULT;
|
r = -EFAULT;
|
||||||
if (copy_from_user(&u.ps2, argp, sizeof(u.ps2)))
|
if (copy_from_user(&u.ps2, argp, sizeof(u.ps2)))
|
||||||
goto out;
|
goto out;
|
||||||
|
mutex_lock(&kvm->lock);
|
||||||
r = -ENXIO;
|
r = -ENXIO;
|
||||||
if (!kvm->arch.vpit)
|
if (!kvm->arch.vpit)
|
||||||
goto out;
|
goto set_pit2_out;
|
||||||
r = kvm_vm_ioctl_set_pit2(kvm, &u.ps2);
|
r = kvm_vm_ioctl_set_pit2(kvm, &u.ps2);
|
||||||
|
set_pit2_out:
|
||||||
|
mutex_unlock(&kvm->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KVM_REINJECT_CONTROL: {
|
case KVM_REINJECT_CONTROL: {
|
||||||
|
|
Loading…
Reference in a new issue