lkml.org 
[lkml]   [2022]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH 2/4] KVM: x86: Harden _regs accesses to guard against buggy input
    Date
    Sean Christopherson <seanjc@google.com> writes:

    > On Thu, May 26, 2022, Vitaly Kuznetsov wrote:
    >> Sean Christopherson <seanjc@google.com> writes:
    >> > ---
    >> > arch/x86/kvm/emulate.c | 6 ++++++
    >> > 1 file changed, 6 insertions(+)
    >> >
    >> > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
    >> > index 7226a127ccb4..c58366ae4da2 100644
    >> > --- a/arch/x86/kvm/emulate.c
    >> > +++ b/arch/x86/kvm/emulate.c
    >> > @@ -247,6 +247,9 @@ enum x86_transfer_type {
    >> >
    >> > static ulong reg_read(struct x86_emulate_ctxt *ctxt, unsigned nr)
    >> > {
    >> > + if (WARN_ON_ONCE(nr >= 16))
    >> > + nr &= 16 - 1;
    >>
    >> As the result of this is unlikely to match the expectation (and I'm
    >> unsure what's the expectation here in the first place :-), why not use
    >> KVM_BUG_ON() here instead?
    >
    > ctxt->vcpu is a 'void *' due to the (IMO futile) separation of the emulator from
    > regular KVM. I.e. this doesn't have access to the 'kvm'.

    Well, if we're not emulating something correctly for whatever reason,
    killing the VM is likely the right thing to do so I'm going to vote for
    abandoning the futility, making ctxt->vcpu 'struct kvm_vcpu *' and doing
    KVM_BUG_ON(). (Not necessarily now, the patch looks good to me).

    --
    Vitaly

    \
     
     \ /
      Last update: 2022-05-26 17:59    [W:5.488 / U:0.400 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site