Skip to content

KVM: nSVM: avoid TOC/TOU race when checking vmcb12

Emanuele Giuseppe Esposito kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: nSVM: move nested_vmcb_check_cr3_cr4 logic in nested_vmcb_valid_sregsarch/x86/kvm/svm/nested.c+13 -221 reply
2/2KVM: nSVM: temporarly save vmcb12's efer, cr0 and cr4 to avoid TOC/TOU racesarch/x86/kvm/svm/nested.c+36 -364 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchMaxim Levitsky
1/2R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] KVM: nSVM: avoid TOC/TOU race when checking vmcb12

Currently there is a TOC/TOU race between the first check of vmcb12's efer, cr0 and cr4 registers and the later save of their values in svm_set_*, because the guest could modify the values in the meanwhile.

To solve this issue, this serie 1) moves the actual check nearer to the usage (from nested_svm_vmrun to enter_svm_guest_mode), possible thanks to the patch "KVM: nSVM: remove useless kvm_clear_*_queue" and 2) adds local variables in enter_svm_guest_mode to save the current value of efer, cr0 and cr4 and later use these to set the vcpu->arch.* state.

Patch 1 just refactors the code to simplify the second patch, where we move the TOC nearer to the TOU and use local variables.

Based-on: <[email protected]>

Emanuele Giuseppe Esposito (2):
KVM: nSVM: move nested_vmcb_check_cr3_cr4 logic in
nested_vmcb_valid_sregs
KVM: nSVM: temporarly save vmcb12's efer, cr0 and cr4 to avoid TOC/TOU
races

 arch/x86/kvm/svm/nested.c | 99 ++++++++++++++++++---------------------
 1 file changed, 45 insertions(+), 54 deletions(-)
Signature · 1 line
2.31.1