This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - --gnu-hash-table: do not crash when the GNU hash table goes past the EOF.
ClosedPublic

Authored by grimar on May 13 2020, 5:15 AM.

Details

Summary

We might have a scenario where a the GbuHashTable variable correctly points
to a place inside the file (we validate this fact early in parseDynamicTable),
but nbuckets/maskwords fields are broken in the way the code tries
to read the data past the EOF. This patch fixes the issue.

Diff Detail

Event Timeline

grimar created this revision.May 13 2020, 5:15 AM
Herald added a project: Restricted Project. · View Herald Transcript
MaskRay accepted this revision.May 13 2020, 9:28 AM

LGTM.

llvm/tools/llvm-readobj/ELFDumper.cpp
2681

IIRC this is guaranteed by ELFFile<ELFT>::toMappedAddr

This revision is now accepted and ready to land.May 13 2020, 9:28 AM
jhenderson accepted this revision.May 14 2020, 12:07 AM

LGTM, with one suggestion.

llvm/test/tools/llvm-readobj/ELF/gnuhash.test
323–324

I'd probably put these lines with their respective cases, since they're only used once.

grimar marked 2 inline comments as done.May 15 2020, 1:34 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
2681

Yes.

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.