[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201022080405.GS2628@hirez.programming.kicks-ass.net>
Date: Thu, 22 Oct 2020 10:04:05 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Borislav Petkov <bp@...en8.de>
Cc: Masami Hiramatsu <mhiramat@...nel.org>, x86-ml <x86@...nel.org>,
Joerg Roedel <jroedel@...e.de>,
lkml <linux-kernel@...r.kernel.org>
Subject: Re: [RFC] Have insn decoder functions return success/failure
On Wed, Oct 21, 2020 at 06:45:58PM +0200, Borislav Petkov wrote:
> On Wed, Oct 21, 2020 at 11:26:13PM +0900, Masami Hiramatsu wrote:
> > Hmm, I meant someone might think it can be used for filtering the
> > instruction something like,
> >
> > insn_init(insn, buf, buflen, 1);
> > ret = insn_get_length(insn);
> > if (!ret) {
> > /* OK, this is safe */
> > patch_text(buf, trampoline);
> > }
> >
> > No, we need another validator for such usage.
>
> Well, I think calling insn_get_length() should give you only the
> *length* of the insn and nothing else - I mean that is what the function
> is called. And I believe current use is wrong.
>
> Examples:
>
> arch/x86/kernel/kprobes/core.c:
> insn_get_length(&insn);
>
> /*
> * Another debugging subsystem might insert this breakpoint.
> * In that case, we can't recover it.
> */
> if (insn.opcode.bytes[0] == INT3_INSN_OPCODE)
>
> So this has called get_length but it is far from clear that after that
> call, the opcode bytes in insn.opcode.bytes are there.
Given the trainwreck called x86-instruction-encoding, it's impossible to
not have decoded the opcode and still know the length. Therefore, if you
know the length, you also have the opcode. Hm?
Powered by blists - more mailing lists