lkml.org 
[lkml]   [2022]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v2 34/39] objtool: Validate IBT assumptions
    On Mon, Feb 28, 2022 at 10:26:07AM +0100, Peter Zijlstra wrote:
    > On Sun, Feb 27, 2022 at 06:00:03PM +0100, Peter Zijlstra wrote:
    > > On Sat, Feb 26, 2022 at 07:13:48PM -0800, Josh Poimboeuf wrote:
    > > > > +static struct instruction *
    > > > > +validate_ibt_reloc(struct objtool_file *file, struct reloc *reloc)
    > > > > +{
    > > > > + struct instruction *dest;
    > > > > + struct section *sec;
    > > > > + unsigned long off;
    > > > > +
    > > > > + sec = reloc->sym->sec;
    > > > > + off = reloc->sym->offset + reloc->addend;
    > > >
    > > > This math assumes non-PC-relative. If it's R_X86_64_PC32 or
    > > > R_X86_64_PLT32 then it needs +4 added.
    > >
    > > Right; so I actually had that PC32 thing in there for a while, but ran
    > > into other trouble. I'll go try and figure it out.
    >
    > Things like .rela.initcall*.init use PC32 but don't need the +4. If we
    > get that wrong it'll seal all the initcall and boot doesn't get very
    > far at all :-)

    Ah...

    > How do you feel about something like:
    >
    > sec = reloc->sym->sec;
    > off = reloc->sym->offset;
    >
    > if ((reloc->sec->base->sh.sh_flags & SHF_EXECINSTR) &&
    > (reloc->type == R_X86_64_PC32 || reloc->type == R_X86_64_PLT32))
    > off += arch_dest_reloc_offset(reloc->addend);
    > else
    > off += reloc->addend;
    >
    >
    > hmm ?

    Looks good to me.

    --
    Josh

    \
     
     \ /
      Last update: 2022-02-28 19:44    [W:4.067 / U:0.068 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site