Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 Google Inc. | 1 // Copyright (c) 2013 Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 | 29 |
| 30 // exploitability_linux.cc: Linux specific exploitability engine. | 30 // exploitability_linux.cc: Linux specific exploitability engine. |
| 31 // | 31 // |
| 32 // Provides a guess at the exploitability of the crash for the Linux | 32 // Provides a guess at the exploitability of the crash for the Linux |
| 33 // platform given a minidump and process_state. | 33 // platform given a minidump and process_state. |
| 34 // | 34 // |
| 35 // Author: Matthew Riley | 35 // Author: Matthew Riley |
| 36 | 36 |
| 37 #include "processor/exploitability_linux.h" | 37 #include "processor/exploitability_linux.h" |
| 38 | 38 |
| 39 #include "google_breakpad/common/minidump_exception_linux.h" | |
| 39 #include "google_breakpad/processor/process_state.h" | 40 #include "google_breakpad/processor/process_state.h" |
| 40 #include "google_breakpad/processor/call_stack.h" | 41 #include "google_breakpad/processor/call_stack.h" |
| 41 #include "google_breakpad/processor/stack_frame.h" | 42 #include "google_breakpad/processor/stack_frame.h" |
| 42 #include "processor/logging.h" | 43 #include "processor/logging.h" |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| 46 // This function in libc is called if the program was compiled with | 47 // This function in libc is called if the program was compiled with |
| 47 // -fstack-protector and a function's stack canary changes. | 48 // -fstack-protector and a function's stack canary changes. |
| 48 const char kStackCheckFailureFunction[] = "__stack_chk_fail"; | 49 const char kStackCheckFailureFunction[] = "__stack_chk_fail"; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 MinidumpException *exception = dump_->GetException(); | 90 MinidumpException *exception = dump_->GetException(); |
| 90 if (exception == NULL) { | 91 if (exception == NULL) { |
| 91 BPLOG(INFO) << "No exception record."; | 92 BPLOG(INFO) << "No exception record."; |
| 92 return EXPLOITABILITY_ERR_PROCESSING; | 93 return EXPLOITABILITY_ERR_PROCESSING; |
| 93 } | 94 } |
| 94 const MinidumpContext *context = exception->GetContext(); | 95 const MinidumpContext *context = exception->GetContext(); |
| 95 if (context == NULL) { | 96 if (context == NULL) { |
| 96 BPLOG(INFO) << "No exception context."; | 97 BPLOG(INFO) << "No exception context."; |
| 97 return EXPLOITABILITY_ERR_PROCESSING; | 98 return EXPLOITABILITY_ERR_PROCESSING; |
| 98 } | 99 } |
| 100 const MDRawExceptionStream *raw_exception_stream = exception->exception(); | |
|
ivanpe
2015/06/26 18:21:36
Please, move this code new below the InstructionPo
liuandrew
2015/06/29 16:13:56
Done.
| |
| 101 if (raw_exception_stream == NULL) { | |
| 102 BPLOG(INFO) << "No raw exception stream."; | |
| 103 return EXPLOITABILITY_ERR_PROCESSING; | |
| 104 } | |
| 99 | 105 |
| 100 // Getting instruction pointer based off architecture. | 106 // Getting instruction pointer based off architecture. |
| 101 uint32_t architecture = context->GetContextCPU(); | 107 uint32_t architecture = context->GetContextCPU(); |
| 102 switch (architecture) { | 108 switch (architecture) { |
| 103 case MD_CONTEXT_X86: | 109 case MD_CONTEXT_X86: |
| 104 instruction_ptr = context->GetContextX86()->eip; | 110 instruction_ptr = context->GetContextX86()->eip; |
| 105 break; | 111 break; |
| 106 case MD_CONTEXT_AMD64: | 112 case MD_CONTEXT_AMD64: |
| 107 instruction_ptr = context->GetContextAMD64()->rip; | 113 instruction_ptr = context->GetContextAMD64()->rip; |
| 108 break; | 114 break; |
| 109 default: | 115 default: |
| 110 // TODO(liuandrew): Add support ARM and arm64 architectures. | 116 // TODO(liuandrew): Add support ARM and arm64 architectures. |
| 111 BPLOG(INFO) << "Unsupported architecture."; | 117 BPLOG(INFO) << "Unsupported architecture."; |
| 112 return EXPLOITABILITY_ERR_PROCESSING; | 118 return EXPLOITABILITY_ERR_PROCESSING; |
| 113 } | 119 } |
| 114 | 120 |
| 115 if (!this->InstructionPointerInCode(instruction_ptr)) { | 121 if (!this->InstructionPointerInCode(instruction_ptr)) { |
| 116 return EXPLOITABILITY_HIGH; | 122 return EXPLOITABILITY_HIGH; |
| 117 } | 123 } |
| 118 | 124 |
| 125 // check for benign exceptions | |
|
ivanpe
2015/06/26 18:21:36
Capitalize, punctuation, etc.
liuandrew
2015/06/29 16:13:56
Done.
| |
| 126 if (this->BenignCrashTrigger(raw_exception_stream)) { | |
| 127 return EXPLOITABILITY_NONE; | |
| 128 } | |
| 129 | |
| 130 // TODO(liuandrew) change default exploitability rating | |
|
ivanpe
2015/06/26 18:21:36
Should be // TODO(author): some text
liuandrew
2015/06/29 16:13:55
Done.
| |
| 119 return EXPLOITABILITY_NONE; | 131 return EXPLOITABILITY_NONE; |
| 120 } | 132 } |
| 121 | 133 |
| 122 bool ExploitabilityLinux::InstructionPointerInCode(uint64_t instruction_ptr) { | 134 bool ExploitabilityLinux::InstructionPointerInCode(uint64_t instruction_ptr) { |
| 123 // Here we get memory mapping. Most minidumps will not contain a memory | 135 // Here we get memory mapping. Most minidumps will not contain a memory |
| 124 // mapping, so we will commonly resort to checking modules. | 136 // mapping, so we will commonly resort to checking modules. |
| 125 MinidumpMemoryInfoList *mem_info_list = dump_->GetMemoryInfoList(); | 137 MinidumpMemoryInfoList *mem_info_list = dump_->GetMemoryInfoList(); |
| 126 const MinidumpMemoryInfo *mem_info = | 138 const MinidumpMemoryInfo *mem_info = |
| 127 mem_info_list ? | 139 mem_info_list ? |
| 128 mem_info_list->GetMemoryInfoForAddress(instruction_ptr) : NULL; | 140 mem_info_list->GetMemoryInfoForAddress(instruction_ptr) : NULL; |
| 129 | 141 |
| 130 // Checking if the memory mapping at the instruction pointer is executable. | 142 // Checking if the memory mapping at the instruction pointer is executable. |
| 131 // If there is no memory mapping, we will use the modules as reference. | 143 // If there is no memory mapping, we will use the modules as reference. |
| 132 if (mem_info != NULL) { | 144 if (mem_info != NULL) { |
| 133 return mem_info->IsExecutable(); | 145 return mem_info->IsExecutable(); |
| 134 } | 146 } |
| 135 | 147 |
| 136 // If the memory mapping retrieval fails, we will check the modules | 148 // If the memory mapping retrieval fails, we will check the modules |
| 137 // to see if the instruction pointer is inside a module. | 149 // to see if the instruction pointer is inside a module. |
| 138 // TODO(liuandrew): Check if the instruction pointer lies in an executable | 150 // TODO(liuandrew): Check if the instruction pointer lies in an executable |
| 139 // region within the module. | 151 // region within the module. |
| 140 MinidumpModuleList *minidump_module_list = dump_->GetModuleList(); | 152 MinidumpModuleList *minidump_module_list = dump_->GetModuleList(); |
| 141 return !minidump_module_list || | 153 return !minidump_module_list || |
| 142 minidump_module_list->GetModuleForAddress(instruction_ptr); | 154 minidump_module_list->GetModuleForAddress(instruction_ptr); |
| 143 } | 155 } |
| 144 | 156 |
| 157 bool ExploitabilityLinux::BenignCrashTrigger(const MDRawExceptionStream | |
| 158 *raw_exception_stream) { | |
| 159 // here we check the cause of crash | |
|
ivanpe
2015/06/26 18:21:36
Capitalize, punctuation, etc.
liuandrew
2015/06/29 16:13:56
Done.
| |
| 160 // if the exception of the crash is a benign exception, | |
| 161 // it is probably not exploitable | |
| 162 switch (raw_exception_stream->exception_record.exception_code) { | |
| 163 case MD_EXCEPTION_CODE_LIN_SIGHUP: | |
|
ivanpe
2015/06/26 18:21:36
What is the rationale for considering these benign
| |
| 164 case MD_EXCEPTION_CODE_LIN_SIGABRT: | |
| 165 case MD_EXCEPTION_CODE_LIN_SIGFPE: | |
| 166 case MD_EXCEPTION_CODE_LIN_SIGUSR1: | |
| 167 case MD_EXCEPTION_CODE_LIN_SIGUSR2: | |
| 168 case MD_EXCEPTION_CODE_LIN_SIGPIPE: | |
| 169 case MD_EXCEPTION_CODE_LIN_SIGALRM: | |
| 170 case MD_EXCEPTION_CODE_LIN_SIGTERM: | |
| 171 case MD_EXCEPTION_CODE_LIN_SIGCONT: | |
| 172 case MD_EXCEPTION_CODE_LIN_SIGSTOP: | |
| 173 case MD_EXCEPTION_CODE_LIN_SIGTSTP: | |
| 174 case MD_EXCEPTION_CODE_LIN_SIGTTIN: | |
| 175 case MD_EXCEPTION_CODE_LIN_SIGTTOU: | |
| 176 case MD_EXCEPTION_CODE_LIN_SIGURG: | |
| 177 case MD_EXCEPTION_CODE_LIN_SIGXCPU: | |
| 178 case MD_EXCEPTION_CODE_LIN_SIGXFSZ: | |
| 179 case MD_EXCEPTION_CODE_LIN_SIGVTALRM: | |
| 180 case MD_EXCEPTION_CODE_LIN_SIGPROF: | |
| 181 case MD_EXCEPTION_CODE_LIN_SIGWINCH: | |
| 182 case MD_EXCEPTION_CODE_LIN_SIGIO: | |
| 183 case MD_EXCEPTION_CODE_LIN_SIGPWR: | |
| 184 case MD_EXCEPTION_CODE_LIN_DUMP_REQUESTED: | |
| 185 return true; | |
| 186 break; | |
| 187 default: | |
| 188 return false; | |
| 189 break; | |
| 190 } | |
| 191 } | |
| 192 | |
| 145 } // namespace google_breakpad | 193 } // namespace google_breakpad |
| OLD | NEW |