Skip to content

Commit

Permalink
Seccomp: filter more syscalls
Browse files Browse the repository at this point in the history
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ia17360035035418ada519cf758e38be35c01a177
  • Loading branch information
caolanm committed Jan 9, 2025
1 parent 5803eca commit c4d4506
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/Seccomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ bool lockdown([[maybe_unused]] Type type)
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \
BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW)

#define REJECT_SYSCALL(name, err) \
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \
BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ERRNO | (err & SECCOMP_RET_DATA))

#define KILL_SYSCALL_FULL(fullname) \
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, fullname, 0, 1), \
BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_TRAP)
Expand Down Expand Up @@ -158,6 +162,8 @@ bool lockdown([[maybe_unused]] Type type)
KILL_SYSCALL(shmat),
KILL_SYSCALL(shmctl),
#endif
REJECT_SYSCALL(execve, EPERM),
REJECT_SYSCALL(execveat, EPERM),
KILL_SYSCALL(getitimer),
KILL_SYSCALL(setitimer),
KILL_SYSCALL(sendfile),
Expand Down

0 comments on commit c4d4506

Please sign in to comment.