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: <20250930073910.GH4067720@noisy.programming.kicks-ass.net>
Date: Tue, 30 Sep 2025 09:39:10 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jürgen Groß <jgross@...e.com>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH 3/3] x86/alternative: Patch a single alternative location
 only once

On Tue, Sep 30, 2025 at 09:33:25AM +0200, Jürgen Groß wrote:
> On 30.09.25 09:26, Peter Zijlstra wrote:

> > > @@ -692,14 +698,19 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
> > >   		 * - feature not present but ALT_FLAG_NOT is set to mean,
> > >   		 *   patch if feature is *NOT* present.
> > >   		 */
> > > -		if (!boot_cpu_has(a->cpuid) == !(a->flags & ALT_FLAG_NOT)) {
> > > -			memcpy(insn_buff, instr, a->instrlen);
> > > -			optimize_nops(instr, insn_buff, a->instrlen);
> > > -		} else {
> > > +		if (!boot_cpu_has(a->cpuid) != !(a->flags & ALT_FLAG_NOT)) {
> > >   			apply_one_alternative(instr, insn_buff, a);
> > > +			patched = true;
> > >   		}
> > > -		text_poke_early(instr, insn_buff, a->instrlen);
> > > +		instances--;
> > > +		if (!instances) {
> > > +			if (!patched) {
> > > +				memcpy(insn_buff, instr, a->instrlen);
> > > +				optimize_nops(instr, insn_buff, a->instrlen);
> > > +			}
> > > +			text_poke_early(instr, insn_buff, a->instrlen);
> > > +		}
> > >   	}
> > >   	kasan_enable_current();
> > 
> > I think you lost the optimize_nops() call for the patched case.
> > 
> > That is, note how apply_one_alternative() does 0x90 padding, but then
> > you only do optimize_nops() when !patched.
> 
> The call of optimize_nops() is part of text_poke_apply_relocation() when
> patching, like without my series.

Indeed it is. Clearly I need more wakeup juice :-)

Therefore the patches seem fine. I'll try and hold onto them until the
merge window closes and then stick them in x86/core or thereabout.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ