diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-11-07 16:25:48 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-11-07 16:25:48 +0100 |
| commit | e03c9a450b20c65b094348056f65b891fb95b3f4 (patch) | |
| tree | 6c1fafda0143b4f4be727ac771b2b160ca822540 | |
| parent | 6968689af8fc30f53f8696172072b4628c933a86 (diff) | |
| download | chawan-e03c9a450b20c65b094348056f65b891fb95b3f4.tar.gz | |
chaseccomp: update docs, remove redundant import
| -rw-r--r-- | lib/chaseccomp/README.md | 15 | ||||
| -rw-r--r-- | lib/chaseccomp/chaseccomp.h | 3 | ||||
| -rw-r--r-- | src/utils/sandbox.nim | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/lib/chaseccomp/README.md b/lib/chaseccomp/README.md index 60ae2045..d04704d9 100644 --- a/lib/chaseccomp/README.md +++ b/lib/chaseccomp/README.md @@ -5,9 +5,6 @@ chaseccomp is a simple BPF assembler for interfacing with seccomp. Input files look something like: ``` -# check if the arch is correct -load arch -ifne CHASECCOMP_AUDIT_ARCH_NR deny # load syscall number load nr # check if it's exit_group @@ -27,6 +24,14 @@ 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. @@ -35,7 +40,7 @@ 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. The output is in - `$<.chasc.expanded`. + 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. diff --git a/lib/chaseccomp/chaseccomp.h b/lib/chaseccomp/chaseccomp.h index 69d5aa43..3d123062 100644 --- a/lib/chaseccomp/chaseccomp.h +++ b/lib/chaseccomp/chaseccomp.h @@ -3,6 +3,7 @@ /* * seccomp */ + #define SECCOMP_SET_MODE_FILTER 1 #define SECCOMP_RET_KILL_PROCESS 0x80000000u @@ -62,8 +63,6 @@ struct sock_fprog { BPF_STMT(BPF_LD | BPF_W | BPF_ABS, \ (offsetof(struct seccomp_data, field))) -/* Note: we always operate in BPF_K source mode, which equals 0. */ - #define CHA_BPF_RET(val) BPF_STMT(BPF_RET | BPF_K, val) #define CHA_BPF_JE(data, n) BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, data, n, 0) #define CHA_BPF_JNE(data, m) BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, data, 0, m) diff --git a/src/utils/sandbox.nim b/src/utils/sandbox.nim index b2e2c8b0..6194dd33 100644 --- a/src/utils/sandbox.nim +++ b/src/utils/sandbox.nim @@ -86,8 +86,6 @@ elif SandboxMode == stSeccomp: return s {.passl: sourceParent() & "../../lib/chaseccomp/chaseccomp.o".} - import std/posix - proc cha_enter_buffer_sandbox(): cint {.importc, cdecl.} proc cha_enter_network_sandbox(): cint {.importc, cdecl.} |