Re: [PATCH 5/9] x86/dumpstack: Improve opcodes dumping in the Code: section

From: Borislav Petkov
Date: Thu Mar 08 2018 - 17:36:54 EST


On Thu, Mar 08, 2018 at 10:00:09AM -0800, Linus Torvalds wrote:
> On Thu, Mar 8, 2018 at 2:16 AM, Borislav Petkov <bp@xxxxxxxxx> wrote:
> > +#define OPCODE_BUFSIZE 64
> > + unsigned int code_prologue = OPCODE_BUFSIZE * 43 / OPCODE_BUFSIZE;
>
> Heh.
>
> That's a very odd way of writing "43".

I was simply search-replacing code_bytes :-)

> Honestly, the "43" is just "two thirds" rounded to closest, and it's
> not important anyway, so I think you should just write it as
>
> unsigned int code_prologue = OPCODE_BUFSIZE * 2 / 3;

Btw, do we have any explanation for the two-thirds prologue? I dug it
out to the patch below but it doesn't say why the prologue being bigger
is more important than the epilogue.

I would've made it half and half but I guess it is more important to see
the opcode bytes leading to rip... Oh well.

> and never mind that it will now be 42.
>
> 42 is obviously the right answer anyway, which makes me think we got
> it wrong earlier.

Doh, of course! What was I thinking?!? :-)

Done.

---