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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALMp9eQBhz1fzN4z=oMy5X9OKN3JxNyiD4GBYbH+fhen_aP6Ww@mail.gmail.com>
Date:   Thu, 25 Oct 2018 09:55:16 -0700
From:   Jim Mattson <jmattson@...gle.com>
To:     Julian Stecklina <jsteckli@...zon.de>
Cc:     kvm list <kvm@...r.kernel.org>,
        Paolo Bonzini <pbonzini@...hat.com>, js@...en8.de,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/4] kvm, vmx: move register clearing out of assembly path

On Wed, Oct 24, 2018 at 1:28 AM, Julian Stecklina <jsteckli@...zon.de> wrote:
> Split the security related register clearing out of the large inline
> assembly VM entry path. This results in two slightly less complicated
> inline assembly statements, where it is clearer what each one does.
>
> Signed-off-by: Julian Stecklina <jsteckli@...zon.de>
> Reviewed-by: Jan H. Schönherr <jschoenh@...zon.de>
> Reviewed-by: Konrad Jan Miller <kjm@...zon.de>
> ---
>  arch/x86/kvm/vmx.c | 33 ++++++++++++++++++++-------------
>  1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 93562d5..9225099 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -10797,20 +10797,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
>                 "mov %%r13, %c[r13](%0) \n\t"
>                 "mov %%r14, %c[r14](%0) \n\t"
>                 "mov %%r15, %c[r15](%0) \n\t"
> -               "xor %%r8d,  %%r8d \n\t"
> -               "xor %%r9d,  %%r9d \n\t"
> -               "xor %%r10d, %%r10d \n\t"
> -               "xor %%r11d, %%r11d \n\t"
> -               "xor %%r12d, %%r12d \n\t"
> -               "xor %%r13d, %%r13d \n\t"
> -               "xor %%r14d, %%r14d \n\t"
> -               "xor %%r15d, %%r15d \n\t"
>  #endif
> -
> -               "xor %%eax, %%eax \n\t"
> -               "xor %%ebx, %%ebx \n\t"
> -               "xor %%esi, %%esi \n\t"
> -               "xor %%edi, %%edi \n\t"
>                 "pop  %%" _ASM_BP "; pop  %%" _ASM_DX " \n\t"
>                 ".pushsection .rodata \n\t"
>                 ".global vmx_return \n\t"
> @@ -10847,6 +10834,26 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
>  #endif
>               );
>
> +       /* Don't let guest register values survive. */
> +       asm volatile (
> +               ""
> +#ifdef CONFIG_X86_64
> +               "xor %%r8d,  %%r8d \n\t"
> +               "xor %%r9d,  %%r9d \n\t"
> +               "xor %%r10d, %%r10d \n\t"
> +               "xor %%r11d, %%r11d \n\t"
> +               "xor %%r12d, %%r12d \n\t"
> +               "xor %%r13d, %%r13d \n\t"
> +               "xor %%r14d, %%r14d \n\t"
> +               "xor %%r15d, %%r15d \n\t"
> +#endif
> +               :: "a" (0), "b" (0), "S" (0), "D" (0)
> +               : "cc"
> +#ifdef CONFIG_X86_64
> +                 , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
> +#endif
> +               );
> +

Looking at the second asm statement and the comment that precedes it,
my first question would be, "What about the registers not covered
here?" I'm also not convinced that the register-clearing asm statement
is actually "clearer" with some registers cleared as input arguments
and others cleared explicitly, but otherwise, the change looks fine to
me.

Reviewed-by: Jim Mattson <jmattson@...gle.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ