• Home
  • Raw
  • Download

Lines Matching full:verifier

18 #include "verifier.h"
23 namespace panda::verifier { namespace
25 Verifier::Verifier(const std::string &filename) in Verifier() function in panda::verifier::Verifier
31 bool Verifier::Verify() in Verify()
48 bool Verifier::CollectIdInfos() in CollectIdInfos()
51 LOG(ERROR, VERIFIER) << "Failed to verify empty abc file!"; in CollectIdInfos()
58 return CheckConstantPool(verifier::ActionType::COLLECTINFOS); in CollectIdInfos()
61 bool Verifier::VerifyChecksum() in VerifyChecksum()
64 LOG(ERROR, VERIFIER) << "Failed to verify empty abc file!"; in VerifyChecksum()
73 bool Verifier::VerifyConstantPool() in VerifyConstantPool()
76 LOG(ERROR, VERIFIER) << "Failed to verify empty abc file!"; in VerifyConstantPool()
84 if (!CheckConstantPool(verifier::ActionType::CHECKCONSTPOOLCONTENT)) { in VerifyConstantPool()
95 bool Verifier::VerifyRegisterIndex() in VerifyRegisterIndex()
98 LOG(ERROR, VERIFIER) << "Failed to verify empty abc file!"; in VerifyRegisterIndex()
113 LOG(ERROR, VERIFIER) << "Integer overflow detected during register index calculation!"; in VerifyRegisterIndex()
117 LOG(ERROR, VERIFIER) << "Register index exceeds the maximum allowable value (0xffff)!"; in VerifyRegisterIndex()
138 bool Verifier::VerifyConstantPoolIndex() in VerifyConstantPoolIndex()
141 LOG(ERROR, VERIFIER) << "Failed to verify empty abc file!"; in VerifyConstantPoolIndex()
152 bool Verifier::VerifyConstantPoolContent() in VerifyConstantPoolContent()
155 LOG(ERROR, VERIFIER) << "Failed to verify empty abc file!"; in VerifyConstantPoolContent()
159 if (!CheckConstantPool(verifier::ActionType::CHECKCONSTPOOLCONTENT)) { in VerifyConstantPoolContent()
170 void Verifier::GetConstantPoolIds() in GetConstantPoolIds()
184 void Verifier::GetLiteralIds() in GetLiteralIds()
202 void Verifier::PushToLiteralIds(T &ids) in PushToLiteralIds()
209 bool Verifier::CheckConstantPoolActions(const verifier::ActionType type, panda_file::File::EntityId… in CheckConstantPoolActions()
212 case verifier::ActionType::CHECKCONSTPOOLCONTENT: { in CheckConstantPoolActions()
215 case verifier::ActionType::COLLECTINFOS: { in CheckConstantPoolActions()
225 bool Verifier::CollectIdInInstructions(const panda_file::File::EntityId &method_id) in CollectIdInInstructions()
240 LOG(ERROR, VERIFIER) << "Fail to verify primary opcode!"; in CollectIdInInstructions()
266 void Verifier::CollectModuleLiteralId(const panda_file::File::EntityId &field_id) in CollectModuleLiteralId()
275 bool Verifier::CheckConstantPool(const verifier::ActionType type) in CheckConstantPool()
281 LOG(ERROR, VERIFIER) << "Binary file corrupted. out of bounds (0x" << std::hex in CheckConstantPool()
295 if (type == verifier::ActionType::COLLECTINFOS) { in CheckConstantPool()
306 size_t Verifier::GetVRegCount(const BytecodeInstruction &bc_ins) in GetVRegCount()
316 bool Verifier::IsRangeInstAndHasInvalidRegIdx(const BytecodeInstruction &bc_ins, in IsRangeInstAndHasInvalidRegIdx()
328 LOG(ERROR, VERIFIER) << "Integer overflow detected during register index calculation!"; in IsRangeInstAndHasInvalidRegIdx()
340 bool Verifier::IsRegIdxOutOfBounds(uint64_t reg_idx, uint64_t valid_regs_num) in IsRegIdxOutOfBounds()
343 LOG(ERROR, VERIFIER) << "Register index out of bounds: 0x" << std::hex in IsRegIdxOutOfBounds()
350 bool Verifier::CheckVRegIdx(const BytecodeInstruction &bc_ins, const size_t count, uint64_t valid_r… in CheckVRegIdx()
359 LOG(ERROR, VERIFIER) << "Register index out of bounds: 0x" << std::hex in CheckVRegIdx()
367 bool Verifier::VerifyMethodId(const uint32_t &method_id) const in VerifyMethodId()
373 … LOG(ERROR, VERIFIER) << "Fail to verify method id. method_id(0x" << std::hex << method_id << ")!"; in VerifyMethodId()
379 bool Verifier::VerifyLiteralId(const uint32_t &literal_id) const in VerifyLiteralId()
385 …LOG(ERROR, VERIFIER) << "Fail to verify literal id. literal_id(0x" << std::hex << literal_id << ")… in VerifyLiteralId()
391 bool Verifier::VerifyStringId(const uint32_t &string_id) const in VerifyStringId()
397 … LOG(ERROR, VERIFIER) << "Fail to verify string id. string_id(0x" << std::hex << string_id << ")!"; in VerifyStringId()
403 std::optional<int64_t> Verifier::GetFirstImmFromInstruction(const BytecodeInstruction &bc_ins) in GetFirstImmFromInstruction()
415 std::optional<uint64_t> Verifier::GetSlotNumberFromAnnotation(panda_file::MethodDataAccessor &metho… in GetSlotNumberFromAnnotation()
435 bool Verifier::VerifyMethodIdInLiteralArray(const uint32_t &id) in VerifyMethodIdInLiteralArray()
440 LOG(ERROR, VERIFIER) << "Invalid method id(0x" << id << ") in literal array"; in VerifyMethodIdInLiteralArray()
446 bool Verifier::VerifyStringIdInLiteralArray(const uint32_t &id) in VerifyStringIdInLiteralArray()
450 LOG(ERROR, VERIFIER) << "Invalid string_id. string_id(0x" << std::hex << id << ")!"; in VerifyStringIdInLiteralArray()
457 LOG(ERROR, VERIFIER) << "Invalid string value(0x" << id << ") in literal array"; in VerifyStringIdInLiteralArray()
463 bool Verifier::VerifyLiteralIdInLiteralArray(const uint32_t &id) in VerifyLiteralIdInLiteralArray()
467 LOG(ERROR, VERIFIER) << "Invalid literal id(0x" << id << ") in literal array"; in VerifyLiteralIdInLiteralArray()
473 bool Verifier::VerifySingleLiteralArray(const panda_file::File::EntityId &literal_id) in VerifySingleLiteralArray()
506 … LOG(ERROR, VERIFIER) << "Fail to verify double value " << value << " in literal array"; in VerifySingleLiteralArray()
547 LOG(ERROR, VERIFIER) << "Invalid literal tag"; in VerifySingleLiteralArray()
555 bool Verifier::IsModuleLiteralId(const panda_file::File::EntityId &id) const in IsModuleLiteralId()
560 bool Verifier::VerifyLiteralArrays() in VerifyLiteralArrays()
571 bool Verifier::PrecomputeInstructionIndices(const BytecodeInstruction &bc_ins_start, in PrecomputeInstructionIndices()
582 LOG(ERROR, VERIFIER) << "Fail to verify primary opcode!"; in PrecomputeInstructionIndices()
592 bool Verifier::IsMethodBytecodeInstruction(const BytecodeInstruction &bc_ins_cur) in IsMethodBytecodeInstruction()
600 bool Verifier::VerifyJumpInstruction(const BytecodeInstruction &bc_ins, const BytecodeInstruction &… in VerifyJumpInstruction()
612 LOG(ERROR, VERIFIER) << "Fail to get immediate data!"; in VerifyJumpInstruction()
616 LOG(ERROR, VERIFIER) << "Jump forward out of boundary"; in VerifyJumpInstruction()
620 LOG(ERROR, VERIFIER) << "Jump backward out of boundary"; in VerifyJumpInstruction()
626 LOG(ERROR, VERIFIER) << "Fail to verify target jump primary opcode!"; in VerifyJumpInstruction()
630 … LOG(ERROR, VERIFIER) << "> error encountered at " << code_id << " (0x" << std::hex << code_id in VerifyJumpInstruction()
641 bool Verifier::GetIcSlotFromInstruction(const BytecodeInstruction &bc_ins, uint32_t &first_slot_ind… in GetIcSlotFromInstruction()
648 LOG(ERROR, VERIFIER) << "Fail to get first immediate data!"; in GetIcSlotFromInstruction()
657 LOG(ERROR, VERIFIER) << "Fail to get first immediate data!"; in GetIcSlotFromInstruction()
668 bool Verifier::VerifyCatchBlocks(panda_file::CodeDataAccessor::TryBlock &try_block, const BytecodeI… in VerifyCatchBlocks()
686 … LOG(ERROR, VERIFIER) << "> Invalid catch block begin offset range! address is: 0x" << std::hex in VerifyCatchBlocks()
692 … LOG(ERROR, VERIFIER) << "> Invalid catch block begin offset validity! address is: 0x" << std::hex in VerifyCatchBlocks()
698 … LOG(ERROR, VERIFIER) << "> Invalid catch block end offset range! address is: 0x" << std::hex in VerifyCatchBlocks()
704 … LOG(ERROR, VERIFIER) << "> Invalid catch block end offset validity! address is: 0x" << std::hex in VerifyCatchBlocks()
716 bool Verifier::VerifyTryBlocks(panda_file::CodeDataAccessor &code_accessor, const BytecodeInstructi… in VerifyTryBlocks()
731 … LOG(ERROR, VERIFIER) << "> Invalid try block begin offset range! address is: 0x" << std::hex in VerifyTryBlocks()
737 … LOG(ERROR, VERIFIER) << "> Invalid try block begin offset validity! address is: 0x" << std::hex in VerifyTryBlocks()
743 … LOG(ERROR, VERIFIER) << "> Invalid try block end offset range! address is: 0x" << std::hex in VerifyTryBlocks()
749 … LOG(ERROR, VERIFIER) << "> Invalid try block end offset validity! address is: 0x" << std::hex in VerifyTryBlocks()
755 LOG(ERROR, VERIFIER) << "Catch block validation failed!"; in VerifyTryBlocks()
767 bool Verifier::VerifySlotNumber(panda_file::MethodDataAccessor &method_accessor, const uint32_t &sl… in VerifySlotNumber()
772 LOG(INFO, VERIFIER) << "There is no slot number information in annotaion."; in VerifySlotNumber()
780 LOG(ERROR, VERIFIER) << "Slot number has been falsified in method 0x" << method_id; in VerifySlotNumber()
784 bool Verifier::VerifyMethodRegisterIndex(panda_file::CodeDataAccessor &code_accessor, in VerifyMethodRegisterIndex()
791 LOG(ERROR, VERIFIER) << "Integer overflow detected during register index calculation!"; in VerifyMethodRegisterIndex()
795 LOG(ERROR, VERIFIER) << "Register index exceeds the maximum allowable value (0xffff)!"; in VerifyMethodRegisterIndex()
801 bool Verifier::VerifyMethodInstructions(const MethodInfos &infos) in VerifyMethodInstructions()
814 LOG(ERROR, VERIFIER) << "> error encountered at " << code_id in VerifyMethodInstructions()
823 LOG(ERROR, VERIFIER) << "> error encountered at " << code_id in VerifyMethodInstructions()
837 LOG(ERROR, VERIFIER) << "Invalid target position of jump instruction"; in VerifyMethodInstructions()
842 LOG(ERROR, VERIFIER) << "Fail to get first slot index!"; in VerifyMethodInstructions()
850 bool Verifier::CheckConstantPoolMethodContent(const panda_file::File::EntityId &method_id) in CheckConstantPoolMethodContent()
854 LOG(ERROR, VERIFIER) << "Fail to get code id!"; in CheckConstantPoolMethodContent()
870 LOG(ERROR, VERIFIER) << "Fail to verify code size!"; in CheckConstantPoolMethodContent()
874 LOG(ERROR, VERIFIER) << "Fail to verify method register index!"; in CheckConstantPoolMethodContent()
878 LOG(ERROR, VERIFIER) << "Fail to precompute instruction indices!"; in CheckConstantPoolMethodContent()
882 LOG(ERROR, VERIFIER) << "Fail to verify method first bytecode instruction!"; in CheckConstantPoolMethodContent()
885 LOG(ERROR, VERIFIER) << "Fail to verify try blocks or catch blocks!"; in CheckConstantPoolMethodContent()
889 LOG(ERROR, VERIFIER) << "Fail to verify method instructions!"; in CheckConstantPoolMethodContent()
901 bool Verifier::CheckConstantPoolIndex() const in CheckConstantPoolIndex()
924 std::optional<uint64_t> Verifier::SafeAdd(uint64_t a, uint64_t b) const in SafeAdd()
931 } // namespace panda::verifier