Messages in this thread | | | Date | Mon, 28 Feb 2022 10:26:07 +0100 | From | Peter Zijlstra <> | Subject | Re: [PATCH v2 34/39] objtool: Validate IBT assumptions |
| |
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 :-)
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 ?
| |