lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c79d0167-7034-ebe2-97b7-58354d81323d@linux.alibaba.com>
Date:   Fri, 9 Jul 2021 11:09:38 +0800
From:   Lai Jiangshan <laijs@...ux.alibaba.com>
To:     Paolo Bonzini <pbonzini@...hat.com>,
        Lai Jiangshan <jiangshanlai@...il.com>,
        linux-kernel@...r.kernel.org
Cc:     Sean Christopherson <seanjc@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        kvm@...r.kernel.org
Subject: Re: [PATCH] KVM: X86: Also reload the debug registers before
 kvm_x86->run() when the host is using them



On 2021/7/9 00:48, Paolo Bonzini wrote:
> On 28/06/21 19:26, Lai Jiangshan wrote:
>> From: Lai Jiangshan <laijs@...ux.alibaba.com>
>>
>> When the host is using debug registers but the guest is not using them
>> nor is the guest in guest-debug state, the kvm code does not reset
>> the host debug registers before kvm_x86->run().  Rather, it relies on
>> the hardware vmentry instruction to automatically reset the dr7 registers
>> which ensures that the host breakpoints do not affect the guest.
>>
>> But there are still problems:
>>     o The addresses of the host breakpoints can leak into the guest
>>       and the guest may use these information to attack the host.
> 
> I don't think this is true, because DRn reads would exit (if they don't, switch_db_regs would be nonzero).  But 
> otherwise it makes sense to do at least the DR7 write, and we might as well do all of them.

Ahh.... you are right.

> 
>>     o It violates the non-instrumentable nature around VM entry and
>>       exit.  For example, when a host breakpoint is set on
>>       vcpu->arch.cr2, #DB will hit aftr kvm_guest_enter_irqoff().
>>
>> Beside the problems, the logic is not consistent either. When the guest
>> debug registers are active, the host breakpoints are reset before
>> kvm_x86->run(). But when the guest debug registers are inactive, the
>> host breakpoints are delayed to be disabled.  The host tracing tools may
>> see different results depending on there is any guest running or not.
> 
> More precisely, the host tracing tools may see different results depending on what the guest is doing.
> 
> Queued (with fixed commit message), thanks!
> 
> Paolo

I just noticed that emulation.c fails to emulate with DBn.
Is there any problem around it?

For code breakpoint, if the instruction didn't cause vm-exit,
(for example, the 2nd instruction when kvm emulates instructions
back to back) emulation.c fails to emulate with DBn.

For code breakpoint, if the instruction just caused vm-exit.
It is difficult to analyze this case due to the complex priorities
between vectored events and fault-like vm-exit.
Anyway, if it is an instruction that vm-exit has priority over #DB,
emulation.c fails to emulate with DBn.

For data breakpoint, a #DB must be delivered to guest or to VMM (when
guest-debug) after the instruction. But emulation.c doesn't do so.

And the existence of both of effective DBn (guest debug) and guest DBn
complicates the problem when we try to emulate them.

Thanks.
Lai.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ