Skip to content

Commit

Permalink
hwasan: Align n_namesz and n_descsz to 4 when reading notes.
Browse files Browse the repository at this point in the history
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

llvm-svn: 369826
  • Loading branch information
pcc committed Aug 23, 2019
1 parent 27d69b2 commit b2e7b85
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler-rt/lib/hwasan/hwasan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b2e7b85

Please sign in to comment.