Commit a681631
KVM: Introduce vcpu->wants_to_run
Introduce vcpu->wants_to_run to indicate when a vCPU is in its core run
loop, i.e. when the vCPU is running the KVM_RUN ioctl and immediate_exit
was not set.
Replace all references to vcpu->run->immediate_exit with
!vcpu->wants_to_run to avoid TOCTOU races with userspace. For example, a
malicious userspace could invoked KVM_RUN with immediate_exit=true and
then after KVM reads it to set wants_to_run=false, flip it to false.
This would result in the vCPU running in KVM_RUN with
wants_to_run=false. This wouldn't cause any real bugs today but is a
dangerous landmine.
Signed-off-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20240503181734.1467938-2-dmatlack@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent 438a496 commit a681631
9 files changed
Lines changed: 12 additions & 8 deletions
File tree
- arch
- arm64/kvm
- loongarch/kvm
- mips/kvm
- powerpc/kvm
- riscv/kvm
- s390/kvm
- x86/kvm
- include/linux
- virt/kvm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1099 | 1099 | | |
1100 | 1100 | | |
1101 | 1101 | | |
1102 | | - | |
| 1102 | + | |
1103 | 1103 | | |
1104 | 1104 | | |
1105 | 1105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1266 | 1266 | | |
1267 | 1267 | | |
1268 | 1268 | | |
1269 | | - | |
| 1269 | + | |
1270 | 1270 | | |
1271 | 1271 | | |
1272 | 1272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
439 | | - | |
| 439 | + | |
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1852 | 1852 | | |
1853 | 1853 | | |
1854 | 1854 | | |
1855 | | - | |
| 1855 | + | |
1856 | 1856 | | |
1857 | 1857 | | |
1858 | 1858 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
763 | | - | |
| 763 | + | |
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5026 | 5026 | | |
5027 | 5027 | | |
5028 | 5028 | | |
5029 | | - | |
| 5029 | + | |
5030 | 5030 | | |
5031 | 5031 | | |
5032 | 5032 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11407 | 11407 | | |
11408 | 11408 | | |
11409 | 11409 | | |
11410 | | - | |
| 11410 | + | |
11411 | 11411 | | |
11412 | 11412 | | |
11413 | 11413 | | |
| |||
11485 | 11485 | | |
11486 | 11486 | | |
11487 | 11487 | | |
11488 | | - | |
| 11488 | + | |
11489 | 11489 | | |
11490 | 11490 | | |
11491 | 11491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| 381 | + | |
381 | 382 | | |
382 | 383 | | |
383 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4435 | 4435 | | |
4436 | 4436 | | |
4437 | 4437 | | |
| 4438 | + | |
4438 | 4439 | | |
| 4440 | + | |
| 4441 | + | |
4439 | 4442 | | |
4440 | 4443 | | |
4441 | 4444 | | |
| |||
0 commit comments