llvm-project/llvm/lib/Target/BPF
Yonghong Song eec758825d [BPF] fix an asan issue when disassemble an illegal instruction
Commit 8e8f1bd75a ("[BPF] Return fail if disassembled insn registers
out of range") tried to fix a segfault when an illegal instruction
is decoded. A test case is added to emulate such an illegal instruction.

The llvm buildbot reported an asan issue with this test case.
  ERROR: AddressSanitizer: global-buffer-overflow on address ...
  decodeMemoryOpValue(llvm::MCInst&, unsigned int, ...)
  llvm::MCDisassembler::DecodeStatus llvm::decodeToMCInst<unsigned long>(...)
  llvm::MCDisassembler::DecodeStatus llvm::decodeInstruction<unsigned long>(...)
  in (anonymous namespace)::BPFDisassembler::getInstruction(...)
  ...

Basically, the fix in Commit 8e8f1bd75a is too later to prevent
the asan. The fix in this patch moved the register number check earlier
during decodeInstruction(). It will return fail for decodeInstruction()
if the register number is out of range.

Note that DecodeGPRRegisterClass() and DecodeGPR32RegisterClass()
already have register number checking, so here we only check
decodeMemoryOpValue().
2020-05-18 22:33:34 -07:00
..
AsmParser [AsmPrinter][MCStreamer] De-capitalize EmitInstruction and EmitCFI* 2020-02-13 22:08:55 -08:00
Disassembler [BPF] fix an asan issue when disassemble an illegal instruction 2020-05-18 22:33:34 -07:00
MCTargetDesc BPFMCTargetDesc.h - remove unused raw_ostream forward declaration. NFC. 2020-04-22 18:26:50 +01:00
TargetInfo CMake: Make most target symbols hidden by default 2020-01-14 19:46:52 -08:00
BPF.h [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
BPF.td
BPFAbstractMemberAccess.cpp [IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand(). 2020-04-27 22:17:03 -07:00
BPFAsmPrinter.cpp [AsmPrinter][MCStreamer] De-capitalize EmitInstruction and EmitCFI* 2020-02-13 22:08:55 -08:00
BPFCORE.h [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
BPFCallingConv.td
BPFFrameLowering.cpp
BPFFrameLowering.h [Alignment][NFC] Use Align for TargetFrameLowering/Subtarget 2019-10-17 07:49:39 +00:00
BPFISelDAGToDAG.cpp [IR] Split out target specific intrinsic enums into separate headers 2019-12-11 18:02:14 -08:00
BPFISelLowering.cpp [BPF] explicit warning of not supporting dynamic stack allocation 2020-02-12 20:43:06 -08:00
BPFISelLowering.h [BPF] implement isTruncateFree and isZExtFree in BPFTargetLowering 2020-02-11 09:59:19 -08:00
BPFInstrFormats.td
BPFInstrInfo.cpp [NFC] unsigned->Register in storeRegTo/loadRegFromStack 2020-02-03 14:22:16 +01:00
BPFInstrInfo.h [NFC] unsigned->Register in storeRegTo/loadRegFromStack 2020-02-03 14:22:16 +01:00
BPFInstrInfo.td [BPF] Prevent disassembly segfault for NOP insn 2020-05-18 17:40:18 -07:00
BPFMCInstLower.cpp
BPFMCInstLower.h [BPF] Remove unused forward declarations. NFC. 2020-04-22 15:07:18 +01:00
BPFMIChecking.cpp Prune a LegacyDivergenceAnalysis and MachineLoopInfo include each 2019-10-19 01:31:09 +00:00
BPFMIPeephole.cpp ProfileSummaryInfo.h - remove unnecessary includes. NFC 2020-04-10 16:25:48 +01:00
BPFMISimplifyPatchable.cpp [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
BPFPreserveDIType.cpp [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
BPFRegisterInfo.cpp
BPFRegisterInfo.h
BPFRegisterInfo.td
BPFSelectionDAGInfo.cpp
BPFSelectionDAGInfo.h
BPFSubtarget.cpp [BPF] turn on -mattr=+alu32 for cpu version v3 and later 2019-11-07 22:08:46 -08:00
BPFSubtarget.h
BPFTargetMachine.cpp [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
BPFTargetMachine.h
BTF.def
BTF.h [BPF] extend BTF_KIND_FUNC to cover global, static and extern funcs 2020-01-10 09:06:31 -08:00
BTFDebug.cpp [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
BTFDebug.h [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
CMakeLists.txt [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
LLVMBuild.txt