[PATCH] D63191: [lld][ELF] Check length of subsection in .ARM.attributes
Eugene Leviant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 05:33:51 PDT 2019
evgeny777 updated this revision to Diff 204265.
evgeny777 added a comment.
Addressed
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63191/new/
https://reviews.llvm.org/D63191
Files:
lib/Support/ARMAttributeParser.cpp
tools/lld/test/ELF/bad-arm-attributes.s
tools/lld/test/ELF/bad-arm-attributes2.s
Index: tools/lld/test/ELF/bad-arm-attributes2.s
===================================================================
--- tools/lld/test/ELF/bad-arm-attributes2.s
+++ tools/lld/test/ELF/bad-arm-attributes2.s
@@ -0,0 +1,7 @@
+# RUN: llvm-mc -filetype=obj -triple=arm-unknown-linux %s -o %t
+# RUN: ld.lld %t -o %tout 2>&1 | FileCheck %s
+
+# CHECK: invalid subsection length 4294967295 at offset 1
+
+.section .ARM.attributes,"a",%0x70000003
+ .byte 0, 0xFF, 0xFF, 0xFF, 0xFF
Index: tools/lld/test/ELF/bad-arm-attributes.s
===================================================================
--- tools/lld/test/ELF/bad-arm-attributes.s
+++ tools/lld/test/ELF/bad-arm-attributes.s
@@ -0,0 +1,7 @@
+# RUN: llvm-mc -filetype=obj -triple=arm-unknown-linux %s -o %t
+# RUN: ld.lld %t -o %tout 2>&1 | FileCheck %s
+
+# CHECK: invalid subsection length 0 at offset 1
+
+.section .ARM.attributes,"a",%0x70000003
+ .quad 0
Index: lib/Support/ARMAttributeParser.cpp
===================================================================
--- lib/Support/ARMAttributeParser.cpp
+++ lib/Support/ARMAttributeParser.cpp
@@ -709,6 +709,12 @@
SW->indent();
}
+ if (SectionLength == 0 || (SectionLength + Offset) > Section.size()) {
+ errs() << "invalid subsection length " << SectionLength << " at offset "
+ << Offset << "\n";
+ return;
+ }
+
ParseSubsection(Section.data() + Offset, SectionLength);
Offset = Offset + SectionLength;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63191.204265.patch
Type: text/x-patch
Size: 1466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190612/165fe7b1/attachment.bin>
More information about the llvm-commits
mailing list