This is an archive of the discontinued LLVM Phabricator instance.

[Object/ELF] - Check index argument in getSymbol().
ClosedPublic

Authored by grimar on Oct 12 2016, 8:12 AM.

Details

Summary

Without this check LLD crashes when SHT_GROUP section has invalid symbol index
because of next code:

template <class ELFT>
StringRef elf::ObjectFile<ELFT>::getShtGroupSignature(const Elf_Shdr &Sec) {
..
  const Elf_Sym *Sym = Obj.getSymbol(Symtab, Sec.sh_info);
..
}

If sh_info is too large, &Symbols[Index] just asserts.

No testcases provided because llvm-objdump/llvm-readelf does not use getSymbol() function.
Though if this be landed I will be happy to add testcase for lld showing the issue.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 74383.Oct 12 2016, 8:12 AM
grimar retitled this revision from to [Object/ELF] - Check index argument in getSymbol()..
grimar updated this object.
grimar added reviewers: rafael, davide.
grimar updated this object.
grimar added subscribers: llvm-commits, grimar, evgeny777.
ruiu accepted this revision.Oct 19 2016, 4:48 PM
ruiu added a reviewer: ruiu.
ruiu added a subscriber: ruiu.

LGTM

This revision is now accepted and ready to land.Oct 19 2016, 4:48 PM

Thanks, Rui !

This revision was automatically updated to reflect the committed changes.