On Fri, 28 Jul 2023 02:12:56 +0200, Michal Luczaj wrote: > 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. > > [...] Applied to kvm-x86 selftests (there are in-flight reworks for selftests that will conflict, and I didn't want to split the testcases from the fix). As mentioned in my reply to patch 2, I split up the selftests patch and massaged things a bit. Please holler if you disagree with any of the changes. Thanks much! [1/4] KVM: x86: Fix KVM_CAP_SYNC_REGS's sync_regs() TOCTOU issues https://github.com/kvm-x86/linux/commit/0d033770d43a [2/4] KVM: selftests: Extend x86's sync_regs_test to check for CR4 races https://github.com/kvm-x86/linux/commit/ae895cbe613a [3/4] KVM: selftests: Extend x86's sync_regs_test to check for event vector races https://github.com/kvm-x86/linux/commit/60c4063b4752 [4/4] KVM: selftests: Extend x86's sync_regs_test to check for exception races https://github.com/kvm-x86/linux/commit/0de704d2d6c8 -- https://github.com/kvm-x86/linux/tree/next https://github.com/kvm-x86/linux/tree/fixes