Documentation ¶
Overview ¶
Package syscallset is an easy to use Go library allowing any Go program to restrict its own capabilities on Linux through seccomp-bpf and predefined syscall sets from systemd.
To self-limit a Go application, use this package's LimitTo or LimitAndLog functions.
The following syscall groups from systemd are available:
- aio: Asynchronous IO
- basic-io: Basic IO
- chown: Change ownership of files and directories
- clock: Change the system time
- cpu-emulation: System calls for CPU emulation functionality
- debug: Debugging, performance monitoring and tracing functionality
- default: System calls that are always permitted
- file-system: File system operations
- io-event: Event loop system calls
- ipc: SysV IPC, POSIX Message Queues or other IPC
- keyring: Kernel keyring access
- known: All known syscalls declared in the kernel
- memlock: Memory locking control
- module: Loading and unloading of kernel modules
- mount: Mounting and unmounting of file systems
- network-io: Network or Unix socket IO, should not be needed if not network facing
- obsolete: Unusual, obsolete or unimplemented system calls
- pkey: System calls used for memory protection keys
- privileged: All system calls which need super-user capabilities
- process: Process control, execution, namespacing operations
- raw-io: Raw I/O port access
- reboot: Reboot and reboot preparation/kexec
- resources: Alter resource settings
- sandbox: Sandbox functionality
- setuid: Operations for changing user/group credentials
- signal: Process signal handling
- swap: Enable/disable swap devices
- sync: Synchronize files and memory to storage
- system-service: General system service operations
- timer: Schedule operations by time
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSupported ¶
func IsSupported() bool
IsSupported returns true if filtering syscalls through seccomp-bpf is possible on this platform.
func LimitAndLog ¶
LimitAndLog acts like LimitTo; however, non allowed syscalls are being logged instead of resulting in aborting the process. This might be useful for testing the application.
func LimitTo ¶
LimitTo a subset of the available Linux syscalls using a systemd system call filter string.
A filter string might contain both syscall sets, prefixed by an at sign (@), as well as single syscalls by their name. The list of syscall sets is either available in this package's main documentation or can be fetched from systemd's exec documentation:
https://www.freedesktop.org/software/systemd/man/systemd.exec.html#System%20Call%20Filtering
The filter acts as an allow list. Thus, every other syscall results in the termination of the process and its children. One can remove single syscalls or smaller sets again by prefixing them with a tilde (~). As the set of allowed syscalls is created by parsing the words from left to right, one should start with building the allow list and reducing it afterwards.
A small subset of syscalls (@default) is always allowed. Thus, when calling with an empty string, a very strict filter is applied, not even allowing using stdin or stdout.
A simple example with systemd's wide @system-service might be:
@system-service
Allowing some IO and file system access might be achieved through:
@basic-io @file-system @io-event
To restrict a wider set might be used like the following:
@system-service ~@process ~@setuid
Types ¶
This section is empty.