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: <4C65B327.8020605@zytor.com>
Date:	Fri, 13 Aug 2010 14:03:35 -0700
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Xiaotian Feng <dfeng@...hat.com>, avi Kivity <avi@...hat.com>
CC:	x86@...nel.org, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	Suresh Siddha <suresh.b.siddha@...el.com>,
	Brian Gerst <brgerst@...il.com>, Avi Kivity <avi@...hat.com>,
	Robert Richter <robert.richter@....com>,
	Sheng Yang <sheng@...ux.intel.com>,
	Marcelo Tosatti <mtosatti@...hat.com>,
	Gleb Natapov <gleb@...hat.com>,
	Jan Kiszka <jan.kiszka@...mens.com>
Subject: Re: [PATCH] kvm: fix poison overwritten caused by using wrong xstate
 size

Avi, do you want to take this one or should I?

	-hpa

On 08/13/2010 12:19 AM, Xiaotian Feng wrote:
> fpu.state is allocated from task_xstate_cachep, the size of task_xstate_cachep
> is xstate_size. xstate_size is set from cpuid instruction, which is often
> smaller than sizeof(struct xsave_struct). kvm is using sizeof(struct xsave_struct)
> to fill in/out fpu.state.xsave, as what we allocated for fpu.state is
> xstate_size, kernel will write out of memory and caused poison/redzone/padding
> overwritten warnings.
> 
> Signed-off-by: Xiaotian Feng <dfeng@...hat.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: "H. Peter Anvin" <hpa@...or.com>
> Cc: Suresh Siddha <suresh.b.siddha@...el.com>
> Cc: Brian Gerst <brgerst@...il.com>
> Cc: Avi Kivity <avi@...hat.com>
> Cc: Robert Richter <robert.richter@....com>
> Cc: Sheng Yang <sheng@...ux.intel.com>
> Cc: Marcelo Tosatti <mtosatti@...hat.com>
> Cc: Gleb Natapov <gleb@...hat.com>
> Cc: Jan Kiszka <jan.kiszka@...mens.com>
> ---
>  arch/x86/kernel/i387.c |    1 +
>  arch/x86/kvm/x86.c     |    4 ++--
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
> index 1f11f5c..a46cb35 100644
> --- a/arch/x86/kernel/i387.c
> +++ b/arch/x86/kernel/i387.c
> @@ -40,6 +40,7 @@
>  
>  static unsigned int		mxcsr_feature_mask __read_mostly = 0xffffffffu;
>  unsigned int xstate_size;
> +EXPORT_SYMBOL_GPL(xstate_size);
>  unsigned int sig_xstate_ia32_size = sizeof(struct _fpstate_ia32);
>  static struct i387_fxsave_struct fx_scratch __cpuinitdata;
>  
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 25f1907..3a09c62 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2387,7 +2387,7 @@ static void kvm_vcpu_ioctl_x86_get_xsave(struct kvm_vcpu *vcpu,
>  	if (cpu_has_xsave)
>  		memcpy(guest_xsave->region,
>  			&vcpu->arch.guest_fpu.state->xsave,
> -			sizeof(struct xsave_struct));
> +			xstate_size);
>  	else {
>  		memcpy(guest_xsave->region,
>  			&vcpu->arch.guest_fpu.state->fxsave,
> @@ -2405,7 +2405,7 @@ static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu,
>  
>  	if (cpu_has_xsave)
>  		memcpy(&vcpu->arch.guest_fpu.state->xsave,
> -			guest_xsave->region, sizeof(struct xsave_struct));
> +			guest_xsave->region, xstate_size);
>  	else {
>  		if (xstate_bv & ~XSTATE_FPSSE)
>  			return -EINVAL;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ