Skip to content
Commit 0d033770 authored by Michal Luczaj's avatar Michal Luczaj Committed by Sean Christopherson
Browse files

KVM: x86: Fix KVM_CAP_SYNC_REGS's sync_regs() TOCTOU issues



In a spirit of using a sledgehammer to crack a nut, make sync_regs() feed
__set_sregs() and kvm_vcpu_ioctl_x86_set_vcpu_events() with kernel's own
copy of data.

Both __set_sregs() and kvm_vcpu_ioctl_x86_set_vcpu_events() assume they
have exclusive rights to structs they operate on. While this is true when
coming from an ioctl handler (caller makes a local copy of user's data),
sync_regs() breaks this contract; a pointer to a user-modifiable memory
(vcpu->run->s.regs) is provided. This can lead to a situation when incoming
data is checked and/or sanitized only to be re-set by a user thread running
in parallel.

Signed-off-by: default avatarMichal Luczaj <mhal@rbox.co>
Fixes: 01643c51 ("KVM: x86: KVM_CAP_SYNC_REGS")
Link: https://lore.kernel.org/r/20230728001606.2275586-2-mhal@rbox.co


Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
parent fdf0eaf1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment