This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readelf] - Report a warning when .hash section contains a chain with a cycle.
ClosedPublic

Authored by grimar on Sep 26 2019, 7:18 AM.

Details

Summary

It is possible to craft a .hash section that triggers an infinite loop
in llvm-readelf code. This patch fixes the issue and introduces
a warning.

Diff Detail

Event Timeline

grimar created this revision.Sep 26 2019, 7:18 AM
MaskRay added inline comments.Sep 26 2019, 8:35 AM
test/tools/llvm-readobj/elf-hash-symbols.test
365

an entry of the bucket array points to a cycle

391

Suggested wording:

llvm-readelf will read the hash table from the file offset p_offset + (p_vaddr - DT_HASH) = p_offset + (0 - 0) = p_offset, which is the start of PT_LOAD, i.e. the file offset of .hash

jhenderson added inline comments.Sep 27 2019, 2:02 AM
test/tools/llvm-readobj/elf-hash-symbols.test
365

Also "when a hash table" or similar.

I think combining the two suggests:

"Show that we report a warning for a hash table which contains an entry of the bucket array pointing to a cycle."

tools/llvm-readobj/ELFDumper.cpp
3446

Perhaps worth giving more context to this message, i.e. something about a cycle being detected linking which buckets.

grimar updated this revision to Diff 222589.Oct 1 2019, 4:23 AM
grimar marked 4 inline comments as done.
  • Addressed review comments.
grimar edited the summary of this revision. (Show Details)Oct 1 2019, 4:23 AM
jhenderson accepted this revision.Oct 1 2019, 6:01 AM

LGTM, with one nit.

test/tools/llvm-readobj/elf-hash-symbols.test
393

Nit: missing trailing full stop.

This revision is now accepted and ready to land.Oct 1 2019, 6:01 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 2 2019, 7:10 AM