~ubuntu-branches/ubuntu/quantal/libseccomp/quantal-backports

« back to all changes in this revision

Viewing changes to patches-master/03-bpf-small_filter_fix.patch

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2013-11-07 16:35:12 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131107163512-gdgfu5c3kuxfpxvg
Tags: 1.0.1-2~ubuntu12.10.1
No-change backport to quantal (LP: #1244340)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
bpf: fix a problem with small filters
 
2
 
 
3
From: Paul Moore <pmoore@redhat.com>
 
4
 
 
5
Signed-off-by: Paul Moore <pmoore@redhat.com>
 
6
---
 
7
 src/gen_bpf.c |    9 ++++-----
 
8
 1 file changed, 4 insertions(+), 5 deletions(-)
 
9
 
 
10
diff --git a/src/gen_bpf.c b/src/gen_bpf.c
 
11
index 5514010..403496e 100644
 
12
--- a/src/gen_bpf.c
 
13
+++ b/src/gen_bpf.c
 
14
@@ -1086,6 +1086,9 @@ static struct bpf_blk *_gen_bpf_arch(struct bpf_state *state,
 
15
                        b_tail = b_tail->next;
 
16
                blk_cnt++;
 
17
        }
 
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);
 
21
 
 
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,
 
25
                b_head = b_hdr;
 
26
        }
 
27
 
 
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 */
 
30
        b_iter = b_head;
 
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);
 
35
-
 
36
                /* add to the hash table */
 
37
                rc = _hsh_add(state, &b_iter, 1);
 
38
                if (rc < 0)