This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readelf] - Do not enter an infinite loop when printing histogram.
ClosedPublic

Authored by grimar on Oct 10 2019, 2:47 AM.

Details

Summary

This is similar to D68086.
We are entering an infinite loop when dumping a histogram for a specially crafted
.hash section with a loop in a chain.

Diff Detail

Event Timeline

grimar created this revision.Oct 10 2019, 2:47 AM
MaskRay added inline comments.Oct 10 2019, 3:14 AM
test/tools/llvm-readobj/elf-hash-histogram.test
51 ↗(On Diff #224291)

Delete all of Address AddressAlign VAddr (see elf-hash-symbols.test)

grimar marked an inline comment as done.Oct 10 2019, 4:01 AM
grimar added inline comments.
test/tools/llvm-readobj/elf-hash-histogram.test
51 ↗(On Diff #224291)

I think I can't, elf-hash-symbols.test is different, see:
https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-readobj/ELFDumper.cpp#L3954

Here getHashTable returns something based on DT_HASH:
https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-readobj/ELFDumper.cpp#L1713

I.e, I think I've already simplified this YAML to a minimum or at least to a very reasonable minimum.
Am I missing something?

grimar planned changes to this revision.Oct 10 2019, 4:07 AM
grimar marked an inline comment as done.
grimar added inline comments.
test/tools/llvm-readobj/elf-hash-histogram.test
51 ↗(On Diff #224291)

Ah, sorry, I've got it now. I've looked at the wrong test case.

grimar updated this revision to Diff 224306.Oct 10 2019, 4:15 AM
  • Addressed review comments.
MaskRay accepted this revision.Oct 10 2019, 4:21 AM
This revision is now accepted and ready to land.Oct 10 2019, 4:21 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2019, 6:29 AM
jhenderson added inline comments.Oct 29 2019, 4:11 AM
llvm/test/tools/llvm-readobj/elf-hash-histogram.test
45

Nit: This should probably have been ET_DYN or ET_EXEC. Program headers and dynamic sections in relocatable objects are... odd :) No need to change it again though if you don't want to.