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: <7a9d29bd-d247-4e57-8330-14f6a5008864@zytor.com>
Date: Thu, 22 May 2025 10:10:00 -0700
From: Xin Li <xin@...or.com>
To: "H. Peter Anvin" <hpa@...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/22/2025 12:20 AM, H. Peter Anvin wrote:
> 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.

Yeah, less conditions, less complexity.  I will remove it.

Thanks!
     Xin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ