Re: [PATCH v2 7/9] x86: Add support for function granular KASLR

From: Kristen Carlson Accardi
Date: Thu May 21 2020 - 17:43:02 EST


Hi Kees,
Thanks for your review - I will incorporate what I can into v3, or
explain why not once I give it a try :).

On Thu, 2020-05-21 at 14:08 -0700, Kees Cook wrote:
> >
<snip>

> On Thu, May 21, 2020 at 09:56:38AM -0700, Kristen Carlson Accardi
> wrote:
> > + /*
> > + * sometimes we are updating a relative offset that would
> > + * normally be relative to the next instruction (such as a
> > call).
> > + * In this case to calculate the target, you need to add 32bits
> > to
> > + * the pc to get the next instruction value. However, sometimes
> > + * targets are just data that was stored in a table such as
> > ksymtab
> > + * or cpu alternatives. In this case our target is not relative
> > to
> > + * the next instruction.
> > + */
>
> Excellent and scary comment. ;) Was this found by trial and error?
> That
> sounds "fun" to debug. :P

This did suck to debug. Thank goodness for debugging with gdb in a VM.
As you know, I had previously had a patch to use a prand to be able to
retain the same layout across boots, and that came in handy here. While
we decided to not submit this functionality with this initial merge
attempt, I will add it on in the future as it does make debugging much
easier when you can reliably duplicate failure modes.