8

[BitcodeReader] fix a logic error in vector type element validation

 2 years ago
source link: https://reviews.llvm.org/D109655
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
[BitcodeReader] fix a logic error in vector type element validation
ClosedPublic
Authored by woodruffw on Sep 11 2021, 11:51 PM.
Details
Summary

The current code checks whether the vector's element type is a valid structure element type, rather than a valid vector element type. The two have separate implementations and but only accept very slightly different sets of types, which is probably why this wasn't caught before.

Diff Detail

Event Timeline

woodruffw requested review of this revision.Sep 11 2021, 11:51 PM
Comment Actions

Increase the context for the patch.

xgupta added a subscriber: xgupta.
Comment Actions

LGTM, Thanks.

This revision is now accepted and ready to land.Oct 8 2021, 8:31 PM
Comment Actions

Thanks! I don't have commit access so I'll need someone else to do the merge :-)

Comment Actions

just doing after a check-llvm.

Diff 378410

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Show First 20 LinesShow All 1,920 Lines▼ Show 20 Lines case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty] break; break; case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] or case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] or // [numelts, eltty, scalable] // [numelts, eltty, scalable] if (Record.size() < 2) if (Record.size() < 2) return error("Invalid record"); return error("Invalid record"); if (Record[0] == 0) if (Record[0] == 0) return error("Invalid vector length"); return error("Invalid vector length"); ResultTy = getTypeByID(Record[1]); ResultTy = getTypeByID(Record[1]); if (!ResultTy || !StructType::isValidElementType(ResultTy)) if (!ResultTy || !VectorType::isValidElementType(ResultTy)) return error("Invalid type"); return error("Invalid type"); bool Scalable = Record.size() > 2 ? Record[2] : false; bool Scalable = Record.size() > 2 ? Record[2] : false; ResultTy = VectorType::get(ResultTy, Record[0], Scalable); ResultTy = VectorType::get(ResultTy, Record[0], Scalable); break; break; } }

if (NumRecords >= TypeList.size()) if (NumRecords >= TypeList.size()) return error("Invalid TYPE table"); return error("Invalid TYPE table"); ▲ Show 20 LinesShow All 5,149 LinesShow Last 20 Lines


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK