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: <20250103151905.GCZ3f_6U97nnsMrSR_@fat_crate.local>
Date: Fri, 3 Jan 2025 16:19:05 +0100
From: Borislav Petkov <bp@...en8.de>
To: David Kaplan <david.kaplan@....com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
	Peter Zijlstra <peterz@...radead.org>,
	Josh Poimboeuf <jpoimboe@...nel.org>,
	Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>,
	Ingo Molnar <mingo@...hat.com>,
	Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
	"H . Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 20/35] x86/bugs: Define attack vectors

On Tue, Nov 05, 2024 at 03:54:40PM -0600, David Kaplan wrote:
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index d0699e47178b..841bcffee5d3 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c

I faintly remember talking about this but shouldn't we make those vectors
x86-only for now?

No need to have them in generic code as other arches will need to get enabled
first anyway so they can lift them here when they need them.

> @@ -3200,6 +3200,22 @@ enum cpu_mitigations {
>  
>  static enum cpu_mitigations cpu_mitigations __ro_after_init = CPU_MITIGATIONS_AUTO;
>  
> +/*
> + * All except the cross-thread attack vector are mitigated by default.
> + * Cross-thread mitigation often requires disabling SMT which is too expensive
> + * to be enabled by default.
> + *
> + * Guest-to-Host and Guest-to-Guest vectors are only needed if KVM support is
> + * present.
> + */
> +static bool cpu_mitigate_attack_vectors[NR_CPU_ATTACK_VECTORS] __ro_after_init = {
> +	[CPU_MITIGATE_USER_KERNEL] = true,
> +	[CPU_MITIGATE_USER_USER] = true,
> +	[CPU_MITIGATE_GUEST_HOST] = IS_ENABLED(CONFIG_KVM),
> +	[CPU_MITIGATE_GUEST_GUEST] = IS_ENABLED(CONFIG_KVM),
> +	[CPU_MITIGATE_CROSS_THREAD] = false
> +};
> +
>  static int __init mitigations_parse_cmdline(char *arg)
>  {
>  	if (!strcmp(arg, "off"))
> @@ -3228,11 +3244,53 @@ bool cpu_mitigations_auto_nosmt(void)
>  	return cpu_mitigations == CPU_MITIGATIONS_AUTO_NOSMT;
>  }
>  EXPORT_SYMBOL_GPL(cpu_mitigations_auto_nosmt);
> +
> +#define DEFINE_ATTACK_VECTOR(opt, v) \
> +static int __init v##_parse_cmdline(char *arg) \
> +{ \
> +	if (!strcmp(arg, "off")) \
> +		cpu_mitigate_attack_vectors[v] = false; \
> +	else if (!strcmp(arg, "on")) \
> +		cpu_mitigate_attack_vectors[v] = true; \
> +	else \
> +		pr_warn("Unsupported " opt "=%s\n", arg); \
> +	return 0; \
> +} \
> +early_param(opt, v##_parse_cmdline)
> +
> +bool cpu_mitigate_attack_vector(enum cpu_attack_vectors v)
> +{
> +	BUG_ON(v >= NR_CPU_ATTACK_VECTORS);

Yeah, we don't love BUG* at all if it can be helped without it. And here it
can. You can simply return false for out-of-range vector and WARN_ON_ONCE.

Thx.

-- 
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