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]
Date:   Fri, 21 Feb 2020 15:04:33 +0100
From:   Borislav Petkov <bp@...en8.de>
To:     Yu-cheng Yu <yu-cheng.yu@...el.com>
Cc:     linux-kernel@...r.kernel.org, x86@...nel.org,
        "H. Peter Anvin" <hpa@...or.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Tony Luck <tony.luck@...el.com>,
        Andy Lutomirski <luto@...nel.org>,
        Rik van Riel <riel@...riel.com>,
        "Ravi V. Shankar" <ravi.v.shankar@...el.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Fenghua Yu <fenghua.yu@...el.com>,
        Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH v2 4/8] x86/fpu/xstate: Define new functions for clearing
 fpregs and xstates

On Tue, Jan 21, 2020 at 12:18:39PM -0800, Yu-cheng Yu wrote:
> @@ -318,9 +313,29 @@ static inline void copy_init_fpstate_to_fpregs(void)
>   * Called by sys_execve(), by the signal handler code and by various
>   * error paths.
>   */
> -void fpu__clear(struct fpu *fpu)
> +void fpu__clear_user_states(struct fpu *fpu)
> +{
> +	WARN_ON_FPU(fpu != &current->thread.fpu);
> +
> +	if (static_cpu_has(X86_FEATURE_FPU)) {
> +		fpregs_lock();
> +		if (!fpregs_state_valid(fpu, smp_processor_id()) &&
> +		    xfeatures_mask_supervisor())
> +			copy_kernel_to_xregs(&fpu->state.xsave,
> +					     xfeatures_mask_supervisor());
> +		copy_init_fpstate_to_fpregs(xfeatures_mask_user());
> +		fpregs_mark_activate();
> +		fpregs_unlock();
> +		return;
> +	} else {
> +		fpu__drop(fpu);
> +		fpu__initialize(fpu);
> +	}
> +}
> +
> +void fpu__clear_all(struct fpu *fpu)
>  {
> -	WARN_ON_FPU(fpu != &current->thread.fpu); /* Almost certainly an anomaly */
> +	WARN_ON_FPU(fpu != &current->thread.fpu);
>  
>  	fpu__drop(fpu);
>  
> @@ -328,8 +343,12 @@ void fpu__clear(struct fpu *fpu)
>  	 * Make sure fpstate is cleared and initialized.
>  	 */
>  	fpu__initialize(fpu);
> -	if (static_cpu_has(X86_FEATURE_FPU))
> -		copy_init_fpstate_to_fpregs();
> +	if (static_cpu_has(X86_FEATURE_FPU)) {
> +		fpregs_lock();
> +		copy_init_fpstate_to_fpregs(xfeatures_mask_all);
> +		fpregs_mark_activate();
> +		fpregs_unlock();
> +	}
>  }

Why do you need two different functions which are pretty similar if you
can do

fpu__clear(struct fpu *fpu, bool user_only)
{
	...

and query that user_only variable in the fpu__clear() body to do the
respective work dependent on the its setting?

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ