unsigned int code;
} struct_ioctlent;
-struct fault_opts {
+struct inject_opts {
uint16_t first;
uint16_t step;
uint16_t signo;
int rval;
};
-#define MAX_ERRNO_VALUE 4095
-#define FAULT_OPTS_RVAL_DEFAULT (-(MAX_ERRNO_VALUE + 1))
-#define FAULT_OPTS_RVAL_DISABLE (FAULT_OPTS_RVAL_DEFAULT - 1)
+#define MAX_ERRNO_VALUE 4095
+#define INJECT_OPTS_RVAL_DEFAULT (-(MAX_ERRNO_VALUE + 1))
+#define INJECT_OPTS_RVAL_DISABLE (INJECT_OPTS_RVAL_DEFAULT - 1)
/* Trace Control Block */
struct tcb {
void (*_free_priv_data)(void *); /* Callback for freeing priv_data */
const struct_sysent *s_ent; /* sysent[scno] or dummy struct for bad scno */
const struct_sysent *s_prev_ent; /* for "resuming interrupted SYSCALL" msg */
- struct fault_opts *fault_vec[SUPPORTED_PERSONALITIES];
+ struct inject_opts *inject_vec[SUPPORTED_PERSONALITIES];
struct timeval stime; /* System time usage as of last process wait */
struct timeval dtime; /* Delta for system time usage */
struct timeval etime; /* Syscall entry time */
#define TCB_ATTACHED 0x08 /* We attached to it already */
#define TCB_REPRINT 0x10 /* We should reprint this syscall on exit */
#define TCB_FILTERED 0x20 /* This system call has been filtered out */
-#define TCB_FAULT_INJ 0x40 /* A syscall fault has been injected */
+#define TCB_TAMPERED 0x40 /* A syscall has been tampered with */
#define TCB_HIDE_LOG 0x80 /* We should hide everything (until execve) */
#define TCB_SKIP_DETACH_ON_FIRST_EXEC 0x100 /* -b execve should skip detach on first execve */
#define QUAL_ABBREV 0x002 /* abbreviate the structures of this syscall */
#define QUAL_VERBOSE 0x004 /* decode the structures of this syscall */
#define QUAL_RAW 0x008 /* print all args in hex for this syscall */
-#define QUAL_FAULT 0x010 /* fail this system call on purpose */
+#define QUAL_INJECT 0x010 /* tamper with this system call on purpose */
#define QUAL_SIGNAL 0x100 /* report events with this signal */
#define QUAL_READ 0x200 /* dump data read from this file descriptor */
#define QUAL_WRITE 0x400 /* dump data written to this file descriptor */
extern const unsigned int nsyscall_vec[SUPPORTED_PERSONALITIES];
extern const struct_sysent *const sysent_vec[SUPPORTED_PERSONALITIES];
-extern struct fault_opts *fault_vec[SUPPORTED_PERSONALITIES];
+extern struct inject_opts *inject_vec[SUPPORTED_PERSONALITIES];
#ifdef IN_MPERS_BOOTSTRAP
/* Transform multi-line MPERS_PRINTER_DECL statements to one-liners. */
struct number_set signal_set;
static struct number_set abbrev_set[SUPPORTED_PERSONALITIES];
-static struct number_set fault_set[SUPPORTED_PERSONALITIES];
+static struct number_set inject_set[SUPPORTED_PERSONALITIES];
static struct number_set raw_set[SUPPORTED_PERSONALITIES];
static struct number_set trace_set[SUPPORTED_PERSONALITIES];
static struct number_set verbose_set[SUPPORTED_PERSONALITIES];
}
static bool
-parse_fault_token(const char *const token, struct fault_opts *const fopts)
+parse_inject_token(const char *const token, struct inject_opts *const fopts)
{
const char *val;
int intval;
fopts->step = 0;
}
} else if ((val = strip_prefix("error=", token))) {
- if (fopts->rval != FAULT_OPTS_RVAL_DEFAULT)
+ if (fopts->rval != INJECT_OPTS_RVAL_DEFAULT)
return false;
intval = string_to_uint_upto(val, MAX_ERRNO_VALUE);
if (intval < 0)
return false;
fopts->rval = -intval;
} else if ((val = strip_prefix("retval=", token))) {
- if (fopts->rval != FAULT_OPTS_RVAL_DEFAULT)
+ if (fopts->rval != INJECT_OPTS_RVAL_DEFAULT)
return false;
intval = string_to_uint(val);
if (intval < 0)
}
static char *
-parse_fault_expression(const char *const s, char **buf,
- struct fault_opts *const fopts)
+parse_inject_expression(const char *const s, char **buf,
+ struct inject_opts *const fopts)
{
char *saveptr = NULL;
char *name = NULL;
token = strtok_r(NULL, ":", &saveptr)) {
if (!name)
name = token;
- else if (!parse_fault_token(token, fopts))
+ else if (!parse_inject_token(token, fopts))
goto parse_error;
}
static void
qualify_fault(const char *const str)
{
- struct fault_opts opts = {
+ struct inject_opts opts = {
.first = 1,
.step = 1,
- .rval = FAULT_OPTS_RVAL_DEFAULT,
+ .rval = INJECT_OPTS_RVAL_DEFAULT,
.signo = 0
};
char *buf = NULL;
- char *name = parse_fault_expression(str, &buf, &opts);
+ char *name = parse_inject_expression(str, &buf, &opts);
if (!name) {
error_msg_and_die("invalid %s '%s'", "fault argument", str);
}
* If signal is specified but neither retval nor error are specified,
* disable syscall fault injection.
*/
- if (opts.signo && opts.rval == FAULT_OPTS_RVAL_DEFAULT) {
- opts.rval = FAULT_OPTS_RVAL_DISABLE;
+ if (opts.signo && opts.rval == INJECT_OPTS_RVAL_DEFAULT) {
+ opts.rval = INJECT_OPTS_RVAL_DISABLE;
}
struct number_set tmp_set[SUPPORTED_PERSONALITIES];
free(buf);
/*
- * Initialize fault_vec accourding to tmp_set.
- * Merge tmp_set into fault_set.
+ * Initialize inject_vec accourding to tmp_set.
+ * Merge tmp_set into inject_set.
*/
unsigned int p;
for (p = 0; p < SUPPORTED_PERSONALITIES; ++p) {
continue;
}
- if (!fault_vec[p]) {
- fault_vec[p] = xcalloc(nsyscall_vec[p],
- sizeof(*fault_vec[p]));
+ if (!inject_vec[p]) {
+ inject_vec[p] = xcalloc(nsyscall_vec[p],
+ sizeof(*inject_vec[p]));
}
unsigned int i;
for (i = 0; i < nsyscall_vec[p]; ++i) {
if (is_number_in_set(i, &tmp_set[p])) {
- add_number_to_set(i, &fault_set[p]);
- fault_vec[p][i] = opts;
+ add_number_to_set(i, &inject_set[p]);
+ inject_vec[p][i] = opts;
}
}
? QUAL_VERBOSE : 0)
| (is_number_in_set(scno, &raw_set[current_personality])
? QUAL_RAW : 0)
- | (is_number_in_set(scno, &fault_set[current_personality])
- ? QUAL_FAULT : 0);
+ | (is_number_in_set(scno, &inject_set[current_personality])
+ ? QUAL_INJECT : 0);
}
int p;
for (p = 0; p < SUPPORTED_PERSONALITIES; ++p)
- free(tcp->fault_vec[p]);
+ free(tcp->inject_vec[p]);
free_tcb_priv_data(tcp);
static int arch_set_error(struct tcb *);
static int arch_set_success(struct tcb *);
-struct fault_opts *fault_vec[SUPPORTED_PERSONALITIES];
+struct inject_opts *inject_vec[SUPPORTED_PERSONALITIES];
-static struct fault_opts *
-tcb_fault_opts(struct tcb *tcp)
+static struct inject_opts *
+tcb_inject_opts(struct tcb *tcp)
{
- return (scno_in_range(tcp->scno) && tcp->fault_vec[current_personality])
- ? &tcp->fault_vec[current_personality][tcp->scno] : NULL;
+ return (scno_in_range(tcp->scno) && tcp->inject_vec[current_personality])
+ ? &tcp->inject_vec[current_personality][tcp->scno] : NULL;
}
static long
-inject_syscall_fault_entering(struct tcb *tcp, unsigned int *signo)
+tamper_with_syscall_entering(struct tcb *tcp, unsigned int *signo)
{
- if (!tcp->fault_vec[current_personality]) {
- tcp->fault_vec[current_personality] =
- xcalloc(nsyscalls, sizeof(**fault_vec));
- memcpy(tcp->fault_vec[current_personality],
- fault_vec[current_personality],
- nsyscalls * sizeof(**fault_vec));
+ if (!tcp->inject_vec[current_personality]) {
+ tcp->inject_vec[current_personality] =
+ xcalloc(nsyscalls, sizeof(**inject_vec));
+ memcpy(tcp->inject_vec[current_personality],
+ inject_vec[current_personality],
+ nsyscalls * sizeof(**inject_vec));
}
- struct fault_opts *opts = tcb_fault_opts(tcp);
+ struct inject_opts *opts = tcb_inject_opts(tcp);
if (!opts || opts->first == 0)
return 0;
if (opts->signo > 0)
*signo = opts->signo;
- if (opts->rval != FAULT_OPTS_RVAL_DISABLE && !arch_set_scno(tcp, -1))
- tcp->flags |= TCB_FAULT_INJ;
+ if (opts->rval != INJECT_OPTS_RVAL_DISABLE && !arch_set_scno(tcp, -1))
+ tcp->flags |= TCB_TAMPERED;
return 0;
}
static long
-update_syscall_fault_exiting(struct tcb *tcp)
+tamper_with_syscall_exiting(struct tcb *tcp)
{
- struct fault_opts *opts = tcb_fault_opts(tcp);
+ struct inject_opts *opts = tcb_inject_opts(tcp);
if (!opts)
return 0;
/* Restrain from fault injection while the trace executes strace code. */
if (hide_log(tcp)) {
- tcp->qual_flg &= ~QUAL_FAULT;
+ tcp->qual_flg &= ~QUAL_INJECT;
}
switch (tcp->s_ent->sen) {
goto ret;
}
- if (tcp->qual_flg & QUAL_FAULT)
- inject_syscall_fault_entering(tcp, sig);
+ if (tcp->qual_flg & QUAL_INJECT)
+ tamper_with_syscall_entering(tcp, sig);
if (cflag == CFLAG_ONLY_STATS) {
res = 0;
}
static bool
-syscall_fault_injected(struct tcb *tcp)
+syscall_tampered(struct tcb *tcp)
{
- return tcp->flags & TCB_FAULT_INJ;
+ return tcp->flags & TCB_TAMPERED;
}
static int
if (filtered(tcp) || hide_log(tcp))
goto ret;
- if (syserror(tcp) && syscall_fault_injected(tcp))
- update_syscall_fault_exiting(tcp);
+ if (syserror(tcp) && syscall_tampered(tcp))
+ tamper_with_syscall_exiting(tcp);
if (cflag) {
count_syscall(tcp, &tv);
tabto();
tprints("= ? <unavailable>\n");
line_ended();
- tcp->flags &= ~(TCB_INSYSCALL | TCB_FAULT_INJ);
+ tcp->flags &= ~(TCB_INSYSCALL | TCB_TAMPERED);
tcp->sys_func_rval = 0;
free_tcb_priv_data(tcp);
return res;
} else {
tprintf("= %#" PRI_klx, tcp->u_rval);
}
- if (syscall_fault_injected(tcp))
+ if (syscall_tampered(tcp))
tprints(" (INJECTED)");
}
else if (!(sys_res & RVAL_NONE) && u_error) {
u_error, strerror(u_error));
break;
}
- if (syscall_fault_injected(tcp))
+ if (syscall_tampered(tcp))
tprintf(" (INJECTED)");
if ((sys_res & RVAL_STR) && tcp->auxstr)
tprintf(" (%s)", tcp->auxstr);
}
if ((sys_res & RVAL_STR) && tcp->auxstr)
tprintf(" (%s)", tcp->auxstr);
- if (syscall_fault_injected(tcp))
+ if (syscall_tampered(tcp))
tprints(" (INJECTED)");
}
if (Tflag) {
#endif
ret:
- tcp->flags &= ~(TCB_INSYSCALL | TCB_FAULT_INJ);
+ tcp->flags &= ~(TCB_INSYSCALL | TCB_TAMPERED);
tcp->sys_func_rval = 0;
free_tcb_priv_data(tcp);
return 0;