summaryrefslogtreecommitdiff
path: root/lib/hwasan/hwasan.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-08-23 23:33:26 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2019-08-23 23:33:26 +0000
commit0ee972f080db3df06aed7672c3298a29b8cec082 (patch)
tree25d07f9983160fc8752b4f3339114619ed32fa6e /lib/hwasan/hwasan.cpp
parentcc53aec3cd3c8e8389175f44fab7a2ff862c536a (diff)
downloadcompiler-rt-0ee972f080db3df06aed7672c3298a29b8cec082.tar.gz
hwasan: Align n_namesz and n_descsz to 4 when reading notes.
There is no requirement for the producer of a note to include the note alignment in these fields. As a result we can end up missing the HWASAN note if one of the other notes in the binary has the alignment missing. Differential Revision: https://reviews.llvm.org/D66692 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@369826 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/hwasan/hwasan.cpp')
-rw-r--r--lib/hwasan/hwasan.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/hwasan/hwasan.cpp b/lib/hwasan/hwasan.cpp
index 999b51183..3a5b8791a 100644
--- a/lib/hwasan/hwasan.cpp
+++ b/lib/hwasan/hwasan.cpp
@@ -276,10 +276,10 @@ static void InitGlobalsFromPhdrs(ElfW(Addr) base, const ElfW(Phdr) * phdr,
while (note < nend) {
auto *nhdr = reinterpret_cast<const ElfW(Nhdr) *>(note);
const char *name = note + sizeof(ElfW(Nhdr));
- const char *desc = name + nhdr->n_namesz;
+ const char *desc = name + RoundUpTo(nhdr->n_namesz, 4);
if (nhdr->n_type != NT_LLVM_HWASAN_GLOBALS ||
internal_strcmp(name, "LLVM") != 0) {
- note = desc + nhdr->n_descsz;
+ note = desc + RoundUpTo(nhdr->n_descsz, 4);
continue;
}