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: <YMs3B6i6mK5F7+gd@zn.tnic>
Date:   Thu, 17 Jun 2021 13:50:31 +0200
From:   Borislav Petkov <bp@...e.de>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Andy Lutomirski <luto@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Fenghua Yu <fenghua.yu@...el.com>,
        Tony Luck <tony.luck@...el.com>,
        Yu-cheng Yu <yu-cheng.yu@...el.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Kan Liang <kan.liang@...ux.intel.com>
Subject: Re: [patch V2 16/52] x86/fpu: Use copy_uabi_xstate_to_membuf() in
 fpregs_get()

On Mon, Jun 14, 2021 at 05:44:24PM +0200, Thomas Gleixner wrote:
> Use the new functionality of copy_uabi_xstate_to_membuf() to retrieve the
> FX state when XSAVE* is in use. This avoids to overwrite the FPU state
> buffer with fpstate_sanitize_xstate() which is error prone and duplicated
> code.
> 
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> ---
> V2: New patch
> ---
>  arch/x86/kernel/fpu/regset.c |   30 ++++++++++++++++++++----------
>  1 file changed, 20 insertions(+), 10 deletions(-)
> 
> --- a/arch/x86/kernel/fpu/regset.c
> +++ b/arch/x86/kernel/fpu/regset.c
> @@ -211,10 +211,10 @@ static inline u32 twd_fxsr_to_i387(struc
>   * FXSR floating point environment conversions.
>   */
>  
> -void
> -convert_from_fxsr(struct user_i387_ia32_struct *env, struct task_struct *tsk)
> +static void __convert_from_fxsr(struct user_i387_ia32_struct *env,
> +				struct task_struct *tsk,
> +				struct fxregs_state *fxsave)
>  {
> -	struct fxregs_state *fxsave = &tsk->thread.fpu.state.fxsave;
>  	struct _fpreg *to = (struct _fpreg *) &env->st_space[0];
>  	struct _fpxreg *from = (struct _fpxreg *) &fxsave->st_space[0];
>  	int i;
> @@ -248,6 +248,12 @@ convert_from_fxsr(struct user_i387_ia32_
>  		memcpy(&to[i], &from[i], sizeof(to[0]));
>  }
>  
> +void
> +convert_from_fxsr(struct user_i387_ia32_struct *env, struct task_struct *tsk)
> +{
> +	__convert_from_fxsr(env, tsk, &tsk->thread.fpu.state.fxsave);
> +}
> +
>  void convert_to_fxsr(struct fxregs_state *fxsave,
>  		     const struct user_i387_ia32_struct *env)
>  
> @@ -280,25 +286,29 @@ int fpregs_get(struct task_struct *targe
>  {
>  	struct fpu *fpu = &target->thread.fpu;
>  	struct user_i387_ia32_struct env;
> +	struct fxregs_state fxsave, *fx;
>  
>  	fpu__prepare_read(fpu);
>  
> -	if (!boot_cpu_has(X86_FEATURE_FPU))
> +	if (!static_cpu_has(X86_FEATURE_FPU))
>  		return fpregs_soft_get(target, regset, to);
>  
> -	if (!boot_cpu_has(X86_FEATURE_FXSR)) {
> +	if (!static_cpu_has(X86_FEATURE_FXSR)) {

both: cpu_feature_enabled

With that:

Reviewed-by: Borislav Petkov <bp@...e.de>

-- 
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ