diff options
Diffstat (limited to 'src/client/linux/minidump_writer')
-rw-r--r-- | src/client/linux/minidump_writer/linux_dumper.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc index be199f7b..c693e907 100644 --- a/src/client/linux/minidump_writer/linux_dumper.cc +++ b/src/client/linux/minidump_writer/linux_dumper.cc @@ -59,6 +59,8 @@ #include "common/linux/linux_libc_support.h" #include "common/linux/linux_syscall_support.h" +static const char kMappedFileUnsafePrefix[] = "/dev/"; + // Suspend a thread by attaching to it. static bool SuspendThread(pid_t pid) { // This may fail if the thread has just died or debugged. @@ -81,6 +83,17 @@ static bool ResumeThread(pid_t pid) { return sys_ptrace(PTRACE_DETACH, pid, NULL, NULL) >= 0; } +inline static bool IsMappedFileOpenUnsafe( + const google_breakpad::MappingInfo* mapping) { + // It is unsafe to attempt to open a mapped file that lives under /dev, + // because the semantics of the open may be driver-specific so we'd risk + // hanging the crash dumper. And a file in /dev/ almost certainly has no + // ELF file identifier anyways. + return my_strncmp(mapping->name, + kMappedFileUnsafePrefix, + sizeof(kMappedFileUnsafePrefix) - 1) == 0; +} + namespace google_breakpad { LinuxDumper::LinuxDumper(int pid) @@ -166,7 +179,11 @@ LinuxDumper::ElfFileIdentifierForMapping(unsigned int mapping_id, uint8_t identifier[sizeof(MDGUID)]) { assert(mapping_id < mappings_.size()); + my_memset(identifier, 0, sizeof(MDGUID)); const MappingInfo* mapping = mappings_[mapping_id]; + if (IsMappedFileOpenUnsafe(mapping)) { + return false; + } int fd = sys_open(mapping->name, O_RDONLY, 0); if (fd < 0) return false; |