This is an archive of the discontinued LLVM Phabricator instance.

[BitcodeReader] Validate Strtab before accessing.
ClosedPublic

Authored by fhahn on Jan 27 2021, 11:56 AM.

Details

Summary

This fixes a crash with invalid bitcode files that have records
referencing names in Strtab, but Strtab is not present or the index is
out-of-bounds.

This fixes the following clusterfuzz issue:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29895

Diff Detail

Event Timeline

fhahn created this revision.Jan 27 2021, 11:56 AM
fhahn requested review of this revision.Jan 27 2021, 11:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2021, 11:57 AM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm added inline comments.Jan 29 2021, 7:47 AM
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
3410–3415

I think you missed the word sure

fhahn updated this revision to Diff 320152.Jan 29 2021, 9:14 AM

Add missing sure and slightly re-word comment, thanks!

pcc added a subscriber: pcc.Jan 29 2021, 3:40 PM

I think there are more of these, search for Strtab.data() in that file.

arsenm accepted this revision.Mar 30 2021, 3:37 PM
This revision is now accepted and ready to land.Mar 30 2021, 3:37 PM
fhahn updated this revision to Diff 353632.Jun 22 2021, 6:47 AM

rebased, I'm planning on landing this soon.

In D95554#2531446, @pcc wrote:

I think there are more of these, search for Strtab.data() in that file.

Yes, those probably should also be audited. But I am not sure how to best get test cases for those. I'll take a look at some other oss-fuzz bugs.

This revision was landed with ongoing or failed builds.Jun 22 2021, 6:53 AM
This revision was automatically updated to reflect the committed changes.