[compiler-rt] r369826 - hwasan: Align n_namesz and n_descsz to 4 when reading notes.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 16:33:26 PDT 2019


Author: pcc
Date: Fri Aug 23 16:33:26 2019
New Revision: 369826

URL: http://llvm.org/viewvc/llvm-project?rev=369826&view=rev
Log:
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

Modified:
    compiler-rt/trunk/lib/hwasan/hwasan.cpp

Modified: compiler-rt/trunk/lib/hwasan/hwasan.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan.cpp?rev=369826&r1=369825&r2=369826&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan.cpp (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan.cpp Fri Aug 23 16:33:26 2019
@@ -276,10 +276,10 @@ static void InitGlobalsFromPhdrs(ElfW(Ad
     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;
       }
 




More information about the llvm-commits mailing list