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: <20160115202858.GK25104@pd.tnic>
Date:	Fri, 15 Jan 2016 21:28:58 +0100
From:	Borislav Petkov <bp@...en8.de>
To:	linux-kernel@...r.kernel.org, peterz@...radead.org,
	torvalds@...ux-foundation.org, tglx@...utronix.de, oleg@...hat.com,
	ravi.v.shankar@...el.com, yu-cheng.yu@...el.com,
	fenghua.yu@...el.com, mingo@...nel.org,
	dave.hansen@...ux.intel.com, quentin.casasnovas@...cle.com,
	bp@...e.de, hpa@...or.com, luto@...capital.net,
	sai.praneeth.prakhya@...el.com
Cc:	linux-tip-commits@...r.kernel.org
Subject: Re: [tip:x86/asm] x86/fpu: Fix early FPU command-line parsing

On Tue, Jan 12, 2016 at 04:00:49AM -0800, tip-bot for yu-cheng yu wrote:
> Commit-ID:  4f81cbafcce2c603db7865e9d0e461f7947d77d4
> Gitweb:     http://git.kernel.org/tip/4f81cbafcce2c603db7865e9d0e461f7947d77d4
> Author:     yu-cheng yu <yu-cheng.yu@...el.com>
> AuthorDate: Wed, 6 Jan 2016 14:24:51 -0800
> Committer:  Ingo Molnar <mingo@...nel.org>
> CommitDate: Tue, 12 Jan 2016 11:51:20 +0100
> 
> x86/fpu: Fix early FPU command-line parsing
> 
> The function fpu__init_system() is executed before
> parse_early_param(). This causes wrong FPU configuration. This
> patch fixes this issue by parsing boot_command_line in the
> beginning of fpu__init_system().
> 
> With all four patches in this series, each parameter disables
> features as the following:
> 
> eagerfpu=off: eagerfpu, avx, avx2, avx512, mpx
> no387: fpu
> nofxsr: fxsr, fxsropt, xmm
> noxsave: xsave, xsaveopt, xsaves, xsavec, avx, avx2, avx512,
> mpx, xgetbv1 noxsaveopt: xsaveopt
> noxsaves: xsaves
> 
> Signed-off-by: Yu-cheng Yu <yu-cheng.yu@...el.com>
> Cc: Andy Lutomirski <luto@...capital.net>
> Cc: Borislav Petkov <bp@...en8.de>
> Cc: Borislav Petkov <bp@...e.de>
> Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> Cc: Fenghua Yu <fenghua.yu@...el.com>
> Cc: H. Peter Anvin <hpa@...or.com>
> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> Cc: Oleg Nesterov <oleg@...hat.com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Quentin Casasnovas <quentin.casasnovas@...cle.com>
> Cc: Ravi V. Shankar <ravi.v.shankar@...el.com>
> Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@...el.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: yu-cheng yu <yu-cheng.yu@...el.com>
> Link: http://lkml.kernel.org/r/1452119094-7252-2-git-send-email-yu-cheng.yu@intel.com
> Signed-off-by: Ingo Molnar <mingo@...nel.org>
> ---
>  arch/x86/kernel/fpu/init.c | 109 ++++++++++++++++-----------------------------
> 1 file changed, 38 insertions(+), 71 deletions(-)

...

> + * We parse fpu parameters early because fpu__init_system() is executed
> + * before parse_early_param().
> + */
> +static void __init fpu__init_parse_early_param(void)
> +{
> +	/*
> +	 * No need to check "eagerfpu=auto" again, since it is the
> +	 * initial default.
> +	 */
> +	if (cmdline_find_option_bool(boot_command_line, "eagerfpu=off"))
> +		eagerfpu = DISABLE;
> +	else if (cmdline_find_option_bool(boot_command_line, "eagerfpu=on"))
> +		eagerfpu = ENABLE;
> +
> +	if (cmdline_find_option_bool(boot_command_line, "no387"))
> +		setup_clear_cpu_cap(X86_FEATURE_FPU);
> +
> +	if (cmdline_find_option_bool(boot_command_line, "nofxsr")) {
> +		setup_clear_cpu_cap(X86_FEATURE_FXSR);
> +		setup_clear_cpu_cap(X86_FEATURE_FXSR_OPT);
> +		setup_clear_cpu_cap(X86_FEATURE_XMM);
> +	}
> +
> +	if (cmdline_find_option_bool(boot_command_line, "noxsave"))
> +		fpu__xstate_clear_all_cpu_caps();
> +
> +	if (cmdline_find_option_bool(boot_command_line, "noxsaveopt"))
> +		setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
> +
> +	if (cmdline_find_option_bool(boot_command_line, "noxsaves"))
> +		setup_clear_cpu_cap(X86_FEATURE_XSAVES);

This could certainly be improved: we're iterating over the *whole*
command line each time for each option unconditionally instead of
iterating word by word and comparing it with all strings.

We'd need something like cmdline_for_each_word() or so, though...

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ