xref: /aosp_15_r20/external/google-breakpad/src/google_breakpad/processor/exploitability.h (revision 9712c20fc9bbfbac4935993a2ca0b3958c5adad2)
1 // Copyright 2010 Google LLC
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //     * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //     * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //     * Neither the name of Google LLC nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 // exploitability_engine.h: Generic exploitability engine.
30 //
31 // The Exploitability class is an abstract base class providing common
32 // generic methods that apply to exploitability engines for specific platforms.
33 // Specific implementations will extend this class by providing run
34 // methods to fill in the exploitability_ enumeration of the ProcessState
35 // for a crash.
36 //
37 // Author: Cris Neckar
38 
39 #ifndef GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_H_
40 #define GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_H_
41 
42 #include "google_breakpad/common/breakpad_types.h"
43 #include "google_breakpad/processor/minidump.h"
44 #include "google_breakpad/processor/process_state.h"
45 
46 namespace google_breakpad {
47 
48 class Exploitability {
49  public:
~Exploitability()50   virtual ~Exploitability() {}
51 
52   static Exploitability *ExploitabilityForPlatform(Minidump *dump,
53                                                    ProcessState *process_state);
54 
55   // The boolean parameter signals whether the exploitability engine is
56   // enabled to call out to objdump for disassembly. This is disabled by
57   // default. It is used to check the identity of the instruction that
58   // caused the program to crash. This should not be enabled if there are
59   // portability concerns.
60   static Exploitability *ExploitabilityForPlatform(Minidump *dump,
61                                                    ProcessState *process_state,
62                                                    bool enable_objdump);
63 
64   ExploitabilityRating CheckExploitability();
65   bool AddressIsAscii(uint64_t);
66 
67  protected:
68   Exploitability(Minidump *dump,
69                  ProcessState *process_state);
70 
71   Minidump *dump_;
72   ProcessState *process_state_;
73   SystemInfo *system_info_;
74 
75  private:
76   virtual ExploitabilityRating CheckPlatformExploitability() = 0;
77 };
78 
79 }  // namespace google_breakpad
80 
81 #endif  // GOOGLE_BREAKPAD_PROCESSOR_EXPLOITABILITY_H_
82