Re: [PATCH] x86/alternatives: Fix optimize_nops() checking

From: Borislav Petkov
Date: Wed Jan 10 2018 - 15:56:03 EST


On Wed, Jan 10, 2018 at 12:26:25PM -0800, Linus Torvalds wrote:
> > I think Boris had a patch floating around to add an instruction decoder
> > to alternatives, so you can do a call/jmp anywhere.
>
> .. and no, we're not doing that. Christ.
>
> People, we need to try to be *robust* here. That's doubly (triply!)
> true of things like altinstructions where people - very much by design
> - won't even *test* the alternatives very much, because very much by
> design the altinstructions are only used on certain architectures or
> in certain situations.

Ok, so the problem was: how to fixup jumps which are not the first
instruction which is being replaced but a following one in the
instruction bytes with which we replace.

I used the insn decoder to get insn boundaries so that I can know
whether bytes 0xeb or 0xe9 are the actual JMP opcode and not some other
bytes from the stream.

So how do you suggest I do that without the decoder? I still need some
sort of parsing to find out where the boundaries are...

Thx.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.