Skip to content
Permalink
Browse files

add priv qualifier for -e inject

  • Loading branch information
haoyouab committed Jun 18, 2019
1 parent aa17a7b commit 9c915fe7ed66f08b41b5d9c72e3d03b09c8ca9a3
Showing with 22 additions and 0 deletions.
  1. +2 −0 defs.h
  2. +18 −0 filter_qualify.c
  3. +2 −0 syscall.c
2 defs.h
@@ -164,6 +164,7 @@ typedef struct ioctlent {
# define INJECT_F_DELAY_ENTER 0x08
# define INJECT_F_DELAY_EXIT 0x10
# define INJECT_F_SYSCALL 0x20
# define INJECT_F_PRIV 0x40

# define INJECT_ACTION_FLAGS \
(INJECT_F_SIGNAL \
@@ -179,6 +180,7 @@ struct inject_data {
uint16_t rval_idx; /* index in retval_vec */
uint16_t delay_idx; /* index in delay_data_vec */
uint16_t scno; /* syscall to be injected instead of -1 */
char priv[4096];
};

struct inject_opts {
@@ -68,6 +68,20 @@ find_errno_by_name(const char *name)
return -1;
}

static bool
parse_priv_token(const char *input, struct inject_opts *fopts)
{
unsigned flag = INJECT_F_PRIV;

if (fopts->data.flags & flag)
return false;

snprintf(fopts->data.priv, 4096, "%s", input);
fopts->data.flags |= flag;

return true;
}

static bool
parse_delay_token(const char *input, struct inject_opts *fopts, bool isenter)
{
@@ -215,6 +229,10 @@ parse_inject_token(const char *const token, struct inject_opts *const fopts,
return false;
fopts->data.signo = intval;
fopts->data.flags |= INJECT_F_SIGNAL;
} else if (!fault_tokens_only
&& (val = STR_STRIP_PREFIX(token, "priv=")) != token) {
if (!parse_priv_token(val, fopts))
return false;
} else if (!fault_tokens_only
&& (val = STR_STRIP_PREFIX(token, "delay_enter=")) != token) {
if (!parse_delay_token(val, fopts, true))
@@ -516,6 +516,8 @@ tamper_with_syscall_entering(struct tcb *tcp, unsigned int *signo)
#endif
}
}
if (opts->data.flags & INJECT_F_PRIV)
tcp->_priv_data = opts->data.priv;
if (opts->data.flags & INJECT_F_DELAY_ENTER)
delay_tcb(tcp, opts->data.delay_idx, true);
if (opts->data.flags & INJECT_F_DELAY_EXIT)

0 comments on commit 9c915fe

Please sign in to comment.
You can’t perform that action at this time.