[all-commits] [llvm/llvm-project] eec758: [BPF] fix an asan issue when disassemble an illega...
yonghong-song via All-commits
all-commits at lists.llvm.org
Mon May 18 22:35:41 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: eec758825d2a85f229bd4914a322eab8e7d57b23
https://github.com/llvm/llvm-project/commit/eec758825d2a85f229bd4914a322eab8e7d57b23
Author: Yonghong Song <yhs at fb.com>
Date: 2020-05-18 (Mon, 18 May 2020)
Changed paths:
M llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
Log Message:
-----------
[BPF] fix an asan issue when disassemble an illegal instruction
Commit 8e8f1bd75a9a ("[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 8e8f1bd75a9a 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().
More information about the All-commits
mailing list