Skip to content

Commit

Permalink
Merge branch 'seccomp-syscall'
Browse files Browse the repository at this point in the history
  • Loading branch information
rootmos committed Oct 27, 2022
2 parents da8f3c7 + bc7e497 commit 7a5937d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION_MAJOR=0
VERSION_MINOR=5
VERSION_PATCH=3
VERSION_PATCH=4
13 changes: 10 additions & 3 deletions build/seccomp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include <linux/seccomp.h>
#include <linux/filter.h>
#include <sys/prctl.h>
#include <sys/syscall.h>

#ifndef seccomp
static int seccomp(unsigned int operation, unsigned int flags, void *args)
{
return syscall(SYS_seccomp, operation, flags, args);
}
#endif

void seccomp_apply_filter()
{
Expand All @@ -9,6 +16,6 @@ void seccomp_apply_filter()
};

struct sock_fprog p = { .len = LENGTH(filter), .filter = filter };
int r = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &p);
CHECK(r, "prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER)");
int r = seccomp(SECCOMP_SET_MODE_FILTER, 0, &p);
CHECK(r, "seccomp(SECCOMP_SET_MODE_FILTER)");
}
1 change: 1 addition & 0 deletions hlua/filter.bpf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ld [$$offsetof(struct seccomp_data, arch)$$]
jne #$AUDIT_ARCH_X86_64, bad
ld [$$offsetof(struct seccomp_data, nr)$$]
jge #$__X32_SYSCALL_BIT, bad

jeq #$__NR_brk, good

Expand Down
1 change: 1 addition & 0 deletions hpython/filter.bpf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ld [$$offsetof(struct seccomp_data, arch)$$]
jne #$AUDIT_ARCH_X86_64, bad
ld [$$offsetof(struct seccomp_data, nr)$$]
jge #$__X32_SYSCALL_BIT, bad

jeq #$__NR_read, good
jeq #$__NR_write, good
Expand Down

0 comments on commit 7a5937d

Please sign in to comment.