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: <20191112222533.GC4131@hirez.programming.kicks-ass.net>
Date:   Tue, 12 Nov 2019 23:25:33 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org, mhiramat@...nel.org,
        bristot@...hat.com, jbaron@...mai.com,
        torvalds@...ux-foundation.org, tglx@...utronix.de,
        mingo@...nel.org, namit@...are.com, hpa@...or.com, luto@...nel.org,
        ard.biesheuvel@...aro.org, jpoimboe@...hat.com, jeyu@...nel.org,
        alexei.starovoitov@...il.com
Subject: Re: [PATCH -v5 04/17] x86/alternatives: Add and use text_gen_insn()
 helper

On Tue, Nov 12, 2019 at 12:10:28PM -0500, Steven Rostedt wrote:
> On Mon, 11 Nov 2019 14:12:56 +0100
> Peter Zijlstra <peterz@...radead.org> wrote:
> 
> > +void *text_gen_insn(u8 opcode, const void *addr, const void *dest)
> > +{
> > +	static union text_poke_insn insn; /* text_mutex */
> > +	int size = 0;
> > +
> > +	lockdep_assert_held(&text_mutex);
> > +
> > +	insn.opcode = opcode;
> > +
> > +#define __CASE(insn)	\
> > +	case insn##_INSN_OPCODE: size = insn##_INSN_SIZE; break
> > +
> > +	switch(opcode) {
> > +	__CASE(INT3);
> > +	__CASE(CALL);
> > +	__CASE(JMP32);
> > +	__CASE(JMP8);
> > +	}
> > +
> > +	if (size > 1) {
> > +		insn.disp = (long)dest - (long)(addr + size);
> > +		if (size == 2)
> 
> Could we add a comment here. It took me a little bit to figure out why
> you have this BUG_ON().

:-)

Sure, I'll add something like:

			/*
			 * Ensure that for JMP.d8 the displacement
			 * actually fits the signed byte.
			 */

> > +			BUG_ON((insn.disp >> 31) != (insn.disp >> 7));
> > +	}
> > +
> > +	return &insn.text;
> > +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ