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: <Yhi7jsnP8bRnx3If@hirez.programming.kicks-ass.net>
Date:   Fri, 25 Feb 2022 12:20:46 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Josh Poimboeuf <jpoimboe@...hat.com>
Cc:     x86@...nel.org, joao@...rdrivepizza.com, hjl.tools@...il.com,
        andrew.cooper3@...rix.com, linux-kernel@...r.kernel.org,
        ndesaulniers@...gle.com, keescook@...omium.org,
        samitolvanen@...gle.com, mark.rutland@....com,
        alyssa.milburn@...el.com, mbenes@...e.cz, rostedt@...dmis.org,
        mhiramat@...nel.org, alexei.starovoitov@...il.com
Subject: Re: [PATCH v2 16/39] x86/bpf: Add ENDBR instructions to prologue and
 trampoline

On Thu, Feb 24, 2022 at 03:37:31PM -0800, Josh Poimboeuf wrote:
> On Thu, Feb 24, 2022 at 03:51:54PM +0100, Peter Zijlstra wrote:
> > @@ -339,9 +350,18 @@ static int __bpf_arch_text_poke(void *ip
> >  	u8 *prog;
> >  	int ret;
> >  
> > +#ifdef CONFIG_X86_KERNEL_IBT
> > +	if (is_endbr(*(u32 *)ip))
> > +		ip += 4;
> > +#endif
> > +
> >  	memcpy(old_insn, nop_insn, X86_PATCH_SIZE);
> >  	if (old_addr) {
> >  		prog = old_insn;
> > +#ifdef CONFIG_X86_KERNEL_IBT
> > +		if (is_endbr(*(u32 *)old_addr))
> > +			old_addr += 4;
> > +#endif
> >  		ret = t == BPF_MOD_CALL ?
> >  		      emit_call(&prog, old_addr, ip) :
> >  		      emit_jump(&prog, old_addr, ip);
> > @@ -352,6 +372,10 @@ static int __bpf_arch_text_poke(void *ip
> >  	memcpy(new_insn, nop_insn, X86_PATCH_SIZE);
> >  	if (new_addr) {
> >  		prog = new_insn;
> > +#ifdef CONFIG_X86_KERNEL_IBT
> > +		if (is_endbr(*(u32 *)new_addr))
> > +			new_addr += 4;
> > +#endif
> 
> All the above ifdef-itis should be able to be removed since is_endbr()
> returns false for !IBT.

So I've been pondering a skip_endbr() function for all these sites.

I just couldn't decide making it a 'function' and having a signature
like:

	ip = skip_endbr(ip);

or making it macro magic and it reading:

	skip_endbr(ip);

Which is why I've not cleaned it up yet.  This being C(ish) I suppose
the former is less confusing, so let me go do that.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ