diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-04-06 14:58:43 +0200 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-04-06 14:58:43 +0200 |
commit | be8d1f5f3aac134218ccbeec49108844293796bc (patch) | |
tree | c15ede4ae3ec5eb1911ebe6dcfdb9bc1b18e751f /cooker | |
parent | 89428f6c6ab2c1cea735258b4257f15f71648d0f (diff) | |
download | seitan-be8d1f5f3aac134218ccbeec49108844293796bc.tar seitan-be8d1f5f3aac134218ccbeec49108844293796bc.tar.gz seitan-be8d1f5f3aac134218ccbeec49108844293796bc.tar.bz2 seitan-be8d1f5f3aac134218ccbeec49108844293796bc.tar.lz seitan-be8d1f5f3aac134218ccbeec49108844293796bc.tar.xz seitan-be8d1f5f3aac134218ccbeec49108844293796bc.tar.zst seitan-be8d1f5f3aac134218ccbeec49108844293796bc.zip |
filter: define arg_cmp and arg_type
Diffstat (limited to 'cooker')
-rw-r--r-- | cooker/filter.c | 21 | ||||
-rw-r--r-- | cooker/filter.h | 8 |
2 files changed, 16 insertions, 13 deletions
diff --git a/cooker/filter.c b/cooker/filter.c index 29c2d64..9a2c9f1 100644 --- a/cooker/filter.c +++ b/cooker/filter.c @@ -158,7 +158,7 @@ static unsigned get_n_args_syscall_entry(const struct bpf_call *entry) unsigned i, n = 0; for (i = 0; i < 6; i++) - if (entry->args[i].type != NO_CHECK) + if (entry->args[i].cmp != NO_CHECK) n++; return n; } @@ -183,6 +183,8 @@ static unsigned int get_n_args_syscall_instr(const struct syscall_entry *table) entry = table->entry + i; n = 0; for (unsigned int k = 0; k < 6; k++) { + if (entry->args[k].cmp == NO_CHECK) + continue; switch (entry->args[k].type) { case U32: /* For 32 bit arguments: 2 instructions, @@ -197,8 +199,6 @@ static unsigned int get_n_args_syscall_instr(const struct syscall_entry *table) */ n += 4; break; - case NO_CHECK: - break; } } total_instr += n; @@ -229,12 +229,11 @@ static unsigned int get_total_args_instr(const struct syscall_entry table[], } static bool check_args_syscall_entry(const struct bpf_call *entry){ - return entry->args[0].type != NO_CHECK || - entry->args[1].type != NO_CHECK || - entry->args[2].type != NO_CHECK || - entry->args[3].type != NO_CHECK || - entry->args[4].type != NO_CHECK || - entry->args[5].type != NO_CHECK; + return entry->args[0].cmp != NO_CHECK || + entry->args[1].cmp != NO_CHECK || + entry->args[2].cmp != NO_CHECK || + entry->args[3].cmp != NO_CHECK || + entry->args[4].cmp != NO_CHECK || entry->args[5].cmp != NO_CHECK; } static bool check_args_syscall(const struct syscall_entry *table) @@ -352,10 +351,10 @@ unsigned int create_bfp_program(struct syscall_entry table[], entry = table[i].entry + j; next_args_off = get_n_args_syscall_entry(entry); for (k = 0; k < 6; k++) { + if (entry->args[k].cmp == NO_CHECK) + continue; offset = next_args_off - n_checks; switch (entry->args[k].type) { - case NO_CHECK: - break; case U64: size += eq_u64_filter( &filter[size], k, diff --git a/cooker/filter.h b/cooker/filter.h index 7705414..afdd0b9 100644 --- a/cooker/filter.h +++ b/cooker/filter.h @@ -33,16 +33,20 @@ #define MAX_JUMPS 128 #define EMPTY -1 -enum arg_type { NO_CHECK, U32, U64 }; +enum arg_type { U32, U64 }; union arg_value { uint32_t v32; uint64_t v64; }; +enum arg_cmp { NO_CHECK, EQ, NE, LE, LT, GE, GT, AND_EQ, AND_NE }; + struct arg { - enum arg_type type; union arg_value value; + enum arg_type type; + enum arg_cmp cmp; + union arg_value op2; }; struct bpf_call { |