summaryrefslogtreecommitdiff
path: root/src/gen_bpf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gen_bpf.c')
-rw-r--r--src/gen_bpf.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gen_bpf.c b/src/gen_bpf.c
index 452d954..8d1b1b5 100644
--- a/src/gen_bpf.c
+++ b/src/gen_bpf.c
@@ -153,6 +153,8 @@ struct bpf_state {
/* filter attributes */
const struct db_filter_attr *attr;
+ /* bad arch action */
+ uint64_t bad_arch_hsh;
/* default action */
uint64_t def_hsh;
@@ -1352,22 +1354,26 @@ static struct bpf_blk *_gen_bpf_arch(struct bpf_state *state,
/* filter out x32 */
_BPF_INSTR(instr,
_BPF_OP(state->arch, BPF_JMP + BPF_JGE),
- _BPF_JMP_NXT(blk_cnt++), _BPF_JMP_NO,
+ _BPF_JMP_HSH(state->bad_arch_hsh),
+ _BPF_JMP_NO,
_BPF_K(state->arch, X32_SYSCALL_BIT));
if (b_head != NULL)
instr.jf = _BPF_JMP_HSH(b_head->hash);
else
instr.jf = _BPF_JMP_HSH(state->def_hsh);
+ blk_cnt++;
} else if (state->arch->token == SCMP_ARCH_X32) {
/* filter out x86_64 */
_BPF_INSTR(instr,
_BPF_OP(state->arch, BPF_JMP + BPF_JGE),
- _BPF_JMP_NO, _BPF_JMP_NXT(blk_cnt++),
+ _BPF_JMP_NO,
+ _BPF_JMP_HSH(state->bad_arch_hsh),
_BPF_K(state->arch, X32_SYSCALL_BIT));
if (b_head != NULL)
instr.jt = _BPF_JMP_HSH(b_head->hash);
else
instr.jt = _BPF_JMP_HSH(state->def_hsh);
+ blk_cnt++;
} else
/* we should never get here */
goto arch_failure;
@@ -1636,6 +1642,7 @@ static int _gen_bpf_build_bpf(struct bpf_state *state,
rc = _hsh_add(state, &b_badarch, 1);
if (rc < 0)
return rc;
+ state->bad_arch_hsh = b_badarch->hash;
/* generate the default action */
b_default = _gen_bpf_action(state, NULL, state->attr->act_default);