1
bpf: fix a problem with small filters
3
From: Paul Moore <pmoore@redhat.com>
5
Signed-off-by: Paul Moore <pmoore@redhat.com>
7
src/gen_bpf.c | 9 ++++-----
8
1 file changed, 4 insertions(+), 5 deletions(-)
10
diff --git a/src/gen_bpf.c b/src/gen_bpf.c
11
index 5514010..403496e 100644
14
@@ -1086,6 +1086,9 @@ static struct bpf_blk *_gen_bpf_arch(struct bpf_state *state,
15
b_tail = b_tail->next;
18
+ if (db->syscalls != NULL)
19
+ /* fixup last syscall false jump (fail to default action) */
20
+ b_tail->blks[0].jf = _BPF_JMP_HSH(state->def_hsh);
22
/* do the architecture check and load the syscall number */
23
if (db->syscalls != NULL) {
24
@@ -1124,13 +1127,9 @@ static struct bpf_blk *_gen_bpf_arch(struct bpf_state *state,
28
- /* add all of the fitlers to the hash table and add a default action */
29
+ /* add all of the fitlers to the hash table */
31
while (b_iter != NULL) {
32
- /* add a jump to the default action if we are at the end */
33
- if (b_iter->next == NULL)
34
- b_iter->blks[0].jf = _BPF_JMP_HSH(state->def_hsh);
36
/* add to the hash table */
37
rc = _hsh_add(state, &b_iter, 1);