aboutgitcodelistschat:MatrixIRC
path: root/cooker/filter.h
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-03-28 16:48:58 +0200
committerAlice Frosi <afrosi@redhat.com>2023-03-28 17:05:54 +0200
commitb6c964fb5a00c8b8ab26a4678cdde24c3e9b1d9c (patch)
tree55449680aa735b529600b2b7927e160944685697 /cooker/filter.h
parent21c4730f0cb020db3bdff22e347a52d012cc79fe (diff)
downloadseitan-b6c964fb5a00c8b8ab26a4678cdde24c3e9b1d9c.tar
seitan-b6c964fb5a00c8b8ab26a4678cdde24c3e9b1d9c.tar.gz
seitan-b6c964fb5a00c8b8ab26a4678cdde24c3e9b1d9c.tar.bz2
seitan-b6c964fb5a00c8b8ab26a4678cdde24c3e9b1d9c.tar.lz
seitan-b6c964fb5a00c8b8ab26a4678cdde24c3e9b1d9c.tar.xz
seitan-b6c964fb5a00c8b8ab26a4678cdde24c3e9b1d9c.tar.zst
seitan-b6c964fb5a00c8b8ab26a4678cdde24c3e9b1d9c.zip
Rename cooker and eater with seitan prefix
Diffstat (limited to 'cooker/filter.h')
-rw-r--r--cooker/filter.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/cooker/filter.h b/cooker/filter.h
new file mode 100644
index 0000000..ee5ab12
--- /dev/null
+++ b/cooker/filter.h
@@ -0,0 +1,39 @@
+#ifndef FILTER_H_
+#define FILTER_H_
+
+#include <linux/filter.h>
+#include <linux/audit.h>
+#include <linux/seccomp.h>
+
+#define JGE(nr, right, left) \
+ BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, (nr), (right), (left))
+#define JUMPA(jump) BPF_JUMP(BPF_JMP | BPF_JA, (jump), 0, 0)
+#define EQ(nr, a1, a2) BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, (nr), (a1), (a2))
+
+#define MAX_FILTER 1024
+
+#define MAX_JUMPS 128
+#define EMPTY -1
+
+struct bpf_call {
+ char *name;
+ int args[6];
+ bool check_arg[6];
+};
+
+struct syscall_entry {
+ unsigned int count;
+ long nr;
+ const struct bpf_call *entry;
+};
+
+void create_lookup_nodes(int jumps[], unsigned int n);
+unsigned int left_child(unsigned int parent_index);
+unsigned int right_child(unsigned int parent_index);
+
+unsigned int create_bfp_program(struct syscall_entry table[],
+ struct sock_filter filter[],
+ unsigned int n_syscall);
+int convert_bpf(char *file, struct bpf_call *entries, int n, bool log);
+
+#endif