This is an archive of the discontinued LLVM Phabricator instance.

[lldb] reject `.debug_arange` sections with nonzero segment size
ClosedPublic

Authored by ldrumm on Mar 10 2020, 8:12 AM.

Details

Summary
If a producer emits a nonzero segment size, `lldb` will silently read
incorrect values and crash, or do something worse later, as the tuple
size is expected to be 2, rather than 3.

Neither LLVM, nor GCC produce segmented aranges, but this dangerous case
should still be checked and handled.

Diff Detail

Event Timeline

ldrumm created this revision.Mar 10 2020, 8:12 AM

Change looks good, just needs a test. Should be easy to take a simple binary that has a .debug_aranges, and run obj2yaml on it, and tweak the segment size as needed?

Change looks good, just needs a test. Should be easy to take a simple binary that has a .debug_aranges, and run obj2yaml on it, and tweak the segment size as needed?

In this case I think the cleanest solution would be to write a c++ unit test: create a simple debug_aranges header (just hardcode bytes, nothing fancy), pass it to DWARFDebugArangesSet::extract, and check the result.

ldrumm updated this revision to Diff 249663.EditedMar 11 2020, 10:07 AM

I found similar unittests for other DWARF entries which allow me to check more about the parser state, so I went with Pavel's suggestion for the testcase

lgtm once all formatting issues are taken care of. Pavel?

labath accepted this revision.Mar 12 2020, 3:26 AM

Looks good, just run clang-format before committing.

This revision is now accepted and ready to land.Mar 12 2020, 3:26 AM
This revision was automatically updated to reflect the committed changes.