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] [day] [month] [year] [list]
Date:   Mon, 18 Jan 2021 18:34:19 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: x86: Add more protection against undefined behavior
 in rsvd_bits()

On 13/01/21 21:45, Sean Christopherson wrote:
> Add compile-time asserts in rsvd_bits() to guard against KVM passing in
> garbage hardcoded values, and cap the upper bound at '63' for dynamic
> values to prevent generating a mask that would overflow a u64.
> 
> Suggested-by: Paolo Bonzini <pbonzini@...hat.com>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
>   arch/x86/kvm/mmu.h | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
> index 581925e476d6..261be1d2032b 100644
> --- a/arch/x86/kvm/mmu.h
> +++ b/arch/x86/kvm/mmu.h
> @@ -44,8 +44,15 @@
>   #define PT32_ROOT_LEVEL 2
>   #define PT32E_ROOT_LEVEL 3
>   
> -static inline u64 rsvd_bits(int s, int e)
> +static __always_inline u64 rsvd_bits(int s, int e)
>   {
> +	BUILD_BUG_ON(__builtin_constant_p(e) && __builtin_constant_p(s) && e < s);
> +
> +	if (__builtin_constant_p(e))
> +		BUILD_BUG_ON(e > 63);
> +	else
> +		e &= 63;
> +
>   	if (e < s)
>   		return 0;
>   
> 

Queued for 5.11, thanks.

Paolo

Powered by blists - more mailing lists