[compiler-rt] 4ecfa0a - [sanitizers] Fix integer underflow when parsing ELF.
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 4 21:47:10 PST 2022
Author: Florian Mayer
Date: 2022-01-04T21:47:02-08:00
New Revision: 4ecfa0a0c5fba0acad8c902d49243c60b6ccd34e
URL: https://github.com/llvm/llvm-project/commit/4ecfa0a0c5fba0acad8c902d49243c60b6ccd34e
DIFF: https://github.com/llvm/llvm-project/commit/4ecfa0a0c5fba0acad8c902d49243c60b6ccd34e.diff
LOG: [sanitizers] Fix integer underflow when parsing ELF.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D116639
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index 3c15c35cf4887..06654ea5ea100 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -605,7 +605,7 @@ static int AddModuleSegments(const char *module_name, dl_phdr_info *info,
writable);
} else if (phdr->p_type == PT_NOTE) {
uptr off = 0;
- while (off < phdr->p_memsz - sizeof(ElfW(Nhdr))) {
+ while (off + sizeof(ElfW(Nhdr)) < phdr->p_memsz) {
auto *nhdr = reinterpret_cast<const ElfW(Nhdr) *>(info->dlpi_addr +
phdr->p_vaddr + off);
constexpr auto kGnuNamesz = 4; // "GNU" with NUL-byte.
More information about the llvm-commits
mailing list