summaryrefslogtreecommitdiffstats
path: root/llvm/test/MC/Disassembler
diff options
context:
space:
mode:
authorAna Pazos <apazos@codeaurora.org>2018-09-07 18:23:19 +0000
committerAna Pazos <apazos@codeaurora.org>2018-09-07 18:23:19 +0000
commitb97d18945b821fe4f9b4c7059eb87e2a8734ab5d (patch)
treee9067228646b62a0224792bc0cbb7b55bf12fa54 /llvm/test/MC/Disassembler
parentf06ffeee21aabbf1ae94a06df4374f296ab81ddb (diff)
downloadbcm5719-llvm-b97d18945b821fe4f9b4c7059eb87e2a8734ab5d.tar.gz
bcm5719-llvm-b97d18945b821fe4f9b4c7059eb87e2a8734ab5d.zip
[RISCV] Fix AddressSanitizer heap-buffer-overflow in disassembling
Summary: RISCVDisassembler should check number of bytes available before reading them. Crash noticed when enabling -DLLVM_USE_SANITIZER=Address. This bug was uncovered by a LLVM MC Disassembler Protocol Buffer Fuzzer for the RISC-V assembly language. Reviewers: asb Reviewed By: asb Subscribers: rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, asb Differential Revision: https://reviews.llvm.org/D51708 llvm-svn: 341686
Diffstat (limited to 'llvm/test/MC/Disassembler')
-rw-r--r--llvm/test/MC/Disassembler/RISCV/fuzzer-invalid.txt8
-rw-r--r--llvm/test/MC/Disassembler/RISCV/lit.local.cfg3
2 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/MC/Disassembler/RISCV/fuzzer-invalid.txt b/llvm/test/MC/Disassembler/RISCV/fuzzer-invalid.txt
new file mode 100644
index 00000000000..d90172d3d34
--- /dev/null
+++ b/llvm/test/MC/Disassembler/RISCV/fuzzer-invalid.txt
@@ -0,0 +1,8 @@
+# RUN: not llvm-mc -disassemble -triple=riscv32 < %s 2>&1 | FileCheck %s
+# RUN: not llvm-mc -disassemble -triple=riscv64 < %s 2>&1 | FileCheck %s
+#
+# Test generated by a LLVM MC Disassembler Protocol Buffer Fuzzer
+# for the RISC-V assembly language.
+
+[0xf9 0x95 0xab 0x99]
+# CHECK: warning: invalid instruction encoding
diff --git a/llvm/test/MC/Disassembler/RISCV/lit.local.cfg b/llvm/test/MC/Disassembler/RISCV/lit.local.cfg
new file mode 100644
index 00000000000..d0b081e3e8b
--- /dev/null
+++ b/llvm/test/MC/Disassembler/RISCV/lit.local.cfg
@@ -0,0 +1,3 @@
+if not 'RISCV' in config.root.targets:
+ config.unsupported = True
+
OpenPOWER on IntegriCloud