Commit d0831ed
committed
Revert "KVM: Fix vcpu_array[0] races"
Now that KVM loads from vcpu_array if and only if the target index is
valid with respect to online_vcpus, i.e. now that it is safe to erase a
not-fully-onlined vCPU entry, revert to storing into vcpu_array before
success is guaranteed.
If xa_store() fails, which _should_ be impossible, then putting the vCPU's
reference to 'struct kvm' results in a refcounting bug as the vCPU fd has
been installed and owns the vCPU's reference.
This was found by inspection, but forcing the xa_store() to fail
confirms the problem:
| Unable to handle kernel paging request at virtual address ffff800080ecd960
| Call trace:
| _raw_spin_lock_irq+0x2c/0x70
| kvm_irqfd_release+0x24/0xa0
| kvm_vm_release+0x1c/0x38
| __fput+0x88/0x2ec
| ____fput+0x10/0x1c
| task_work_run+0xb0/0xd4
| do_exit+0x210/0x854
| do_group_exit+0x70/0x98
| get_signal+0x6b0/0x73c
| do_signal+0xa4/0x11e8
| do_notify_resume+0x60/0x12c
| el0_svc+0x64/0x68
| el0t_64_sync_handler+0x84/0xfc
| el0t_64_sync+0x190/0x194
| Code: b9000909 d503201f 2a1f03e1 52800028 (88e17c08)
Practically speaking, this is a non-issue as xa_store() can't fail, absent
a nasty kernel bug. But the code is visually jarring and technically
broken.
This reverts commit afb2acb.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Michal Luczaj <mhal@rbox.co>
Cc: Alexander Potapenko <glider@google.com>
Cc: Marc Zyngier <maz@kernel.org>
Reported-by: Will Deacon <will@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20241009150455.1057573-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent 6e2b235 commit d0831ed
1 file changed
Lines changed: 5 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4128 | 4128 | | |
4129 | 4129 | | |
4130 | 4130 | | |
4131 | | - | |
| 4131 | + | |
| 4132 | + | |
4132 | 4133 | | |
4133 | 4134 | | |
4134 | 4135 | | |
| |||
4143 | 4144 | | |
4144 | 4145 | | |
4145 | 4146 | | |
4146 | | - | |
4147 | | - | |
4148 | | - | |
4149 | | - | |
4150 | | - | |
4151 | | - | |
| 4147 | + | |
4152 | 4148 | | |
4153 | 4149 | | |
4154 | 4150 | | |
| |||
4163 | 4159 | | |
4164 | 4160 | | |
4165 | 4161 | | |
4166 | | - | |
| 4162 | + | |
4167 | 4163 | | |
4168 | 4164 | | |
4169 | | - | |
| 4165 | + | |
4170 | 4166 | | |
4171 | 4167 | | |
4172 | 4168 | | |
| |||
0 commit comments