Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rop.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, 2013, 2014 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __ROP_H__
20 #define __ROP_H__
21 
22 #include <glib.h>
23 #include "common.h"
24 #include "target_api.h"
25 #include "probe_api.h"
26 
27 struct rop_gadget {
30  char *meta;
31 };
32 
34  uint8_t ingadget:1,
35  isviolation:1,
36  isfpviolation:1,
39  uint16_t violations;
40  uint16_t fpviolations;
41  uint16_t jmpfpviolations;
42  uint16_t jccfpviolations;
43  uint16_t total;
45 };
46 
47 typedef enum {
48  /*
49  * Starts at start of real instr, and ends at end of real instr.
50  * This means the entry/exit probes are always in place, never get
51  * removed, and are always hit whether the gadget is validly used or
52  * not.
53  */
55  /*
56  * Starts in middle of real instr, and ends at end of real instr.
57  * This means that we need a guard probe on the real instruction
58  * that includes the gadget's first instruction, so that we can
59  * remove the entry probe until we have executed the real
60  * instruction. Once we have done so, we put both the guard probe
61  * and entry probe back in.
62  */
64  /*
65  * Starts in the middle of a real instr, and ends in the middle of a
66  * real instr.
67  *
68  * This means that we need a guard probe on the real instr
69  * containing the gadget's first instr, so that we can remove the
70  * entry point. Initially, the gadget exit probe will NOT be
71  * inserted. If the gadget entry probe is inserted, we'll insert
72  * the gadget exit probe; otherwise we won't!
73  */
75 } rop_gadget_t;
76 
81 
82  struct rop_gadget *gadget;
83 
84  /*
85  * If the rop gadget is not aligned with the rest of the text, this
86  * is the probe that guards the first instruction before the
87  * gadget.
88  */
89  struct probe *cont_probe;
91  /* The probe on the gadget's first instruction. */
92  struct probe *entry_probe;
93  /* The probe on the gadget's RET instruction. */
94  struct probe *ret_probe;
95 
96  /* The high-level probe. */
97  struct probe *rop_probe;
98 
99  /* Status of the high-level probe. */
101 };
102 
103 GHashTable *rop_load_gadget_file(char *filename);
104 GHashTable *rop_load_gadget_stream(FILE *stream);
106  struct rop_gadget *rg,
109  void *handler_data);
110 
111 #endif
GHashTable * rop_load_gadget_stream(FILE *stream)
Definition: rop_util.c:36
ADDR current_ret_addr
Definition: rop.h:44
result_t pre_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
Definition: spf.c:903
struct probe * cont_probe
Definition: rop.h:89
int32_t tid_t
Definition: common.h:36
Definition: rop.h:27
struct probe * ret_probe
Definition: rop.h:94
uint16_t fpviolations
Definition: rop.h:40
uint8_t isjmpfpviolation
Definition: rop.h:34
uint8_t isviolation
Definition: rop.h:34
rop_gadget_t type
Definition: rop.h:78
ADDR cont_start
Definition: rop.h:79
struct probe * entry_probe
Definition: rop.h:92
struct probe * rop_probe
Definition: rop.h:97
char * meta
Definition: rop.h:30
result_t(* probe_handler_t)(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
Definition: probe_api.h:70
tid_t tid
Definition: probe.h:344
uint16_t total
Definition: rop.h:43
uint16_t jmpfpviolations
Definition: rop.h:41
ADDR start
Definition: rop.h:28
uint8_t ingadget
Definition: rop.h:34
struct rop_checkret_status status
Definition: rop.h:100
ADDR cont_end
Definition: rop.h:80
Definition: probe.h:308
uint8_t isfpviolation
Definition: rop.h:34
ADDR end
Definition: rop.h:29
GHashTable * rop_load_gadget_file(char *filename)
Definition: rop_util.c:89
result_t post_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
Definition: spf.c:908
rop_gadget_t
Definition: rop.h:47
uint32_t ADDR
Definition: common.h:64
uint8_t isjccfpviolation
Definition: rop.h:34
struct probe * probe_rop_checkret(struct target *target, tid_t tid, struct rop_gadget *rg, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
Definition: rop_util.c:492
uint16_t violations
Definition: rop.h:39
ADDR cont_instr_start
Definition: rop.h:90
uint16_t jccfpviolations
Definition: rop.h:42
struct rop_gadget * gadget
Definition: rop.h:82