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: <o3ceiexzywuw4udvxf3fcxyjqlff4kpvepjr2jii67oghkyai2@6dok6fljt2vs>
Date: Thu, 10 Apr 2025 09:26:08 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: David Kaplan <david.kaplan@....com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>, 
	Peter Zijlstra <peterz@...radead.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, 
	Brendan Jackman <jackmanb@...gle.com>, Derek Manwaring <derekmn@...zon.com>
Subject: Re: [PATCH v4 11/36] x86/bugs: Restructure spectre_v2_user mitigation

On Mon, Mar 10, 2025 at 11:39:58AM -0500, David Kaplan wrote:
>  static inline bool spectre_v2_in_ibrs_mode(enum spectre_v2_mitigation mode)
> @@ -1446,10 +1436,10 @@ static inline bool spectre_v2_in_ibrs_mode(enum spectre_v2_mitigation mode)
>  	return spectre_v2_in_eibrs_mode(mode) || mode == SPECTRE_V2_IBRS;
>  }
>  
> +

Extra newline here.

>  	case SPECTRE_V2_USER_CMD_SECCOMP:
> -	case SPECTRE_V2_USER_CMD_SECCOMP_IBPB:
>  		if (IS_ENABLED(CONFIG_SECCOMP))
> -			mode = SPECTRE_V2_USER_SECCOMP;
> +			spectre_v2_user_ibpb = SPECTRE_V2_USER_SECCOMP;
>  		else
> -			mode = SPECTRE_V2_USER_PRCTL;
> +			spectre_v2_user_ibpb = SPECTRE_V2_USER_PRCTL;
> +		spectre_v2_user_stibp = spectre_v2_user_ibpb;
> +		break;
> +	case SPECTRE_V2_USER_CMD_SECCOMP_IBPB:
> +		spectre_v2_user_ibpb = SPECTRE_V2_USER_STRICT;
> +		spectre_v2_user_stibp = SPECTRE_V2_USER_PRCTL;
>  		break;
>  	}

For SPECTRE_V2_USER_CMD_SECCOMP_IBPB, shouldn't spectre_v2_user_stibp
be SPECTRE_V2_USER_SECCOMP if CONFIG_SECCOMP?

Also I think spectre_v2_user_ibpb needs to be cleared here if
X86_FEATURE_IBPB isn't set.  And similar for spectre_v2_user_stibp and
X86_FEATURE_STIBP.

> -	/* Initialize Indirect Branch Prediction Barrier */
> -	if (boot_cpu_has(X86_FEATURE_IBPB)) {
> -		static_branch_enable(&switch_vcpu_ibpb);
> +	/*
> +	 * At this point, an STIBP mode other than "off" has been set.
> +	 * If STIBP support is not being forced, check if STIBP always-on
> +	 * is preferred.
> +	 */
> +	if (spectre_v2_user_stibp != SPECTRE_V2_USER_STRICT &&
> +	    boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON))
> +		spectre_v2_user_stibp = SPECTRE_V2_USER_STRICT_PREFERRED;

Instead of checking for !SPECTRE_V2_USER_STRICT it would probably be
better to check for SPECTRE_V2_USER_PRCTL or SPECTRE_V2_USER_SECCOMP
directly.

Then the returns added to the SPECTRE_V2_USER_CMD_AUTO case in
"x86/bugs: Add attack vector controls for spectre_v2_user" can be
converted to breaks, which simplifies the control flow and also allows
the above-suggested X86_FEATURE_IBPB/X86_FEATURE_STIBP checks to keep
working.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ