diff options
author | Sean Christopherson <sean.j.christopherson@intel.com> | 2019-09-27 14:45:20 -0700 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-10-22 13:34:13 +0200 |
commit | 489cbcf01d1c9e1bf09b7e371d0f312b3a1f3ef2 (patch) | |
tree | 4a6d83d64de76cd1aed55fd55ec1577c48548043 /arch/x86/include/asm/kvm_host.h | |
parent | 491c1ad1ac8d891aa440eb0216d023af6c038346 (diff) |
KVM: x86: Add WARNs to detect out-of-bounds register indices
Add WARN_ON_ONCE() checks in kvm_register_{read,write}() to detect reg
values that would cause KVM to overflow vcpu->arch.regs. Change the reg
param to an 'int' to make it clear that the reg index is unverified.
Regarding the overhead of WARN_ON_ONCE(), now that all fixed GPR reads
and writes use dedicated accessors, e.g. kvm_rax_read(), the overhead
is limited to flows where the reg index is generated at runtime. And
there is at least one historical bug where KVM has generated an out-of-
bounds access to arch.regs (see commit b68f3cc7d9789, "KVM: x86: Always
use 32-bit SMRAM save state for 32-bit kernels").
Adding the WARN_ON_ONCE() protection paves the way for additional
cleanup related to kvm_reg and kvm_reg_ex.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/include/asm/kvm_host.h')
0 files changed, 0 insertions, 0 deletions