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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e32dc7de-9f97-4857-8e07-0905a94acfad@zytor.com>
Date: Thu, 22 May 2025 00:20:13 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: "Xin Li (Intel)" <xin@...or.com>, linux-kernel@...r.kernel.org
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
        dave.hansen@...ux.intel.com, x86@...nel.org, peterz@...radead.org,
        andrew.cooper3@...rix.com, stable@...r.kernel.org
Subject: Re: [PATCH v1 1/1] x86/fred/signal: Prevent single-step upon ERETU
 completion

On 5/21/25 23:05, Xin Li (Intel) wrote:
>  
> +/*
> + * To prevent infinite SIGTRAP handler loop if TF is used without an external
> + * debugger, clear the software event flag in the augmented SS, ensuring no
> + * single-step trap is pending upon ERETU completion.
> + *
> + * Note, this function should be called in sigreturn() before the original state
> + * is restored to make sure the TF is read from the entry frame.
> + */
> +static __always_inline void prevent_single_step_upon_eretu(struct pt_regs *regs)
> +{
> +	/*
> +	 * If the trap flag (TF) is set, i.e., the sigreturn() SYSCALL instruction
> +	 * is being single-stepped, do not clear the software event flag in the
> +	 * augmented SS, thus a debugger won't skip over the following instruction.
> +	 */
> +	if (IS_ENABLED(CONFIG_X86_FRED) && cpu_feature_enabled(X86_FEATURE_FRED) &&
> +	    !(regs->flags & X86_EFLAGS_TF))
> +		regs->fred_ss.swevent = 0;
> +}
> +

Minor nit (and I should have caught this when I saw your patch earlier):

cpu_feature_enabled(X86_FEATURE_FRED) is unnecessary here, because when
FRED is not enabled, regs->fred_ss.swevent will always be 0, and this
bit has no function, so there is no point in making that extra test.

The only reason for IS_ENABLED(CONFIG_X86_FRED) (which is implied in
cpu_feature_enabled() anyway via !CONFIG_X86_DISABLED_FEATURE_FRED) is
to eliminate the code entirely if FRED is not compiled in.

Although the way it goes, it sounds like CONFIG_X86_FRED might go away
soon anyway, since KVM wants to use some of the FRED code
unconditionally (and Xen might follow, too.)

	-hpa


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ