blob: d04704d9a1230c96b593394adf4454aa9ba03757 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# chaseccomp
chaseccomp is a simple BPF assembler for interfacing with seccomp.
Input files look something like:
```
# load syscall number
load nr
# check if it's exit_group
ifeq SYS_exit_group allow
# if not, die
ret kill
: allow
# else, allow
ret allow
```
It has labels, conditional jumps, and support for C identifiers. In
fact, C identifiers are just passed on to the C compiler.
It also has an "ifeqdef" statement, which wraps each "ifeq" in an
ifdef. This lets us use the same filters for all platforms - if it
doesn't support a syscall, its "allow" rule just doesn't get compiled
in.
Also note, the following statement is prepended to every filter, with an
automatically determined audit arch nr:
```
load arch
ifne {audit arch nr of computer} deny
```
Ideally, the filter should be constructed by sorting the syscalls in
order of usage frequency and then checking each syscall with ifeqdef.
The assembler runs in three steps:
* gen_defs generates a C file from `$<.chasc` (and any chasc file it
includes)
* The C file is compiled and executed, thereby disabling filters for
syscalls that do not apply to this platform, and determining the audit
arch number. The output is in `$<.chasc.expanded`.
* gen_syscalls takes `$<.chasc.expanded` and outputs `chasc_$<.h`.
This is the final header file we include in the actual program.
|