use std::{
os::unix::ffi::OsStrExt,
sync::{LazyLock, Mutex, OnceLock},
};
use btoi::btoi;
use dur::Duration;
use memchr::memchr;
use nix::{
errno::Errno,
sys::{resource::rlim_t, utsname::uname},
unistd::{sysconf, Gid, SysconfVar, Uid},
};
use crate::{
cache::HashCache,
compat::{fs_type_t, MFdFlags, Persona},
confine::{check_cross_memory_attach, secure_getenv},
info,
landlock::ABI,
proc::proc_mmap_min_addr,
rng::randint,
sandbox::Version,
sysinfo::RandTimer,
};
pub type KeyValue<'a> = (&'a str, u64);
pub const PATH_ETC: &[u8] = b"/etc";
pub const SYD_SH: &str =
"/usr/bin/env HISTFILE= /usr/bin/bash --login --noprofile --norc --restricted";
pub const ESYD_SH: &str = include_str!("esyd.sh");
pub const SYD_EL: &str = include_str!("syd.el");
pub const ENV_ASSUME_KERNEL: &str = "SYD_ASSUME_KERNEL";
pub const ENV_CD: &str = "SYD_CHDIR";
pub const ENV_SH: &str = "SYD_SHELL";
pub const ENV_LOG: &str = "SYD_LOG";
pub const ENV_LOG_FD: &str = "SYD_LOG_FD";
pub const ENV_LOG_BUF_LEN: &str = "SYD_LOG_BUF_LEN";
pub const ENV_NPROC: &str = "SYD_NPROC";
pub const ENV_NPROC_MAX: &str = "SYD_NPROC_MAX";
pub const ENV_PID_FN: &str = "SYD_PID_FN";
pub const ENV_FORCE_NO_SYMLINKS: &str = "SYD_FORCE_NO_SYMLINKS";
pub const ENV_FORCE_NO_MAGICLINKS: &str = "SYD_FORCE_NO_MAGICLINKS";
pub const ENV_FORCE_NO_XDEV: &str = "SYD_FORCE_NO_XDEV";
pub const ENV_FORCE_CLOEXEC: &str = "SYD_FORCE_CLOEXEC";
pub const ENV_FORCE_RAND_FD: &str = "SYD_FORCE_RAND_FD";
pub const ENV_FORCE_RO_OPEN: &str = "SYD_FORCE_RO_OPEN";
pub const ENV_FORCE_LOCAL_NET: &str = "SYD_FORCE_LOCAL_NET";
pub const ENV_FORCE_TTY: &str = "SYD_FORCE_TTY";
pub const ENV_QUIET_TTY: &str = "SYD_QUIET_TTY";
pub const ENV_RLIMIT_AS: &str = "SYD_RLIMIT_AS";
pub const ENV_RLIMIT_CORE: &str = "SYD_RLIMIT_CORE";
pub const ENV_RLIMIT_DATA: &str = "SYD_RLIMIT_DATA";
pub const ENV_RLIMIT_FSIZE: &str = "SYD_RLIMIT_FSIZE";
pub const ENV_RLIMIT_MEMLOCK: &str = "SYD_RLIMIT_MEMLOCK";
pub const ENV_RLIMIT_NICE: &str = "SYD_RLIMIT_NICE";
pub const ENV_RLIMIT_NOFILE: &str = "SYD_RLIMIT_NOFILE";
pub const ENV_RLIMIT_NPROC: &str = "SYD_RLIMIT_NPROC";
pub const ENV_RLIMIT_RTPRIO: &str = "SYD_RLIMIT_RTPRIO";
pub const ENV_RLIMIT_RTTIME: &str = "SYD_RLIMIT_RTTIME";
pub const ENV_RLIMIT_SIGPENDING: &str = "SYD_RLIMIT_SIGPENDING";
pub const ENV_RLIMIT_STACK: &str = "SYD_RLIMIT_STACK";
pub const ENV_TMOUT: &str = "SYD_TMOUT";
pub const ENV_PTY_FD: &str = "SYD_PTY_FD";
pub const ENV_IPC: &str = "SYD_IPC";
pub const ENV_IPC_POLL_FD: &str = "SYD_IPC_POLL_FD";
pub const ENV_IPC_UNIX_FD: &str = "SYD_IPC_UNIX_FD";
pub const ENV_PROXY_HOST: &str = "SYD_PROXY_HOST";
pub const ENV_PROXY_PORT: &str = "SYD_PROXY_PORT";
pub const ENV_PROXY_UNIX: &str = "SYD_PROXY_UNIX";
pub const ENV_NO_CROSS_MEMORY_ATTACH: &str = "SYD_NO_CROSS_MEMORY_ATTACH";
pub const ENV_PROC_PID_MEM_FALLBACK: &str = "SYD_PROC_PID_MEM_FALLBACK";
pub const ENV_DUMP_SCMP: &str = "SYD_DUMP_SCMP";
pub const ENV_SKIP_SCMP: &str = "SYD_SKIP_SCMP";
pub const ENV_QUICK_BOOT: &str = "SYD_QUICK_BOOT";
pub const ENV_RAND: &str = "SYD_RAND";
pub const ENV_ID: &str = "SYD_ID";
pub const ENV_OCI_NO_CONFIG: &str = "SYD_OCI_NO_CONFIG";
pub const ENV_PDS: &str = "SYD_PDS";
pub const UID_MIN: Uid = Uid::from_raw(11);
pub const GID_MIN: Gid = Gid::from_raw(14);
pub const MAGIC_PREFIX: &[u8] = b"/dev/syd";
pub static VERSION: LazyLock<&'static str> = LazyLock::new(|| {
if env!("SYD_GIT_HEAD").is_empty() {
env!("CARGO_PKG_VERSION")
} else {
env!("SYD_GIT_HEAD")
}
});
pub const API_VERSION: Version = Version::new(3, 1);
pub const API_MAJOR_VERSION: &str = env!("CARGO_PKG_VERSION_MAJOR");
pub const API_MINOR_VERSION: &str = "1";
pub const IPC_MINOR_VERSION: &str = "1";
pub const CRYPT_MAGIC: &[u8] = &[0x7F, b'S', b'Y', b'D', 3];
pub const MAGIC_FILE: &[u8] = b"/dev/null";
pub const MAGIC_LOAD: &[u8] = b"/dev/syd/load";
pub static MAGIC_FEXT: LazyLock<String> = LazyLock::new(|| format!("syd-{API_MAJOR_VERSION}"));
pub const PATH_MAX_COMP: usize = 1024;
pub const DIRENT_BUF_SIZE: usize = 2048;
#[expect(clippy::cast_sign_loss)]
pub static PAGE_SIZE: LazyLock<u64> = LazyLock::new(|| {
sysconf(SysconfVar::PAGE_SIZE)
.unwrap_or(Some(4096))
.unwrap_or(4096) as u64
});
#[expect(clippy::cast_possible_truncation)]
pub static MAX_RW_COUNT: LazyLock<usize> = LazyLock::new(|| {
let page_size = *PAGE_SIZE as usize;
let page_mask = !(page_size - 1);
(i32::MAX as usize) & page_mask
});
pub const KCAPI_SIZE: usize = 16 * libc::PIPE_BUF;
pub const HASH_MAX_DIGESTSIZE: usize = 64;
pub const PIPE_BUF: usize = 16 * libc::PIPE_BUF;
pub const PIPE_BUF_ALG: usize = 15 * libc::PIPE_BUF;
pub static NPROC: LazyLock<usize> = LazyLock::new(num_cpus::get);
pub const MAXSYMLINKS: u8 = 40;
#[expect(clippy::disallowed_methods)]
pub static EMU_POOL_SIZE: LazyLock<usize> = LazyLock::new(|| {
let n = std::env::var_os(ENV_NPROC)
.map(|val| btoi::<usize>(val.as_bytes()).expect("SYD_NPROC"))
.unwrap_or_else(|| *NPROC);
assert!(n >= 1, "SYD_NPROC must be at least 1!");
n
});
#[expect(clippy::disallowed_methods)]
pub static EMU_MAX_SIZE: LazyLock<usize> = LazyLock::new(|| {
let n = std::env::var_os(ENV_NPROC_MAX)
.map(|val| btoi::<usize>(val.as_bytes()).expect("SYD_NPROC_MAX"))
.unwrap_or(usize::MAX);
assert!(
n > *EMU_POOL_SIZE,
"SYD_NPROC_MAX must be greater than SYD_NPROC!"
);
n
});
pub const EMU_KEEP_ALIVE: u16 = 3;
pub const EMU_STACK_SIZE: usize = 256 * 1024;
pub const MON_STACK_SIZE: usize = 192 * 1024;
pub const INT_POLL_TIME: Duration = Duration::from_millis(5);
pub const INT_STACK_SIZE: usize = 128 * 1024;
pub const OUT_STACK_SIZE: usize = 64 * 1024;
pub const IPC_STACK_SIZE: usize = 256 * 1024;
pub const AES_STACK_SIZE: usize = 96 * 1024;
pub const MAIN_STACK_SIZE: rlim_t = 2 * 1024 * 1024;
pub const MAIN_RLIMIT_FSIZE: rlim_t = 2 * 1024;
#[cfg(target_arch = "x86_64")]
const SYSLOG_CAPSHIFT: usize = 18;
#[cfg(target_arch = "x86")]
const SYSLOG_CAPSHIFT: usize = 18;
#[cfg(target_arch = "aarch64")]
const SYSLOG_CAPSHIFT: usize = 14;
#[cfg(target_arch = "arm")]
const SYSLOG_CAPSHIFT: usize = 13;
#[cfg(target_arch = "riscv64")]
const SYSLOG_CAPSHIFT: usize = 14;
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
const SYSLOG_CAPSHIFT: usize = 18;
#[cfg(target_arch = "s390x")]
const SYSLOG_CAPSHIFT: usize = 17;
#[cfg(not(any(
target_arch = "x86_64",
target_arch = "x86",
target_arch = "aarch64",
target_arch = "arm",
target_arch = "s390x",
target_arch = "riscv64",
target_arch = "powerpc",
target_arch = "powerpc64",
)))]
const SYSLOG_CAPSHIFT: usize = 14;
pub const SYSLOG_STACK_SIZE: usize = 1 << SYSLOG_CAPSHIFT;
pub const SYSLOG_CAPACITY: usize = 2 * 1024 * 1024;
pub const SEGVGUARD_EXPIRY: Duration = Duration::from_secs(2 * 60);
pub const SEGVGUARD_SUSPENSION: Duration = Duration::from_secs(10 * 60);
pub const SEGVGUARD_MAXCRASHES: u8 = 5;
pub const SAFE_PERSONAS: &[KeyValue] = &[
("PER_LINUX", 0x0000),
("PER_LINUX32", 0x0008),
("UNAME26", 0x0020000),
("PER_LINUX32|UNAME26", 0x0008 | 0x0020000),
("GET_PERSONALITY", 0xffffffff),
];
pub const UNSAFE_PERSONA: Persona = Persona::from_bits_retain(
Persona::READ_IMPLIES_EXEC.bits()
| Persona::ADDR_NO_RANDOMIZE.bits()
| Persona::ADDR_COMPAT_LAYOUT.bits()
| Persona::MMAP_PAGE_ZERO.bits(),
);
pub const ALLOW_MADVISE: &[KeyValue] = &[
("MADV_NORMAL", libc::MADV_NORMAL as u64),
("MADV_SEQUENTIAL", libc::MADV_SEQUENTIAL as u64),
("MADV_DONTNEED", libc::MADV_DONTNEED as u64),
("MADV_REMOVE", libc::MADV_REMOVE as u64),
("MADV_HUGEPAGE", libc::MADV_HUGEPAGE as u64),
("MADV_NOHUGEPAGE", libc::MADV_NOHUGEPAGE as u64),
("MADV_DONTDUMP", libc::MADV_DONTDUMP as u64),
("MADV_COLLAPSE", 25),
("MADV_POPULATE_READ", libc::MADV_POPULATE_READ as u64),
("MADV_POPULATE_WRITE", libc::MADV_POPULATE_WRITE as u64),
("MADV_GUARD_INSTALL", 102),
("MADV_GUARD_REMOVE", 103),
];
pub const NOOP_MADVISE: &[u64] = &[
libc::MADV_RANDOM as u64,
libc::MADV_WILLNEED as u64,
libc::MADV_DONTFORK as u64,
libc::MADV_DOFORK as u64,
libc::MADV_MERGEABLE as u64,
libc::MADV_UNMERGEABLE as u64,
101, libc::MADV_DODUMP as u64,
libc::MADV_FREE as u64,
libc::MADV_WIPEONFORK as u64,
libc::MADV_KEEPONFORK as u64,
libc::MADV_COLD as u64,
libc::MADV_PAGEOUT as u64,
];
pub const DENY_MADVISE: &[u64] = &[libc::MADV_HWPOISON as u64];
pub const SYD_MADVISE: &[u64] = &[
libc::MADV_DONTNEED as u64,
libc::MADV_FREE as u64,
libc::MADV_HUGEPAGE as u64,
102, 103, ];
pub const ALLOW_PRCTL: &[KeyValue] = &[
("PR_SET_PDEATHSIG", 1),
("PR_GET_PDEATHSIG", 2),
("PR_GET_DUMPABLE", 3),
("PR_SET_DUMPABLE", 4),
("PR_GET_UNALIGN", 5),
("PR_SET_UNALIGN", 6),
("PR_GET_KEEPCAPS", 7),
("PR_SET_KEEPCAPS", 8),
("PR_GET_FPEMU", 9),
("PR_SET_FPEMU", 10),
("PR_GET_FPEXC", 11),
("PR_SET_FPEXC", 12),
("PR_GET_TIMING", 13),
("PR_SET_TIMING", 14),
("PR_SET_NAME", 15),
("PR_GET_NAME", 16),
("PR_GET_ENDIAN", 19),
("PR_SET_ENDIAN", 20),
("PR_GET_SECCOMP", 21), ("PR_SET_SECCOMP", 22), ("PR_CAPBSET_READ", 23),
("PR_CAPBSET_DROP", 24),
("PR_GET_TSC", 25),
("PR_SET_TSC", 26),
("PR_GET_SECUREBITS", 27),
("PR_SET_SECUREBITS", 28),
("PR_SET_TIMERSLACK", 29),
("PR_GET_TIMERSLACK", 30),
("PR_TASK_PERF_EVENTS_DISABLE", 31), ("PR_TASK_PERF_EVENTS_ENABLE", 32), ("PR_MCE_KILL", 33),
("PR_MCE_KILL_GET", 34),
("PR_SET_PTRACER", 0x59616d61), ("PR_SET_CHILD_SUBREAPER", 36),
("PR_GET_CHILD_SUBREAPER", 37),
("PR_SET_NO_NEW_PRIVS", 38),
("PR_GET_NO_NEW_PRIVS", 39),
("PR_GET_TID_ADDRESS", 40),
("PR_SET_THP_DISABLE", 41),
("PR_GET_THP_DISABLE", 42),
("PR_SET_FP_MODE", 45),
("PR_GET_FP_MODE", 46),
("PR_CAP_AMBIENT", 47),
("PR_SVE_SET_VL", 50),
("PR_SVE_GET_VL", 51),
("PR_GET_SPECULATION_CTRL", 52), ("PR_SET_SPECULATION_CTRL", 53), ("PR_PAC_RESET_KEYS", 54),
("PR_SET_TAGGED_ADDR_CTRL", 55),
("PR_GET_TAGGED_ADDR_CTRL", 56),
("PR_SET_IO_FLUSHER", 57),
("PR_GET_IO_FLUSHER", 58),
("PR_SET_SYSCALL_USER_DISPATCH", 59),
("PR_PAC_SET_ENABLED_KEYS", 60),
("PR_PAC_GET_ENABLED_KEYS", 61),
("PR_SCHED_CORE", 62),
("PR_SME_SET_VL", 63),
("PR_SME_GET_VL", 64),
("PR_SET_MDWE", 65),
("PR_GET_MDWE", 66),
("PR_RISCV_V_SET_CONTROL", 69),
("PR_RISCV_V_GET_CONTROL", 70),
("PR_RISCV_SET_ICACHE_FLUSH_CTX", 71),
("PR_PPC_GET_DEXCR", 72),
("PR_PPC_SET_DEXCR", 73),
("PR_GET_SHADOW_STACK_STATUS", 74),
("PR_SET_SHADOW_STACK_STATUS", 75),
("PR_LOCK_SHADOW_STACK_STATUS", 76),
("PR_FUTEX_HASH", 78),
("PR_RSEQ_SLICE_EXTENSION", 79), ("PR_GET_INDIR_BR_LP_STATUS", 80),
("PR_SET_INDIR_BR_LP_STATUS", 81),
("PR_LOCK_INDIR_BR_LP_STATUS", 82),
("PR_SET_VMA", 0x53564d41),
];
pub const DENY_SETSOCKOPT: &[(i32, i32)] = &[
(libc::SOL_SOCKET, libc::SO_DEBUG),
(libc::SOL_SOCKET, libc::SO_SNDBUFFORCE),
(libc::SOL_SOCKET, libc::SO_RCVBUFFORCE),
(libc::SOL_SOCKET, 25), (libc::SOL_SOCKET, 62), (libc::SOL_SOCKET, 26), (libc::SOL_SOCKET, 27), (libc::SOL_SOCKET, 50), (libc::SOL_SOCKET, 51), (libc::SOL_SOCKET, 52), (libc::SOL_SOCKET, 68), (libc::IPPROTO_IP, 64), (libc::IPPROTO_IP, 65), (libc::IPPROTO_IP, 96), (libc::IPPROTO_IP, 97), (libc::IPPROTO_IP, 41), (libc::IPPROTO_IP, 48), (libc::IPPROTO_IP, libc::IP_OPTIONS),
(libc::IPPROTO_IP, libc::IP_ADD_MEMBERSHIP),
(libc::IPPROTO_IP, libc::IP_DROP_MEMBERSHIP),
(libc::IPPROTO_IP, libc::IP_ADD_SOURCE_MEMBERSHIP),
(libc::IPPROTO_IP, libc::IP_DROP_SOURCE_MEMBERSHIP),
(libc::IPPROTO_IP, libc::IP_BLOCK_SOURCE),
(libc::IPPROTO_IP, libc::IP_UNBLOCK_SOURCE),
(libc::IPPROTO_IP, libc::MCAST_JOIN_GROUP),
(libc::IPPROTO_IP, libc::MCAST_LEAVE_GROUP),
(libc::IPPROTO_IP, libc::MCAST_JOIN_SOURCE_GROUP),
(libc::IPPROTO_IP, libc::MCAST_LEAVE_SOURCE_GROUP),
(libc::IPPROTO_IP, libc::MCAST_BLOCK_SOURCE),
(libc::IPPROTO_IP, libc::MCAST_UNBLOCK_SOURCE),
(libc::IPPROTO_IP, 200), (libc::IPPROTO_IP, 201), (libc::IPPROTO_IP, 202), (libc::IPPROTO_IP, 203), (libc::IPPROTO_IP, 204), (libc::IPPROTO_IP, 205), (libc::IPPROTO_IP, 206), (libc::IPPROTO_IP, 207), (libc::IPPROTO_IP, 208), (libc::IPPROTO_IP, 209), (libc::IPPROTO_IP, 210), (libc::IPPROTO_IP, 211), (libc::IPPROTO_IP, 212), (libc::IPPROTO_IPV6, 64), (libc::IPPROTO_IPV6, 65), (libc::IPPROTO_IPV6, libc::IPV6_ADDRFORM),
(libc::IPPROTO_IPV6, libc::IPV6_RTHDR),
(libc::IPPROTO_IPV6, libc::IPV6_DSTOPTS),
(libc::IPPROTO_IPV6, libc::IPV6_2292PKTOPTIONS),
(libc::IPPROTO_IP, 128), (libc::IPPROTO_IP, 129), (libc::IPPROTO_IPV6, 20 ),
(libc::IPPROTO_IPV6, 21 ),
(libc::IPPROTO_IPV6, 27 ),
(libc::IPPROTO_IPV6, 28 ),
(libc::IPPROTO_IPV6, libc::MCAST_JOIN_GROUP),
(libc::IPPROTO_IPV6, libc::MCAST_LEAVE_GROUP),
(libc::IPPROTO_IPV6, libc::MCAST_JOIN_SOURCE_GROUP),
(libc::IPPROTO_IPV6, libc::MCAST_LEAVE_SOURCE_GROUP),
(libc::IPPROTO_IPV6, libc::MCAST_BLOCK_SOURCE),
(libc::IPPROTO_IPV6, libc::MCAST_UNBLOCK_SOURCE),
(libc::IPPROTO_IPV6, 200), (libc::IPPROTO_IPV6, 201), (libc::IPPROTO_IPV6, 202), (libc::IPPROTO_IPV6, 203), (libc::IPPROTO_IPV6, 204), (libc::IPPROTO_IPV6, 205), (libc::IPPROTO_IPV6, 206), (libc::IPPROTO_IPV6, 207), (libc::IPPROTO_IPV6, 208), (libc::IPPROTO_IPV6, 209), (libc::IPPROTO_IPV6, 210), (libc::IPPROTO_IPV6, 211), (libc::IPPROTO_IPV6, 212), (libc::IPPROTO_TCP, libc::TCP_REPAIR),
(libc::IPPROTO_TCP, libc::TCP_REPAIR_QUEUE),
(libc::IPPROTO_TCP, libc::TCP_QUEUE_SEQ),
(libc::IPPROTO_TCP, libc::TCP_REPAIR_OPTIONS),
(libc::IPPROTO_TCP, libc::TCP_REPAIR_WINDOW),
(libc::IPPROTO_TCP, libc::TCP_ULP),
(libc::IPPROTO_TCP, libc::TCP_CONGESTION),
(libc::IPPROTO_TCP, 38), (libc::IPPROTO_TCP, 39), (libc::IPPROTO_TCP, 40), (libc::IPPROTO_TCP, 41), (libc::IPPROTO_TCP, 42), (libc::IPPROTO_UDP, libc::UDP_CORK),
(libc::SOL_PACKET, 5), (libc::SOL_PACKET, 10), (libc::SOL_PACKET, 13), (libc::SOL_PACKET, 18), (libc::SOL_PACKET, 19), (libc::SOL_PACKET, 20), (libc::SOL_PACKET, 21), (libc::SOL_PACKET, 22), (libc::SOL_PACKET, 23), (libc::SOL_SOCKET, 26 ),
(
libc::SOL_SOCKET,
27,
),
(libc::SOL_SOCKET, 44 ),
(libc::SOL_SOCKET, 48 ),
(libc::SOL_SOCKET, 50 ),
(libc::SOL_SOCKET, 51 ),
(libc::SOL_SOCKET, 52 ),
(libc::SOL_SOCKET, 53 ),
(libc::AF_VSOCK, 0), (libc::AF_VSOCK, 1), (libc::AF_VSOCK, 2), ];
pub const UNSAFE_ENV: &[&[u8]] = &[
b"GCONV_*",
b"GETCONF_*",
b"GLIBC_*",
b"HOST*",
b"LD_*",
b"LIBPATH",
b"LOCALDOMAIN",
b"MAIL_*",
b"MALLOC_*",
b"MUSL_*",
b"PRINTER",
b"RESOLV_HOST_CONF",
b"RES_OPTIONS",
b"TMPDIR",
b"*PWD",
b"*CRED*",
b"*PASS*",
b"*PRIV*",
b"*KEY*",
b"*TOKEN*",
b"LANG",
b"LANGUAGE",
b"LC_*",
b"TZ",
b"TZDIR",
b"*_CHARSET",
b"GNUPG*",
b"GPG_*",
b"PINENTRY_*",
b"SSH_*",
b"DBUS_*",
b"*SESSION*",
b"*DISPLAY*",
b"GDK_*",
b"GDM_*",
b"GTK_*",
b"QT_*",
b"XAUTHORITY",
b"XDG_*",
b"[ALMT]SAN_*",
b"UBSAN_*",
];
pub const FS_MAGIC: &[(&str, fs_type_t)] = &[
("aafs", 0x5a3c69f0i64 as fs_type_t),
("adfs", 0xadf5i64 as fs_type_t),
("affs", 0xadffi64 as fs_type_t),
("afs", 0x5346414Fi64 as fs_type_t),
("anon_inode_fs", 0x09041934i64 as fs_type_t),
("aufs", 0x61756673i64 as fs_type_t),
("autofs", 0x0187i64 as fs_type_t),
("bcachefs", 0xca451a4ei64 as fs_type_t),
("bdevfs", 0x62646576i64 as fs_type_t),
("befs", 0x42465331i64 as fs_type_t),
("bfs", 0x1BADFACEi64 as fs_type_t),
("binderfs", 0x6c6f6f70i64 as fs_type_t),
("binfmt_misc", 0x42494e4di64 as fs_type_t),
("bpf_fs", 0xcafe4a11i64 as fs_type_t),
("btrfs", 0x9123683Ei64 as fs_type_t),
("btrfs_test", 0x73727279i64 as fs_type_t),
("ceph", 0x00c36400i64 as fs_type_t),
("cgroup", 0x27e0ebi64 as fs_type_t),
("cgroup2", 0x63677270i64 as fs_type_t),
("cifs", 0xFF534D42i64 as fs_type_t),
("coda", 0x73757245i64 as fs_type_t),
("coh", 0x012FF7B7i64 as fs_type_t),
("configfs", 0x62656570i64 as fs_type_t),
("cramfs", 0x28cd3d45i64 as fs_type_t),
("cramfs", 0x453dcd28i64 as fs_type_t),
("daxfs", 0x64646178i64 as fs_type_t),
("debugfs", 0x64626720i64 as fs_type_t),
("devfs", 0x1373i64 as fs_type_t),
("devmem", 0x454d444di64 as fs_type_t),
("devpts", 0x1cd1i64 as fs_type_t),
("dma_buf", 0x444d4142i64 as fs_type_t),
("ecryptfs", 0xf15fi64 as fs_type_t),
("efivarfs", 0xde5e81e4i64 as fs_type_t),
("efs", 0x414A53i64 as fs_type_t),
("erofs", 0xE0F5E1E2i64 as fs_type_t),
("exfat", 0x2011BAB0i64 as fs_type_t),
("ext", 0x137Di64 as fs_type_t),
("ext", 0xEF51i64 as fs_type_t),
("ext", 0xEF53i64 as fs_type_t),
("f2fs", 0xF2F52010i64 as fs_type_t),
("fat", 0x4006i64 as fs_type_t),
("fhgfs", 0x19830326i64 as fs_type_t),
("fuseblk", 0x65735546i64 as fs_type_t),
("fusectl", 0x65735543i64 as fs_type_t),
("futexfs", 0xBAD1DEAi64 as fs_type_t),
("gfs", 0x1161970i64 as fs_type_t),
("gpfs", 0x47504653i64 as fs_type_t),
("hfs", 0x4244i64 as fs_type_t),
("hfsplus", 0x482bi64 as fs_type_t),
("hostfs", 0x00c0ffeei64 as fs_type_t),
("hpfs", 0xf995e849i64 as fs_type_t),
("hugetlbfs", 0x958458f6i64 as fs_type_t),
("inodefs", 0x11307854i64 as fs_type_t),
("inotifyfs", 0x2BAD1DEAi64 as fs_type_t),
("isofs", 0x9660i64 as fs_type_t),
("isofs", 0x4004i64 as fs_type_t),
("isofs", 0x4000i64 as fs_type_t),
("jffs", 0x07C0i64 as fs_type_t),
("jffs2", 0x72b6i64 as fs_type_t),
("jfs", 0x3153464Ai64 as fs_type_t),
("kafs", 0x6B414653 as fs_type_t),
("lustre", 0x0BD00BD0i64 as fs_type_t),
("minix", 0x137Fi64 as fs_type_t),
("minix", 0x138Fi64 as fs_type_t),
("minix2", 0x2468i64 as fs_type_t),
("minix2", 0x2478i64 as fs_type_t),
("minix3", 0x4d5ai64 as fs_type_t),
("mqueue", 0x19800202i64 as fs_type_t),
("msdos", 0x4d44i64 as fs_type_t),
("ncp", 0x564ci64 as fs_type_t),
("nfs", 0x6969i64 as fs_type_t),
("nfsd", 0x6E667364i64 as fs_type_t),
("nilfs", 0x3434i64 as fs_type_t),
("nsfs", 0x6e736673i64 as fs_type_t),
("ntfs", 0x5346544Ei64 as fs_type_t),
("ocfs2", 0x7461636fi64 as fs_type_t),
("openprom", 0x9fa1i64 as fs_type_t),
("overlayfs", 0x794c7630i64 as fs_type_t),
("panfs", 0xAAD7AAEAi64 as fs_type_t),
("pid_fd", 0x50494446i64 as fs_type_t),
("pipefs", 0x50495045i64 as fs_type_t),
("proc", 0x9fa0i64 as fs_type_t),
("pstorefs", 0x6165676Ci64 as fs_type_t),
("qnx4", 0x002fi64 as fs_type_t),
("qnx6", 0x68191122i64 as fs_type_t),
("ramfs", 0x858458f6i64 as fs_type_t),
("rdtgroup", 0x7655821i64 as fs_type_t),
("reiserfs", 0x52654973i64 as fs_type_t),
("reiserfs2", 0x52654974i64 as fs_type_t),
("reiserfs3", 0x52654975i64 as fs_type_t),
("romfs", 0x7275i64 as fs_type_t),
("rpc_pipefs", 0x67596969i64 as fs_type_t),
("secretmem", 0x5345434di64 as fs_type_t),
("securityfs", 0x73636673i64 as fs_type_t),
("selinux", 0xf97cff8ci64 as fs_type_t),
("smack", 0x43415d53i64 as fs_type_t),
("smb", 0x517Bi64 as fs_type_t),
("smb2", 0xFE534D42i64 as fs_type_t),
("sockfs", 0x534F434Bi64 as fs_type_t),
("squashfs", 0x73717368i64 as fs_type_t),
("sysfs", 0x62656572i64 as fs_type_t),
("sysv2", 0x012FF7B6i64 as fs_type_t),
("sysv4", 0x012FF7B5i64 as fs_type_t),
("tmpfs", 0x01021994i64 as fs_type_t),
("tracefs", 0x74726163i64 as fs_type_t),
("udf", 0x15013346i64 as fs_type_t),
("ufs", 0x00011954i64 as fs_type_t),
("ufs", 0x54190100i64 as fs_type_t),
("usbdevfs", 0x9fa2i64 as fs_type_t),
("v9fs", 0x01021997i64 as fs_type_t),
("vmhgfs", 0xBACBACBCi64 as fs_type_t),
("vxfs", 0xA501FCF5i64 as fs_type_t),
("vzfs", 0x565A4653i64 as fs_type_t),
("xenfs", 0xabba1974i64 as fs_type_t),
("xenix", 0x012FF7B4i64 as fs_type_t),
("xfs", 0x58465342i64 as fs_type_t),
("xia", 0x012FD16Di64 as fs_type_t),
("zfs", 0x2fc12fc1i64 as fs_type_t),
("zonefs", 0x5a4f4653i64 as fs_type_t),
];
pub const DEFAULT_IOCTL: &[(&str, bool)] = &[
("FIOCLEX", false),
("FIONCLEX", false),
("FIONBIO", false),
("FIONREAD", false),
("FIOASYNC", false),
("FIOQSIZE", false),
("FIFREEZE", true), ("FITHAW", true), ("FS_IOC_FIEMAP", true), ("FIGETBSZ", true), ("FICLONE", false),
("FICLONERANGE", false),
("FIDEDUPERANGE", false),
("FS_IOC_GETFSUUID", true), ("FS_IOC_GETFSSYSFSPATH", true), ("FIBMAP", true), ("KDSETKEYCODE", true),
("KDSIGACCEPT", true),
("TIOCSETD", true),
("TIOCSTI", true),
("TIOCCONS", true),
("TIOCLINUX", true),
("TIOCSSERIAL", true), ("FS_IOC_FSGETXATTR", true), ("FS_IOC_FSSETXATTR", true), ("FS_IOC_SETFLAGS", true), ("FS_IOC32_SETFLAGS", true), ("PIDFD_GET_INFO", false), ("RNDGETENTCNT", false), ("RNDADDTOENTCNT", true), ("RNDGETPOOL", true), ("RNDADDENTROPY", true), ("RNDZAPENTCNT", true), ("RNDCLEARPOOL", true), ("SECCOMP_IOCTL_NOTIF_RECV", true),
("SECCOMP_IOCTL_NOTIF_SEND", true),
("SECCOMP_IOCTL_NOTIF_ID_VALID", true),
("SECCOMP_IOCTL_NOTIF_ADDFD", true),
("SECCOMP_IOCTL_NOTIF_SET_FLAGS", true),
("KCOV_INIT_TRACE", true),
("KCOV_ENABLE", true),
("KCOV_DISABLE", true),
("KCOV_RESET_TRACE", true),
("KCOV_REMOTE_ENABLE", true),
];
pub const PROFILE_OFF: &[&str] = &[
"sandbox/all:off",
"sandbox/fs,ioctl,lock,net,mem,pid,pty,force,tpe:off",
];
pub const PROFILE_LIB: &[&str] = &["include_profile off", "lock:exec"];
pub const PROFILE_QUIET: &[&str] = &[
"default/all:filter",
"default/net,block,mem,pid,force,segvguard,tpe:filter",
];
pub const PROFILE_TRACE: &[&str] = &[
"log/level:info",
"sandbox/lock:off",
"sandbox/force,ioctl:on",
"default/all,fs,ioctl,force,tpe:warn",
];
pub const PROFILE_KCOV: &[&str] = &[
"include_profile privileged",
"setuid+0:65534",
"setgid+0:65534",
"sandbox/pty,tpe:off",
"segvguard/expiry:0",
"allow/fs+all",
"allow/net/link+all",
"trace/allow_safe_syslog:true",
"trace/allow_unsupp_socket:true",
"allow/all+/***",
"filter/chroot+/***",
"allow/all+!memfd:**",
"allow/all+!memfd-hugetlb:**",
"allow/all+!secretmem",
"filter/net/bind,net/connect+any!0-65535",
"allow/net/bind,net/connect+loopback!0-65535",
"allow/net/bind,net/connect,net/sendfd+!unnamed",
"allow/net/bind,net/connect,net/sendfd+/***",
"allow/net/bind,net/connect,net/sendfd+@**",
"default/ioctl:allow",
"deny/ioctl-*",
"trace/allow_unsafe_bind:true",
"trace/allow_unsafe_cbpf:true",
"trace/allow_unsafe_chown:true",
"trace/allow_unsafe_cpu:true",
"trace/allow_unsafe_create:true",
"trace/allow_unsafe_deprecated:true",
"trace/allow_unsafe_ebpf:true",
"trace/allow_unsafe_env:true",
"trace/allow_unsafe_exec_libc:true",
"trace/allow_unsafe_exec_memory:true",
"trace/allow_unsafe_exec_nopie:true",
"trace/allow_unsafe_exec_null:true",
"trace/allow_unsafe_exec_speculative:true",
"trace/allow_unsafe_hardlinks:true",
"trace/allow_unsafe_keyring:true",
"trace/allow_unsafe_magiclinks:true",
"trace/allow_unsafe_memfd:true",
"trace/allow_unsafe_mkbdev:true",
"trace/allow_unsafe_mkcdev:true",
"trace/allow_unsafe_msgqueue:true",
"trace/allow_unsafe_nice:true",
"trace/allow_unsafe_page_cache:true",
"trace/allow_unsafe_perf:true",
"trace/allow_unsafe_perm_msgqueue:true",
"trace/allow_unsafe_perm_shm:true",
"trace/allow_unsafe_pipe:true",
"trace/allow_unsafe_pkey:true",
"trace/allow_unsafe_prlimit:true",
"trace/allow_unsafe_sendfd_bdev:true",
"trace/allow_unsafe_sendfd_cdev:true",
"trace/allow_unsafe_sendfd_dir:true",
"trace/allow_unsafe_sendfd_fifo:true",
"trace/allow_unsafe_sendfd_magiclink:true",
"trace/allow_unsafe_sendfd_memfd:true",
"trace/allow_unsafe_sendfd_misc:true",
"trace/allow_unsafe_sendfd_secretmem:true",
"trace/allow_unsafe_sendfd_socket:true",
"trace/allow_unsafe_sendfd_symlink:true",
"trace/allow_unsafe_shm:true",
"trace/allow_unsafe_socket:true",
"trace/allow_unsafe_sticky:true",
"trace/allow_unsafe_symlinks:true",
"trace/allow_unsafe_sync:true",
"trace/allow_unsafe_sysinfo:true",
"trace/allow_unsafe_time:true",
"trace/allow_unsafe_uring:true",
];
pub const PROFILE_OCI: &[&str] = &[
"include_profile nopie", "include_profile trace",
"lock:off", "trace/allow_safe_syslog:true", ];
pub const PROFILE_ENFORCE: &[&str] = &["default/all,fs,ioctl,force,tpe:deny"];
pub const PROFILE_NOIPV4: &[&str] = &[
"sandbox/net:on",
"allow/cnet+any6!0-65535",
"deny/cnet+any4!0-65535",
];
pub const PROFILE_NOIPV6: &[&str] = &[
"sandbox/net:on",
"allow/cnet+any4!0-65535",
"deny/cnet+any6!0-65535",
];
pub const PROFILE_PRIVILEGED: &[&str] = &["trace/allow_unsafe_caps:true"];
pub const PROFILE_CORE: &[&str] = &[
"rlimit/core:inf", "trace/allow_unsafe_dumpable:true", ];
pub const PROFILE_DEBUG: &[&str] = &[
"include_profile core",
"trace/allow_unsafe_magiclinks:true", "trace/allow_unsafe_exec_memory:true", "trace/allow_unsafe_prctl:true", "trace/allow_unsafe_prlimit:true", "trace/allow_unsafe_ptrace:true", ];
pub const PROFILE_NOMEM: &[&str] = &["trace/allow_unsafe_exec_memory:true"];
pub const PROFILE_NOPIE: &[&str] = &["trace/allow_unsafe_exec_nopie:true"];
pub const PROFILE_NO_MAGIC: &[&str] = &["trace/force_no_magiclinks:true"];
pub const PROFILE_NO_XDEV: &[&str] = &["trace/force_no_xdev:true"];
pub const PROFILE_RAND: &[&str] = &["trace/force_rand_fd:true"];
pub const PROFILE_READONLY: &[&str] = &["trace/force_ro_open:true", "deny/cpath,wpath+/***"];
pub const PROFILE_LOCAL: &[&str] = &["trace/force_local_net:true"];
pub const PROFILE_LDD: &[&str] = &[
"trace/allow_unsafe_exec_libc:true", "trace/allow_unsafe_exec_ldso:true", ];
pub const PROFILE_LANG: &[&str] = &[
"passenv+LANG",
"passenv+LANGUAGE",
"passenv+LC_*",
"passenv+TZ",
"passenv+TZDIR",
"passenv+*_CHARSET",
];
pub const PROFILE_GUI: &[&str] = &[
"include_profile xdg",
"include_profile tty",
"trace/exit_wait_all:true", "uts/host:none", "uts/domain:none", "passenv+DBUS_*",
"passenv+*SESSION*",
"passenv+*DISPLAY*",
"passenv+GDK_*",
"passenv+GDM_*",
"passenv+GTK_*",
"passenv+QT_*",
"passenv+XAUTHORITY",
];
pub const PROFILE_XDG: &[&str] = &["passenv+XDG_*"];
pub const PROFILE_FIREFOX: &[&str] = &[
"include_profile lang",
"include_profile gui",
"trace/allow_unsafe_cbpf:true", "trace/allow_unsafe_chroot:true", "trace/allow_unsafe_namespace:all", "trace/allow_unsafe_magiclinks:true", "trace/allow_unsafe_exec_libc:true", "trace/allow_unsafe_exec_memory:true", "trace/allow_unsafe_page_cache:true", "trace/allow_unsafe_prlimit:true", "trace/allow_unsafe_shm:true", ];
pub const PROFILE_CHROME: &[&str] = &[
"include_profile lang",
"include_profile gui",
"trace/allow_unsafe_exec_memory:true", "trace/allow_unsafe_sendfd_dir:1", "trace/allow_unsafe_sendfd_memfd:1", "trace/allow_unsafe_sendfd_socket:1", "trace/allow_unsafe_shm:true", "trace/allow_unsafe_perm_shm:true", "trace/allow_unsafe_page_cache:true", ];
pub const PROFILE_CONTAINER: &[&str] = &[
"unshare/all:true",
"unshare/net:${SYD_CONTAINER_NET:-true}", "allow/lpath,rpath+/proc/uptime", ];
pub const PROFILE_IMMUTABLE: &[&str] = &[
"include_profile container",
"bind+/opt:/opt:ro,nodev,nosuid",
"bind+/usr:/usr:ro,nodev,nosuid",
"bind+/etc:/etc:ro,nodev,nosuid,noexec",
"bind+/mnt:/mnt:ro,nodev,nosuid,noexec,nosymfollow",
"bind+/srv:/srv:ro,nodev,nosuid,noexec,nosymfollow",
"bind+/home:/home:ro,nodev,nosuid,noexec,nosymfollow",
"bind+tmpfs:/boot:ro,nodev,nosuid,noexec,nosymfollow,mode=0,nr_blocks=1,nr_inodes=1",
"bind+tmpfs:/run:nodev,nosuid,nosymfollow,mode=1700",
"bind+tmpfs:/tmp:nodev,nosuid,nosymfollow,mode=1700",
"bind+tmpfs:/dev/shm:nodev,nosuid,noexec,nosymfollow,mode=1700",
"bind+tmpfs:/var/tmp:nodev,nosuid,noexec,nosymfollow,mode=1700",
"bind+mqueue:/dev/mqueue:nodev,nosuid,noexec,nosymfollow",
"bind+sysfs:/sys:ro,nodev,nosuid,noexec,nosymfollow",
];
pub const PROFILE_LANDLOCK: &[&str] = &[
"sandbox/lock:on", "allow/lock/rpath,exec+/etc",
"allow/lock/rpath,exec+/bin",
"allow/lock/rpath,exec+/sbin",
"allow/lock/rpath,exec+/lib",
"allow/lock/rpath,exec+/opt",
"allow/lock/rpath,exec+/usr",
"allow/lock/read,ioctl,write+/dev/full",
"allow/lock/read,ioctl,write+/dev/zero",
"allow/lock/read,ioctl+/dev/random",
"allow/lock/read,ioctl+/dev/urandom",
"allow/lock/rpath,cpath,wpath,tpath+/dev/shm",
"allow/lock/rpath,cpath,wpath,tpath+/var/tmp",
"allow/lock/rpath,cpath,wpath,tpath+/tmp",
];
pub const PROFILE_PALUDIS: &[&str] = &[
"include_profile linux",
"include_profile tty",
"default/lock:warn", "allow/lock/rpath+/dev", "allow/lock/rpath+/run", "allow/lock/rpath+/sys", "allow/lock/rpath+/var", "mask^", "rlimit/memlock:off", "time/mono:0", "sandbox/fs:${SYD_PALUDIS_FS:-off}", "sandbox/lpath:${SYD_PALUDIS_LPATH:-off}", "sandbox/ioctl:${SYD_PALUDIS_IOCTL:-off}", "sandbox/pty:${SYD_PALUDIS_PTY:-off}", "trace/memory_access:0", "trace/allow_safe_bind:true",
"trace/allow_unsafe_any_addr:true", "trace/allow_unsafe_cbpf:true", "trace/allow_unsafe_chroot:true", "trace/allow_unsafe_dumpable:true", "trace/allow_unsafe_env:true",
"trace/allow_unsafe_exec_libc:true",
"trace/allow_unsafe_exec_memory:true",
"trace/allow_unsafe_exec_nopie:true",
"trace/allow_unsafe_exec_null:true",
"trace/allow_unsafe_exec_stack:true",
"trace/allow_unsafe_exec_script:true", "trace/allow_unsafe_exec_interactive:true", "trace/allow_unsafe_exec_speculative:true", "trace/allow_unsafe_filename:true", "trace/allow_unsafe_cap_fixup:true", "trace/allow_unsafe_create:true", "trace/allow_unsafe_hardlinks:true", "trace/allow_unsafe_kcapi:true",
"trace/allow_unsafe_magiclinks:true", "trace/allow_unsafe_symlinks:true", "trace/allow_unsafe_machine_id:true", "trace/allow_unsafe_memfd:true", "trace/allow_unsafe_mkbdev:true", "trace/allow_unsafe_mkcdev:true", "trace/allow_unsafe_nice:true",
"trace/allow_unsafe_open_path:true",
"trace/allow_unsafe_open_suid:true", "trace/allow_unsafe_page_cache:true",
"trace/allow_unsafe_perf:true",
"trace/allow_unsafe_personality:true", "trace/allow_unsafe_ptrace:true",
"trace/allow_unsafe_prctl:true", "trace/allow_unsafe_prlimit:true",
"trace/allow_unsafe_proc_files:true", "trace/allow_unsafe_proc_pid_status:true", "trace/allow_unsafe_msgqueue:true", "trace/allow_unsafe_perm_msgqueue:true", "trace/allow_unsafe_shm:true", "trace/allow_unsafe_perm_shm:true", "trace/allow_unsafe_sendfd_cdev:true", "trace/allow_unsafe_sendfd_fifo:true", "trace/allow_unsafe_sendfd_memfd:true", "trace/allow_unsafe_sendfd_misc:true", "trace/allow_unsafe_sendfd_socket:true", "trace/allow_unsafe_sigreturn:true",
"trace/allow_unsafe_socket:true",
"trace/allow_unsafe_sysinfo:true", "trace/allow_unsupp_socket:true",
"trace/allow_unsafe_stat_cdev:true", "trace/allow_unsafe_stat_bdev:true", "trace/allow_unsafe_sticky:true", "trace/allow_unsafe_time:true",
"trace/allow_unsafe_uname:true", "trace/allow_unsafe_xattr:true", "allow/lock/readdir+/",
"deny/ioctl-FS_IOC_SETFLAGS!", "allow/ioctl+FS_IOC_SETFLAGS!",
"sandbox/exec:off",
"sandbox/tpe:off",
"filter/cnet+/run/systemd/userdb/io.systemd.DynamicUser",
"allow/lpath,rpath+/selinux",
"allow/lpath,rpath+/selinux/context",
"allow/lpath,rpath,write+/selinux/context/**",
"allow/lpath,rpath+/sys",
"allow/lpath,rpath+/sys/devices",
"allow/lpath,rpath+/sys/devices/system",
"allow/lpath,rpath+/sys/devices/system/cpu",
"allow/lpath,rpath+/sys/devices/system/cpu/isolated",
"allow/lpath,rpath+/sys/devices/system/cpu/kernel_max",
"allow/lpath,rpath+/sys/devices/system/cpu/online",
"allow/lpath,rpath+/sys/devices/system/cpu/offline",
"allow/lpath,rpath+/sys/devices/system/cpu/possible",
"allow/lpath,rpath+/sys/devices/system/cpu/present",
"allow/lpath,rpath+/sys/fs",
"allow/lpath,rpath+/sys/fs/cgroup/***",
"allow/lpath,rpath+/sys/kernel",
"allow/lpath,rpath+/sys/kernel/mm",
"allow/lpath,rpath+/sys/kernel/mm/transparent_hugepage/***",
"allow/lpath,rpath+/sys/kernel/security",
"allow/lpath,rpath+/sys/kernel/security/apparmor/***",
"allow/lpath,rpath+/proc/crypto",
"allow/lpath,rpath+/proc/cpuinfo",
"allow/lpath,rpath+/proc/filesystems",
"allow/lpath,rpath+/proc/loadavg",
"allow/lpath,rpath+/proc/meminfo",
"allow/lpath,rpath+/proc/mounts", "allow/lpath,rpath+/proc/stat",
"allow/lpath,rpath+/proc/uptime",
"allow/lpath,rpath+/proc/version",
"allow/lpath,rpath+/proc/sys",
"allow/lpath,rpath+/proc/sys/fs/***",
"allow/lpath,rpath+/proc/sys/kernel/***",
"allow/lpath,rpath+/proc/sys/net/***",
"allow/lpath,rpath+/proc/sys/vm/***",
"allow/lpath,rpath+/proc/[0-9]*",
"allow/lpath,rpath+/proc/self/cmdline",
"allow/lpath,rpath+/proc/self/task/[0-9]*/cmdline",
"allow/lpath,rpath+/proc/self/comm",
"allow/lpath,rpath+/proc/self/task/[0-9]*/comm",
"allow/lpath,rpath+/proc/self/environ",
"allow/lpath,rpath+/proc/self/task/[0-9]*/environ",
"allow/lpath,rpath+/proc/self/loginuid",
"allow/lpath,rpath+/proc/self/task/[0-9]*/loginuid",
"allow/lpath,rpath+/proc/self/stat*",
"allow/lpath,rpath+/proc/self/task/[0-9]*/stat*",
"allow/lpath,rpath+/proc/[0-9]*/cmdline",
"allow/lpath,rpath+/proc/[0-9]*/task/[0-9]*/cmdline",
"allow/lpath,rpath+/proc/[0-9]*/comm",
"allow/lpath,rpath+/proc/[0-9]*/task/[0-9]*/comm",
"allow/lpath,rpath+/proc/[0-9]*/environ",
"allow/lpath,rpath+/proc/[0-9]*/task/[0-9]*/environ",
"allow/lpath,rpath+/proc/[0-9]*/stat*",
"allow/lpath,rpath+/proc/[0-9]*/task/[0-9]*/stat*",
"allow/ioctl+PROCMAP_QUERY",
"allow/lpath,rpath+/proc/self/maps",
"allow/lpath,rpath+/proc/self/task/[0-9]*/maps",
"allow/lpath,rpath+/proc/self/smaps*",
"allow/lpath,rpath+/proc/self/task/[0-9]*/smaps*",
"allow/lpath,rpath+/proc/self/pagemap",
"allow/lpath,rpath+/proc/self/task/[0-9]*/pagemap",
"allow/lpath,rpath+/proc/self/mounts",
"allow/lpath,rpath+/proc/self/task/[0-9]*/mounts",
"allow/lpath,rpath+/proc/self/mountinfo",
"allow/lpath,rpath+/proc/self/task/[0-9]*/mountinfo",
"allow/lpath,rpath+/proc/self/attr/***",
"allow/lpath,rpath+/proc/self/task/[0-9]*/attr/***",
"allow/lpath,rpath+/proc/self/cgroup",
"allow/lpath,rpath+/proc/self/task/[0-9]*/cgroup",
"bind-tmpfs:/tmp", "bind-tmpfs:/dev/shm", "bind-tmpfs:/var/tmp", "allow/exec,spath,net,fown+/dev/shm/**",
"allow/exec,spath,net,fown+/var/tmp/**",
"allow/exec,spath,net,fown+/tmp/**",
"allow/lock/exec,ioctl,spath,bnet+/dev/shm",
"allow/lock/exec,ioctl,spath,bnet+/var/tmp",
"allow/lock/exec,ioctl,spath,bnet+/tmp",
"allow/lpath,rpath,mktemp+/var/cache/***",
"allow/lpath,rpath,wpath,cpath,spath,tpath,exec,net,fown,fattr+/var/cache/**",
"allow/lock/rpath,wpath,cpath,spath,tpath,exec,ioctl,bnet+/var/cache",
"allow/bnet+loopback!0",
"allow/bnet+loopback!1024-65535",
"allow/lock/bnet+0",
"allow/lock/bnet+1024-65535",
"allow/lock/cnet+1024-65535",
"allow/exec,lpath,rpath,wpath,cpath,fattr+!memfd:**",
"allow/exec,lpath,rpath,wpath,cpath,fattr+!memfd-hugetlb:**",
"allow/lpath,rpath,wpath,cpath,fattr+!secretmem",
"allow/lpath,rpath+/var/db",
"allow/lpath,rpath+/var/db/paludis/***",
"lock:${SYD_PALUDIS_LOCK:-exec}", ];
pub const PROFILE_LTP: &[&str] = &[
"include_profile paludis",
"rlimit/memlock:off", "trace/allow_unsafe_chroot:false", "trace/allow_unsafe_deprecated:true", "trace/allow_unsafe_keyring:true", "trace/allow_unsafe_madvise:true", "trace/allow_unsafe_mbind:true", "trace/allow_unsafe_oob:true", "default/ioctl:allow",
"deny/ioctl-*",
"allow/net+@**",
"allow/net+any!0-65535",
];
pub const PROFILE_NIX: &[&str] = &[
"include_profile paludis",
"trace/allow_unsafe_madvise:true", "trace/allow_unsafe_vmsplice:true", "allow/all+/***",
"allow/net+@**",
"allow/net+any!0-65535",
];
pub const PROFILE_CWD: &[&str] = &["allow/all+${SYD_PWD}/***", "allow/lock/all+${SYD_PWD}"];
pub const PROFILE_HIDE: &[&str] = &["sandbox/lpath:on"];
pub const PROFILE_USER: &[&str] = &[
"include_profile linux",
"include_profile landlock",
"include_profile local",
"include_profile nomagic",
"include_profile rand",
"include_profile tty",
"sandbox/lpath:${SYD_USER_LPATH:-on}",
"tpe/negate:1",
"tpe/user_owned:1",
"tpe/gid:${SYD_GID}",
"trace/force_umask:7177",
"allow/lock/all+${SYD_HOME}",
"allow/all+${SYD_HOME}/**",
"allow/lpath,rpath+${SYD_HOME}/***",
"deny/all+${SYD_HOME}/**/.*/***",
"allow/all+${SYD_HOME}/**/.*history*",
"append+${SYD_HOME}/.*history",
];
pub const PROFILE_LINUX: &[&str] = &[
"include_profile fs",
"allow/lpath,readdir+/",
"allow/lpath,rpath,exec+/bin/***",
"allow/lpath,rpath,exec+/sbin/***",
"allow/lpath,rpath,exec+/lib*/***",
"allow/lpath,rpath,exec+/usr/***",
"allow/lpath,rpath,exec+/opt/***",
"deny/lpath,rpath,exec+/lib*/modules/***",
"allow/net/link+route", "allow/cnet+/run/nscd/socket",
"allow/cnet+/var/run/nscd/socket",
"allow/cnet+/var/lib/sss/pipes/nss",
"allow/cnet+loopback!65535", "allow/lpath,rpath+/dev",
"allow/lpath,rpath+/dev/fd",
"allow/lpath,rpath,mktemp+/dev/shm/***",
"allow/lpath,rpath,mktemp+/var/tmp/***",
"allow/lpath,rpath,mktemp+/tmp/***",
"allow/lpath,rpath,wpath,cpath,tpath,fattr+/dev/shm/**",
"allow/lpath,rpath,wpath,cpath,tpath,fattr+/var/tmp/**",
"allow/lpath,rpath,wpath,cpath,tpath,fattr+/tmp/**",
"allow/lpath,rpath,wpath+/dev/full",
"allow/lpath,rpath,wpath+/dev/zero",
"allow/lpath,rpath,wpath+/dev/null",
"allow/lpath,rpath,wpath+/dev/stdin",
"allow/lpath,rpath,wpath+/dev/stdout",
"allow/lpath,rpath,wpath+/dev/stderr",
"allow/lpath,rpath,wpath+/dev/random",
"allow/lpath,rpath,wpath+/dev/urandom",
"allow/lpath,rpath+/proc",
"allow/lpath,rpath+/proc/self/stat",
"allow/lpath,rpath+/proc/self/task/[0-9]*/stat",
"allow/lpath,rpath+/proc/self/statm",
"allow/lpath,rpath+/proc/self/task/[0-9]*/statm",
"allow/lpath,rpath+/proc/self/status",
"allow/lpath,rpath+/proc/self/task/[0-9]*/status",
"mask+/dev/random:/dev/urandom",
"mask+/proc/*info*/***:/dev/null:/var/empty",
"mask+/proc/*stat*/***:/dev/null:/var/empty",
"allow/lpath,rpath+/proc/cmdline",
"mask+/proc/cmdline",
"allow/lpath,rpath+/proc/version",
"mask+/proc/interrupts",
"mask+/proc/kcore",
"mask+/proc/keys",
"mask+/proc/acpi/***:/dev/null:/var/empty",
"mask+/proc/asound/***:/dev/null:/var/empty",
"mask+/proc/bus/***:/dev/null:/var/empty",
"mask+/proc/driver/***:/dev/null:/var/empty",
"mask+/proc/*debug*/***:/dev/null:/var/empty",
"mask+/proc/fs/***:/dev/null:/var/empty",
"mask+/proc/irq/***:/dev/null:/var/empty",
"mask+/proc/latency_*/***:/dev/null:/var/empty",
"mask+/proc/timer_*/***:/dev/null:/var/empty",
"mask+/proc/*_stats/***:/dev/null:/var/empty",
"mask+/proc/pressure/***:/dev/null:/var/empty",
"mask+/proc/sched*/***:/dev/null:/var/empty",
"mask+/proc/scsi/***:/dev/null:/var/empty",
"mask+/proc/sys*/***:/dev/null:/var/empty",
"mask+/proc/tty/***:/dev/null:/var/empty",
"allow/lpath,rpath+/proc/sys",
"allow/lpath,rpath+/proc/sys/kernel",
"allow/lpath,rpath+/proc/sys/kernel/random",
"allow/lpath,rpath+/proc/sys/kernel/random/*id",
"mask+/proc/sys/kernel/random/boot_id:/proc/sys/kernel/random/uuid",
"mask+/proc/sys/kernel/random/uuid:/proc/sys/kernel/random/uuid",
"mask+/sys/dev/***:/dev/null:/var/empty",
"mask+/sys/devices/***:/dev/null:/var/empty",
"mask+/sys/firmware/***:/dev/null:/var/empty",
"mask+/sys/fs/***:/dev/null:/var/empty",
"mask+/sys/kernel/notes:/dev/null:/var/empty",
"mask+/boot/***:/dev/null:/var/empty",
"allow/lpath,rpath+/proc/self",
"allow/lpath,rpath+/proc/thread-self",
"allow/lpath,rpath+/proc/self/comm",
"allow/lpath,rpath+/proc/self/task/[0-9]*/comm",
"allow/lpath,rpath+/proc/self/cmdline",
"allow/lpath,rpath+/proc/self/task/[0-9]*/cmdline",
"allow/lpath,rpath+/proc/self/fd",
"allow/lpath,rpath+/proc/self/fdinfo",
"allow/lpath,rpath+/proc/self/task",
"allow/lpath,rpath+/proc/self/task/[0-9]*",
"allow/lpath,rpath+/proc/self/task/[0-9]*/fd",
"allow/lpath,rpath+/proc/self/task/[0-9]*/fdinfo",
"allow/lpath,rpath+/proc/self/cwd",
"allow/lpath,rpath+/proc/self/task/[0-9]*/cwd",
"allow/lpath,rpath+/proc/self/exe",
"allow/lpath,rpath+/proc/self/task/[0-9]*/exe",
"allow/lpath,rpath+/proc/self/root",
"allow/lpath,rpath+/proc/self/task/[0-9]*/root",
"allow/lpath,rpath+/proc/self/fdinfo/[0-9]*",
"allow/lpath,rpath+/proc/self/task/[0-9]*/fdinfo/[0-9]*",
"allow/lpath,rpath,wpath+/proc/self/fd/[0-9]*",
"allow/lpath,rpath,wpath+/proc/self/task/[0-9]*/fd/[0-9]*",
r"allow/lpath,rpath,wpath+/proc/self/fd/anon_inode:\[pidfd\]",
r"allow/lpath,rpath,wpath+/proc/self/fd/pipe:\[[0-9]*\]",
r"allow/lpath,rpath,wpath+/proc/self/fd/socket:\[[0-9]*\]",
r"allow/lpath,rpath,wpath+/proc/self/task/[0-9]*/fd/anon_inode:\[pidfd\]",
r"allow/lpath,rpath,wpath+/proc/self/task/[0-9]*/fd/pipe:\[[0-9]*\]",
r"allow/lpath,rpath,wpath+/proc/self/task/[0-9]*/fd/socket:\[[0-9]*\]",
"allow/lpath,rpath+/run",
"allow/lpath,rpath+/run/systemd",
"allow/lpath,rpath+/run/systemd/resolve",
"allow/lpath,rpath+/run/systemd/resolve/*.conf",
"allow/lpath,rpath+/var",
"allow/lpath,rpath+/var/lib/sss/mc/passwd", "allow/lpath,rpath+/var/lib/sss/mc/group", "allow/lpath,rpath,chroot+/var/empty", "allow/lpath,rpath+/etc",
"allow/lpath,rpath+/etc/DIR_COLORS",
"allow/lpath,rpath+/etc/GREP_COLORS",
"allow/lpath,rpath+/etc/bash*/***",
"allow/lpath,rpath+/etc/alternatives/***",
"allow/lpath,rpath+/etc/ca-certificates/***",
"allow/lpath,rpath+/etc/env.d/***",
"allow/lpath,rpath+/etc/groff/***",
"allow/lpath,rpath+/etc/ld.so.conf.d/***",
"allow/lpath,rpath+/etc/environment",
"allow/lpath,rpath+/etc/ethertypes",
"allow/lpath,rpath+/etc/gai.conf",
"allow/lpath,rpath+/etc/group",
"allow/lpath,rpath+/etc/hosts",
"allow/lpath,rpath+/etc/inputrc",
"allow/lpath,rpath+/etc/issue",
"allow/lpath,rpath+/etc/ld*",
"allow/lpath,rpath+/etc/locale.alias",
"allow/lpath,rpath+/etc/locale.conf",
"allow/lpath,rpath+/etc/localtime",
"mask+/etc/localtime:/usr/share/zoneinfo/UTC", "mask+/usr/share/zoneinfo/**:/usr/share/zoneinfo/UTC:/var/empty", "allow/lpath,rpath+/etc/machine-id", "allow/lpath,rpath+/etc/hostid", "allow/lpath,rpath+/var/adm/hostid", "allow/lpath,rpath+/etc/man_db.conf",
"allow/lpath,rpath+/etc/manpath.config",
"allow/lpath,rpath+/etc/nanorc",
"allow/lpath,rpath+/etc/**/nsswitch.conf",
"allow/lpath,rpath+/etc/passwd",
"allow/lpath,rpath+/etc/php*",
"allow/lpath,rpath+/etc/php*/**/*.ini",
"allow/lpath,rpath+/etc/profile*/***",
"deny/lpath,rpath+/etc/profile*/*systemd*", "allow/lpath,rpath+/etc/services",
"allow/lpath,rpath+/etc/*-release",
"allow/lpath,rpath+/etc/protocols",
"allow/lpath,rpath+/etc/resolv.conf",
"allow/lpath,rpath+/etc/skel/***",
"allow/lpath,rpath+/etc/ssl",
"allow/lpath,rpath+/etc/ssl/certs/***",
"allow/lpath,rpath+/etc/ssl/misc/***",
"allow/lpath,rpath+/etc/ssl/openssl.cnf",
"allow/lpath,rpath+/etc/terminfo/***",
"allow/lpath,rpath+/etc/zsh/***",
"allow/lpath+/home",
"allow/net+!unnamed",
];
pub const PROFILE_FS: &[&str] = &[
"sandbox/fs:on",
"allow/fs+all",
"deny/fs+aafs,bpf_fs,securityfs,selinux,smack",
"deny/fs+binfmt_misc,debugfs,pstorefs,tracefs",
"deny/fs+cgroup,cgroup2,nsfs,pid_fd,rdtgroup",
"deny/fs+configfs,devmem,efivarfs,hostfs,inodefs,openprom",
"deny/fs+daxfs,secretmem",
"deny/fs+bdevfs,binderfs,fusectl,usbdevfs,xenfs,zonefs",
"deny/fs+nfsd,rpc_pipefs",
];
pub const PROFILE_TTY: &[&str] = &[
"include_profile tty_native",
"allow/lock/read,ioctl,write+/dev/tty",
"allow/lock/read,ioctl,write+/dev/ptmx",
"allow/lock/read,ioctl,write+${SYD_TTY}",
"allow/lock/rpath,ioctl,write+/dev/pts",
"allow/lpath,rpath,wpath+/dev/tty",
"allow/lpath,rpath,wpath+/dev/ptmx",
"allow/lpath,rpath,wpath+${SYD_TTY}",
"allow/lpath,rpath+/dev/pts",
"allow/lpath,rpath,wpath+/dev/pts/ptmx",
"allow/lpath,rpath,wpath+/dev/pts/[0-9]*",
];
pub const PROFILE_TTY_NATIVE: &[&str] = &[
"allow/ioctl+TC[GS]ET*",
"allow/ioctl+TIOC*",
"allow/ioctl+TCFLSH",
"allow/ioctl+TCSBRK",
"allow/ioctl+TCSBRKP",
"allow/ioctl+TCXONC",
];
pub const PROFILE_KVM: &[&str] = &[
"allow/wpath+/dev/kvm",
"include_profile kvm_native",
"allow/ioctl+KVM_*",
];
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
pub const PROFILE_KVM_NATIVE: &[&str] = &[
"allow/ioctl+0x4680aea3", "allow/ioctl+0x4010aeab", "allow/ioctl+0x4010aeac", "allow/ioctl+0xc008aeb0", "allow/ioctl+5", "allow/ioctl+0x8020aeaf", "allow/ioctl+0x4020aeae", "allow/ioctl+0x4040aec2", "allow/ioctl+0x6030000000100042", "allow/ioctl+0x6030000000100044", "allow/ioctl+0x6030000000100000", "allow/ioctl+0x6030000000100002", "allow/ioctl+0x6030000000100004", "allow/ioctl+0x6030000000100006", "allow/ioctl+0x6030000000100010", "allow/ioctl+0x6030000000100024", "allow/ioctl+0x6030000000100040", "allow/ioctl+0x603000000013c510", "allow/ioctl+0x603000000013c102", "allow/ioctl+0x603000000013c100", "allow/ioctl+0x603000000013c101", "allow/ioctl+0x603000000013c080", "allow/ioctl+0x603000000013c082", "allow/ioctl+0x603000000013c600", "allow/ioctl+0x603000000013df1a", "allow/ioctl+0x603000000013df00", "allow/ioctl+0x6030000000138012", "allow/ioctl+0x603000000013c708", "allow/ioctl+0x603000000013c684", ];
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub const PROFILE_KVM_NATIVE: &[&str] = &[
"allow/ioctl+0x0", "allow/ioctl+0x0", "allow/ioctl+0xc004ae02", "allow/ioctl+0xc004ae0a", "allow/ioctl+0x4040ae77", "allow/ioctl+0xc208ae62", "allow/ioctl+0x4208ae63", "allow/ioctl+0x4030ae7b", "allow/ioctl+0x8030ae7c", "allow/ioctl+0x8070ae9f", "allow/ioctl+0x4070aea0", "allow/ioctl+0xc008aeba", "allow/ioctl+0x8010aebb", "allow/ioctl+0x8010aebc", "allow/ioctl+0xc018ae85", "allow/ioctl+0x81a0ae8c", "allow/ioctl+0x41a0ae8d", "allow/ioctl+0x8400ae8e", "allow/ioctl+0x4400ae8f", "allow/ioctl+0x4008ae90", "allow/ioctl+0xc008ae91", "allow/ioctl+0x8080aea1", "allow/ioctl+0x4080aea2", "allow/ioctl+0x9000aea4", "allow/ioctl+0x5000aea5", "allow/ioctl+0x8188aea6", "allow/ioctl+0x4188aea7", "allow/ioctl+0xaead", ];
#[cfg(not(any(
target_arch = "arm",
target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64"
)))]
pub const PROFILE_KVM_NATIVE: &[&str] = &[];
pub const PROFILE_NIX_STORE: &[&str] = &["allow/lpath,rpath,exec+/nix/store/**"];
pub const EBPF_SYSCALLS: &[&str] = &["bpf"];
pub const KILL_SYSCALLS: &[&str] = &[
"kill",
"rt_sigqueueinfo",
"rt_tgsigqueueinfo",
"tgkill",
"tkill",
];
pub const MOUNT_SYSCALLS: &[&str] = &[
"fsconfig",
"fsmount",
"fsopen",
"fspick",
"listmount",
"mount",
"mount_setattr",
"move_mount",
"open_tree",
"open_tree_attr",
"statmount",
"umount",
"umount2",
];
pub const MSGQUEUE_SYSCALLS: &[&str] = &[
"mq_getsetattr",
"mq_notify",
"mq_open",
"mq_timedreceive",
"mq_timedreceive_time64",
"mq_timedsend",
"mq_timedsend_time64",
"mq_unlink",
];
pub const SHM_SYSCALLS: &[&str] = &[
"ipc",
"msgget",
"msgsnd",
"msgrcv",
"msgctl",
"semget",
"semop",
"semctl",
"semtimedop",
"semtimedop_time64",
"shmat",
"shmctl",
"shmdt",
"shmget",
];
pub const NICE_SYSCALLS: &[&str] = &[
"ioprio_set",
"sched_setattr",
"sched_setscheduler",
"sched_setparam",
"setpriority",
];
pub const PAGE_CACHE_SYSCALLS: &[&str] = &["cachestat", "mincore"];
pub const PERF_SYSCALLS: &[&str] = &[
"lookup_dcookie",
"perf_event_open",
"rtas",
"s390_runtime_instr",
"sys_debug_setcontext",
];
pub const PTRACE_SYSCALLS: &[&str] = &[
"kcmp",
"pidfd_getfd",
"ptrace",
"process_madvise",
"process_vm_readv",
"process_vm_writev",
];
pub const EPOLL_SYSCALLS: &[&str] = &[
"epoll_ctl",
"epoll_ctl_old",
"epoll_wait",
"epoll_wait_old",
"epoll_pwait",
"epoll_pwait2",
];
pub const UTS_SYSCALLS: &[&str] = &["setdomainname", "sethostname"];
pub const GETID_SYSCALLS: &[&str] = &[
"getuid",
"getuid32",
"getgid",
"getgid32",
"geteuid",
"geteuid32",
"getegid",
"getegid32",
"getresuid",
"getresuid32",
"getresgid",
"getresgid32",
"getgroups",
"getgroups32",
];
pub const FADVISE_SYSCALLS: &[&str] = &["arm_fadvise64_64", "fadvise64", "fadvise64_64"];
pub const FUTEX_SYSCALLS: &[&str] = &[
"futex",
"futex_requeue",
"futex_time64",
"futex_wait",
"futex_waitv",
"futex_wake",
"swapcontext",
"sys_debug_swapcontext",
];
pub const SET_ID_SYSCALLS: &[&str] = &[
"setuid",
"setuid32",
"setgid",
"setgid32",
"setreuid",
"setreuid32",
"setregid",
"setregid32",
"setresuid",
"setresuid32",
"setresgid",
"setresgid32",
"setgroups",
"setgroups32",
];
pub const VDSO_SYSCALLS: &[&str] = &[
"clock_getres",
"clock_getres_time64",
"clock_gettime",
"clock_gettime64",
"getcpu",
"getrandom",
"gettimeofday",
"time",
"uretprobe", #[cfg(target_arch = "riscv64")]
"riscv_hwprobe",
];
#[cfg(all(
not(coverage),
not(feature = "prof"),
not(target_os = "android"),
not(target_arch = "riscv64"),
target_env = "gnu",
target_page_size_4k,
target_pointer_width = "64"
))]
pub const ALLOC_SYSCALLS: &[&str] = &["pkey_alloc", "pkey_free", "pkey_mprotect"];
#[cfg(not(all(
not(coverage),
not(feature = "prof"),
not(target_os = "android"),
not(target_arch = "riscv64"),
target_env = "gnu",
target_page_size_4k,
target_pointer_width = "64"
)))]
pub const ALLOC_SYSCALLS: &[&str] = &[];
pub const HOOK_SYSCALLS: &[&str] = &[
"accept",
"accept4",
"bind",
"connect",
"getpeername",
"getsockname",
"getsockopt",
"recvfrom",
"recvmsg",
"recvmmsg",
"recvmmsg_time64",
"sendto",
"sendmsg",
"sendmmsg",
"socket",
"socketcall",
"socketpair",
"execve",
"execveat",
"getdents64",
"stat",
"access",
"fstat",
"fstat64",
"fstatat64",
"lstat",
"newfstatat",
"stat64",
"statx",
"faccessat",
"faccessat2",
"chdir",
"fchdir",
"chmod",
"fchmod",
"fchmodat",
"fchmodat2",
"fchown",
"fchown32",
"chown",
"lchown",
"fchownat",
"creat",
"link",
"symlink",
"unlink",
"linkat",
"symlinkat",
"unlinkat",
"mkdir",
"rmdir",
"mkdirat",
"mknod",
"mknodat",
"open",
"openat",
"openat2",
"readlink",
"readlinkat",
"rename",
"renameat",
"renameat2",
"utime",
"utimes",
"futimesat",
"utimensat",
"utimensat_time64",
"truncate",
"truncate64",
"ftruncate",
"ftruncate64",
"getxattr",
"getxattrat",
"fgetxattr",
"lgetxattr",
"setxattr",
"setxattrat",
"fsetxattr",
"lsetxattr",
"listxattr",
"listxattrat",
"flistxattr",
"llistxattr",
"removexattr",
"removexattrat",
"fremovexattr",
"lremovexattr",
"ioctl",
"prctl",
"kill",
"tkill",
"tgkill",
"rt_sigqueueinfo",
"rt_tgsigqueueinfo",
"pidfd_open",
"brk",
"mmap",
"mmap2",
"mremap",
"setrlimit",
"prlimit64",
"statfs",
"statfs64",
"fstatfs",
"fstatfs64",
"fallocate",
"uname",
"fanotify_mark",
"inotify_add_watch",
"memfd_create",
"fcntl",
"fcntl64",
"sysinfo",
"sigaction",
"rt_sigaction",
"chroot",
"syslog",
];
pub(crate) const HOOK_SCKCALLS: &[u8] = &[
0x1, 0x2, 0x3, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, ];
pub const STAT_SYSCALLS: &[&str] = &[
"access",
"faccessat",
"faccessat2",
"fstatat64",
"fstatfs",
"fstatfs64",
"lstat",
"lstat64",
"newfstatat",
"stat",
"stat64",
"statfs",
"statfs64",
"statx",
];
pub const RENAME_SYSCALLS: &[&str] = &["link", "linkat", "rename", "renameat", "renameat2"];
pub const TRUNCATE_SYSCALLS: &[&str] = &[
"fallocate",
"ftruncate",
"ftruncate64",
"truncate",
"truncate64",
];
pub const CONNECT_SYSCALLS: &[&str] = &["connect", "send", "sendmmsg", "sendmsg", "sendto"];
pub const CPU_SYSCALLS: &[&str] = &[
"modify_ldt",
"subpage_prot",
"switch_endian",
"vm86",
"vm86old",
];
pub const KEYRING_SYSCALLS: &[&str] = &["add_key", "keyctl", "request_key"];
pub const PKEY_SYSCALLS: &[&str] = &["pkey_alloc", "pkey_free", "pkey_mprotect"];
pub const DEAD_SYSCALLS: &[&str] = &[
"_sysctl", "acct",
"create_module",
"delete_module",
"finit_module",
"get_kernel_syms",
"init_module",
"ioperm",
"iopl",
"kexec_file_load",
"kexec_load",
"lsm_get_self_attr",
"lsm_set_self_attr",
"lsm_list_modules",
"migrate_pages",
"move_pages",
"name_to_handle_at",
"nfsservctl",
"pciconfig_iobase",
"pciconfig_read",
"pciconfig_write",
"query_module",
"quotactl",
"quotactl_fd",
"reboot",
"swapoff",
"swapon",
"sysfs",
"uselib",
"userfaultfd",
"vhangup",
];
pub const DEPRECATED_SYSCALLS: &[&str] = &[
"remap_file_pages",
"setfsgid",
"setfsgid32",
"setfsuid",
"setfsuid32",
"stime",
"ustat",
];
pub const TIME_SYSCALLS: &[&str] = &[
"adjtimex",
"clock_adjtime",
"clock_adjtime64",
"clock_settime",
"clock_settime64",
"settimeofday",
];
pub const SYNC_SYSCALLS: &[&str] = &["sync", "syncfs"];
pub const IOURING_SYSCALLS: &[&str] = &["io_uring_enter", "io_uring_register", "io_uring_setup"];
#[cfg(feature = "kcov")]
pub const KCOV_SYSCALLS: &[&str] = &["fdatasync", "pread64", "pwrite64"];
#[cfg(not(feature = "kcov"))]
pub const KCOV_SYSCALLS: &[&str] = &[];
#[cfg(feature = "prof")]
pub const PROF_SYSCALLS: &[&str] = &["setitimer"];
#[cfg(not(feature = "prof"))]
pub const PROF_SYSCALLS: &[&str] = &[];
pub const SAFE_SYSCALLS: &[&str] = &[
"_llseek",
"_newselect",
"alarm",
"arch_prctl", "arm_fadvise64_64",
"arm_sync_file_range",
"atomic_barrier",
"atomic_cmpxchg_32",
"breakpoint", "cacheflush", "capget",
"capset",
"clock_nanosleep",
"clock_nanosleep_time64",
"clone", "close",
"close_range",
"copy_file_range",
"dup",
"dup2",
"dup3",
"epoll_create",
"epoll_create1",
"epoll_ctl",
"epoll_ctl_old",
"epoll_pwait",
"epoll_pwait2",
"epoll_wait",
"epoll_wait_old",
"eventfd",
"eventfd2",
"exit",
"exit_group",
"fadvise64",
"fadvise64_64",
"fanotify_init",
"fdatasync",
"flock",
"fork",
"fsync",
"getpagesize",
"get_mempolicy",
"get_robust_list",
"get_thread_area",
"getcwd",
"getitimer",
"getpgid",
"getpgrp",
"getpid",
"getpmsg",
"getppid",
"getpriority",
"getresgid",
"getresuid",
"getrlimit",
"getrusage",
"getsid",
"gettid",
"inotify_init",
"inotify_init1",
"inotify_rm_watch",
"io_cancel",
"io_destroy",
"io_getevents",
"io_pgetevents",
"io_pgetevents_time64",
"io_setup",
"io_submit",
"ioprio_get",
"landlock_add_rule",
"landlock_create_ruleset",
"landlock_restrict_self",
"listen",
"lseek",
"map_shadow_stack",
"membarrier",
"mlock",
"mlock2",
"mlockall",
"mprotect",
"mseal",
"msync",
"munlock",
"munlockall",
"munmap",
"nanosleep",
"pause",
"pidfd_send_signal",
"pipe",
"poll",
"ppoll",
"ppoll_time64",
"pread64",
"preadv",
"preadv2",
"process_mrelease",
"pselect6",
"pselect6_time64",
"pwrite64",
"pwritev",
"pwritev2", "read",
"readahead",
"readv",
"recv",
"restart_syscall",
#[cfg(target_arch = "riscv64")]
"riscv_flush_icache",
"rt_sigpending",
"rt_sigprocmask",
"rt_sigsuspend",
"rt_sigtimedwait",
"rt_sigtimedwait_time64",
"s390_pci_mmio_read",
"s390_pci_mmio_write",
"s390_runtime_instr",
"sched_get_priority_max",
"sched_get_priority_min",
"sched_getaffinity",
"sched_getattr",
"sched_rr_get_interval",
"sched_rr_get_interval_time64",
"sched_getparam",
"sched_getscheduler",
"sched_setaffinity",
"sched_yield",
"select",
"send",
"sendfile",
"sendfile64",
"set_mempolicy",
"set_mempolicy_home_node",
"set_robust_list",
"set_thread_area",
"set_tid_address",
"setitimer",
"setns", "setpgid",
"setsid",
"setsockopt",
"set_tls", "shutdown",
"signal",
"sigaltstack",
"signalfd",
"signalfd4",
"sigpending",
"sigprocmask",
"sigsuspend",
"splice",
"sync_file_range",
"sync_file_range2", "tee",
"timer_create",
"timer_delete",
"timer_getoverrun",
"timer_gettime",
"timer_gettime64",
"timer_settime",
"timer_settime64",
"timerfd_create",
"timerfd_gettime",
"timerfd_gettime64",
"timerfd_settime",
"timerfd_settime64",
"times",
"ugetrlimit",
"umask",
"unshare", "vfork",
"wait4",
"waitid",
"waitpid",
"write",
"writev",
];
pub const EMU_SYSCALLS: &[&str] = &[
"_llseek",
"brk",
"clock_nanosleep",
"exit",
"exit_group",
"fanotify_mark",
"fgetxattr",
"flistxattr",
"fstatfs",
"fstatfs64",
"get_robust_list",
"getpgid",
"getpgrp",
"getpid",
"getsockname",
"getsockopt",
"gettid",
"getxattrat",
"inotify_add_watch",
"kcmp",
"landlock_create_ruleset",
"landlock_restrict_self",
"lgetxattr",
"listxattrat",
"llistxattr",
"lseek",
"lstat",
"mlock",
"mremap",
"munlock",
"munmap",
"nanosleep",
"process_mrelease", "process_vm_readv",
"process_vm_writev",
"read",
"readv",
"restart_syscall",
"rseq",
"rt_sigprocmask",
"rt_sigtimedwait", "rt_sigtimedwait_time64", "sched_getaffinity",
"sched_yield",
"set_robust_list",
"sigaltstack",
"sigprocmask",
"tee",
"tgkill",
"tkill",
"timer_create", "timer_delete", "timer_settime", "timer_settime64", "waitid",
"sigreturn",
"rt_sigreturn",
"readlinkat",
"statx", "write",
];
pub const EMU_LOCK_SYSCALLS: &[&str] = &["clone", "clone3", "unshare"];
pub const EMU_FCNTL_OPS: &[u64] = &[
libc::F_GETFD as u64,
libc::F_SETFD as u64,
libc::F_GETFL as u64,
libc::F_SETFL as u64,
libc::F_OFD_SETLK as u64,
libc::F_OFD_SETLKW as u64,
libc::F_ADD_SEALS as u64,
libc::F_GET_SEALS as u64,
];
pub const EMU_PRCTL_OPS: &[KeyValue] = &[
("PR_SET_NAME", 15), ("PR_SET_VMA", 0x53564d41), ("PR_SET_NO_NEW_PRIVS", 38), ("PR_GET_NO_NEW_PRIVS", 39), ];
pub const EMU_PRCTL_OPS_SAFESETID: &[KeyValue] = &[("PR_CAP_AMBIENT", 47), ("PR_CAPBSET_DROP", 24)];
pub const INT_SYSCALLS: &[&str] = &[
"clock_nanosleep",
"exit",
"exit_group", "getpid",
"gettid",
"brk",
"mremap",
"munmap",
"nanosleep",
"lseek", "_llseek", "read",
"restart_syscall",
"rt_sigprocmask",
"rseq",
"sched_yield",
"sigaltstack", "sigprocmask", ];
pub const OUT_SYSCALLS: &[&str] = &[
"clock_nanosleep",
"exit",
"exit_group", "getpid",
"gettid",
"brk",
"mremap",
"munmap",
"nanosleep",
"restart_syscall",
"rt_sigprocmask",
"rseq",
"sched_yield",
"sigaltstack", "sigprocmask", ];
pub const INT_FCNTL_OPS: &[u64] = &[
libc::F_GETFD as u64,
libc::F_SETFD as u64,
libc::F_OFD_SETLK as u64,
libc::F_OFD_SETLKW as u64,
];
pub const OUT_FCNTL_OPS: &[u64] = &[
libc::F_GETFD as u64,
libc::F_SETFD as u64,
libc::F_OFD_SETLK as u64,
libc::F_OFD_SETLKW as u64,
];
pub const INT_PRCTL_OPS: &[KeyValue] = &[("PR_SET_VMA", 0x53564d41)];
pub const IPC_SYSCALLS: &[&str] = &[
"close",
"exit",
"getpid",
"gettid",
"getsockopt",
"accept4",
"recvmsg",
"sendmsg",
"brk",
"mremap",
"mseal",
"munmap",
"restart_syscall",
"rt_sigprocmask",
"rseq",
"sched_yield",
"sigaltstack", "sigprocmask", ];
pub const IPC_FCNTL_OPS: &[u64] = &[
libc::F_GETFD as u64,
libc::F_SETFD as u64,
libc::F_OFD_SETLK as u64,
libc::F_OFD_SETLKW as u64,
];
pub const IPC_PRCTL_OPS: &[KeyValue] = &[("PR_SET_VMA", 0x53564d41)];
pub const AES_SYSCALLS: &[&str] = &[
"_llseek",
"brk",
"clock_nanosleep",
"exit",
"fremovexattr",
"get_robust_list",
"getpid",
"getsockopt",
"gettid",
"landlock_create_ruleset",
"landlock_restrict_self",
"lseek",
"mlock",
"mremap",
"munlock",
"munmap",
"nanosleep",
"restart_syscall",
"rseq",
"rt_sigprocmask",
"sched_getaffinity",
"sched_yield",
"set_robust_list",
"sigaltstack",
"sigprocmask",
"splice",
"tee",
];
pub const AES_FCNTL_OPS: &[u64] = &[
libc::F_GETFD as u64,
libc::F_SETFD as u64,
libc::F_ADD_SEALS as u64,
libc::F_OFD_SETLK as u64, libc::F_OFD_SETLKW as u64,
];
pub const AES_PRCTL_OPS: &[KeyValue] = &[
("PR_SET_NAME", 15), ("PR_SET_VMA", 0x53564d41), ];
pub const MAIN_SYSCALLS: &[&str] = &[
"_llseek",
"brk",
"clock_nanosleep",
"exit_group",
"fstatfs",
"fstatfs64",
"get_robust_list",
"getpgid",
"getpgrp",
"getpid",
"gettid",
"kill", "lseek",
"mremap",
"mseal", "munlock",
"munmap",
"nanosleep",
"process_mrelease", "process_vm_readv", "process_vm_writev", "read",
"readv",
"restart_syscall",
"rseq",
"rt_sigprocmask",
"sched_getaffinity",
"sched_yield",
"set_robust_list",
"sigaltstack",
"sigprocmask",
"statx", "sysinfo", "tgkill",
"tkill",
"waitid",
"readlinkat",
];
pub const MAIN_FCNTL_OPS: &[u64] = &[
libc::F_GETFD as u64,
libc::F_SETFD as u64,
libc::F_GETFL as u64,
libc::F_SETFL as u64,
libc::F_OFD_SETLK as u64,
libc::F_OFD_SETLKW as u64,
];
pub const MAIN_PRCTL_OPS: &[KeyValue] = &[("PR_SET_VMA", 0x53564d41)];
pub const PTY_FCNTL_OPS: &[u64] = &[libc::F_GETFD as u64, libc::F_GETFL as u64];
pub const PTY_PRCTL_OPS: &[KeyValue] = &[("PR_SET_VMA", 0x53564d41)];
pub const TOR_FCNTL_OPS: &[u64] = &[
libc::F_GETFD as u64,
libc::F_SETFD as u64,
libc::F_GETFL as u64,
libc::F_SETFL as u64,
];
pub const TOR_PRCTL_OPS: &[KeyValue] = &[("PR_SET_VMA", 0x53564d41)];
pub const WORDEXP_SYSCALLS: &[&str] = &[
"_llseek",
"_newselect",
"access",
"alarm",
"arch_prctl", "arm_fadvise64_64",
"arm_sync_file_range",
"breakpoint", "brk",
"cacheflush", "capget",
"chdir",
"clock_nanosleep",
"clock_nanosleep_time64",
"clone",
"clone3",
"close",
"close_range",
"dup",
"dup2",
"dup3",
"epoll_create",
"epoll_create1",
"epoll_ctl",
"epoll_ctl_old",
"epoll_pwait",
"epoll_pwait2",
"epoll_wait",
"epoll_wait_old",
"eventfd",
"eventfd2",
"execve",
"execveat",
"exit",
"exit_group",
"faccessat",
"faccessat2",
"fadvise64",
"fadvise64_64",
"fchdir",
"fcntl",
"fcntl64",
"fdatasync",
"flock",
"fork",
"fstat",
"fstat64",
"fstatfs",
"fstatfs64",
"fsync",
"futex",
"futex_time64",
"futex_waitv",
"get_mempolicy",
"get_robust_list",
"get_thread_area",
"getcwd",
"getitimer",
"getpgid",
"getpgrp",
"getpid",
"getpmsg",
"getppid",
"getpriority",
"getrlimit",
"getrusage",
"getsid",
"gettid",
"io_cancel",
"io_destroy",
"io_getevents",
"io_pgetevents",
"io_pgetevents_time64",
"io_setup",
"io_submit",
"ioprio_get",
"ioprio_set",
"landlock_add_rule",
"landlock_create_ruleset",
"landlock_restrict_self",
"lseek",
"lstat",
"membarrier",
"mmap",
"mmap2",
"mprotect",
"mremap",
"msync",
"munlock",
"munlockall",
"munmap",
"nanosleep",
"newfstatat",
"oldfstat",
"open",
"openat",
"openat2",
"pause",
"pipe",
"pipe2",
"poll",
"ppoll",
"ppoll_time64",
"pread64",
"preadv",
"preadv2",
"pselect6",
"pselect6_time64",
"pwrite64",
"pwritev",
"pwritev2",
"read",
"readahead",
"readlink",
"readlinkat",
"readv",
"remap_file_pages",
"restart_syscall",
"rseq",
"rt_sigaction",
"rt_sigpending",
"rt_sigprocmask",
"rt_sigreturn",
"rt_sigsuspend",
"rt_sigtimedwait",
"rt_sigtimedwait_time64",
"sched_yield",
"seccomp",
"select",
"set_robust_list",
"set_thread_area",
"set_tid_address",
"set_tls", "setitimer",
"setpgid",
"setsid",
"sigaction",
"sigaltstack",
"signal",
"signalfd",
"signalfd4",
"sigpending",
"sigprocmask",
"sigreturn",
"sigsuspend",
"splice",
"stat",
"stat64",
"statx",
"tee",
"timer_create",
"timer_delete",
"timer_getoverrun",
"timer_gettime",
"timer_gettime64",
"timer_settime",
"timer_settime64",
"timerfd_create",
"timerfd_gettime",
"timerfd_gettime64",
"timerfd_settime",
"timerfd_settime64",
"times",
"ugetrlimit",
"umask",
"vfork",
"wait4",
"waitid",
"waitpid",
"write",
"writev",
];
pub const OCI_SYSCALLS: &[&str] = &[
"kcmp",
"pidfd_getfd",
"process_mrelease",
"process_vm_readv",
"process_vm_writev",
"ptrace",
"syslog",
"unshare",
];
pub const SYSCALL_PTR_ARGS: &[(&str, &[u32])] = &[
("_llseek", &[3]),
("_newselect", &[1, 2, 3, 4]),
("accept", &[1, 2]),
("accept4", &[1, 2]),
("access", &[0]),
("add_key", &[0, 1, 2]),
("adjtimex", &[0]),
("arch_prctl", &[1]),
("bind", &[1]),
("bpf", &[1]),
("brk", &[0]),
("cacheflush", &[0, 1]),
("capget", &[0, 1]),
("capset", &[0, 1]),
("chdir", &[0]),
("chmod", &[0]),
("chown", &[0]),
("chroot", &[0]),
("clock_adjtime", &[1]),
("clock_adjtime64", &[1]),
("clock_getres", &[1]),
("clock_getres_time64", &[1]),
("clock_gettime", &[1]),
("clock_gettime64", &[1]),
("clock_nanosleep", &[2, 3]),
("clock_nanosleep_time64", &[2, 3]),
("clock_settime", &[1]),
("clock_settime64", &[1]),
("clone", &[1, 2, 3, 4]),
("clone3", &[0]),
("connect", &[1]),
("copy_file_range", &[1, 3]),
("creat", &[0]),
("epoll_ctl", &[3]),
("epoll_ctl_old", &[3]),
("epoll_pwait", &[1, 4]),
("epoll_pwait2", &[1, 3, 4]),
("epoll_wait", &[1]),
("epoll_wait_old", &[1]),
("execve", &[0, 1, 2]),
("execveat", &[1, 2, 3]),
("faccessat", &[1]),
("faccessat2", &[1]),
("fanotify_mark", &[4]),
("fchmodat", &[1]),
("fchmodat2", &[1]),
("fchownat", &[1]),
("fgetxattr", &[1, 2]),
("flistxattr", &[1]),
("fremovexattr", &[1]),
("fsetxattr", &[1, 2]),
("fstat", &[1]),
("fstat64", &[1]),
("fstatat64", &[1, 2]),
("fstatfs", &[1]),
("fstatfs64", &[1]),
("futex", &[0]),
("futimesat", &[1, 2]),
("get_mempolicy", &[1]),
("get_robust_list", &[1, 2]),
("get_thread_area", &[0]),
("getcpu", &[0, 1, 2]),
("getcwd", &[0]),
("getdents", &[1]),
("getdents64", &[1]),
("getgroups", &[1]),
("getgroups32", &[1]),
("getitimer", &[1]),
("getpeername", &[1, 2]),
("getrandom", &[0]),
("getresgid", &[0, 1, 2]),
("getresuid", &[0, 1, 2]),
("getrlimit", &[1]),
("getrusage", &[1]),
("getsockname", &[1, 2]),
("getsockopt", &[3, 4]),
("gettimeofday", &[0, 1]),
("getxattr", &[0, 1, 2]),
("getxattrat", &[1, 3]),
("inotify_add_watch", &[1]),
("io_cancel", &[1, 2]),
("io_getevents", &[3, 4]),
("io_pgetevents", &[3, 4, 5]),
("io_pgetevents_time64", &[3, 4, 5]),
("io_setup", &[1]),
("io_submit", &[2]),
("io_uring_enter", &[4]),
("io_uring_register", &[2]),
("io_uring_setup", &[1]),
("kexec_file_load", &[3]),
("kexec_load", &[2]),
("keyctl", &[]), ("landlock_add_rule", &[2]),
("landlock_create_ruleset", &[0]),
("lchown", &[0]),
("lgetxattr", &[0, 2]),
("link", &[0, 1]),
("linkat", &[1, 3]),
("listxattr", &[0, 1]),
("listxattrat", &[1, 2]),
("llistxattr", &[0, 1]),
("lookup_dcookie", &[1]),
("lremovexattr", &[0]),
("lsetxattr", &[0, 2]),
("lstat", &[0, 1]),
("lstat64", &[0, 1]),
("madvise", &[0]),
("map_shadow_stack", &[0]),
("mbind", &[0, 3]),
("memfd_create", &[0]),
("migrate_pages", &[2, 3]),
("mincore", &[0, 2]),
("mkdir", &[0]),
("mkdirat", &[1]),
("mknod", &[0]),
("mknodat", &[1]),
("mlock", &[0]),
("mlock2", &[0]),
("mmap", &[0]),
("mmap2", &[0]),
("modify_ldt", &[1]),
("mount", &[0, 1, 2, 4]),
("mount_setattr", &[1, 3]),
("move_pages", &[2, 3, 4]),
("mprotect", &[0]),
("mq_getsetattr", &[1, 2]),
("mq_notify", &[1]),
("mq_open", &[0, 3]),
("mq_timedreceive", &[1, 3, 4]),
("mq_timedreceive_time64", &[1, 3, 4]),
("mq_timedsend", &[1, 4]),
("mq_timedsend_time64", &[1, 4]),
("mq_unlink", &[0]),
("mremap", &[0, 4]),
("mseal", &[0]),
("msgctl", &[2]),
("msgrcv", &[1]),
("msgsnd", &[1]),
("msync", &[0]),
("munlock", &[0]),
("munmap", &[0]),
("name_to_handle_at", &[1, 2, 3]),
("nanosleep", &[0, 1]),
("newfstatat", &[1, 2]),
("nfsservctl", &[1, 2]),
("oldfstat", &[1]),
("open", &[0]),
("open_by_handle_at", &[1]),
("open_tree", &[1]),
("openat", &[1]),
("openat2", &[1, 2]),
("perf_event_open", &[0]),
("pidfd_send_signal", &[2]),
("pipe", &[0]),
("pipe2", &[0]),
("pivot_root", &[0, 1]),
("pkey_mprotect", &[0]),
("poll", &[0]),
("ppoll", &[0, 2, 3]),
("ppoll_time64", &[0, 2, 3]),
("prctl", &[]), ("pread64", &[1]),
("preadv", &[1]),
("preadv2", &[1]),
("prlimit64", &[2, 3]),
("process_madvise", &[1]),
("process_vm_readv", &[1, 3]),
("process_vm_writev", &[1, 3]),
("pselect6", &[1, 2, 3, 4, 5]),
("pselect6_time64", &[1, 2, 3, 4, 5]),
("ptrace", &[2, 3]),
("putpmsg", &[1, 2]),
("pwrite64", &[1]),
("pwritev", &[1]),
("pwritev2", &[1]),
("query_module", &[0, 2, 4]),
("quotactl", &[1, 3]),
("quotactl_fd", &[3]),
("read", &[1]),
("readlink", &[0, 1]),
("readlinkat", &[1, 2]),
("readv", &[1]),
("reboot", &[3]),
("recv", &[1]),
("recvfrom", &[1, 4, 5]),
("recvmmsg", &[1, 4]),
("recvmmsg_time64", &[1, 4]),
("recvmsg", &[1]),
("remap_file_pages", &[0]),
("removexattr", &[0]),
("removexattrat", &[1]),
("rename", &[0, 1]),
("renameat", &[1, 3]),
("renameat2", &[1, 3]),
("request_key", &[0, 1, 2]),
("riscv_flush_icache", &[0, 1]),
("riscv_hwprobe", &[0, 3]),
("rmdir", &[0]),
("rseq", &[0]),
("rt_sigaction", &[1, 2]),
("rt_sigpending", &[0]),
("rt_sigprocmask", &[1, 2]),
("rt_sigqueueinfo", &[2]),
("rt_sigsuspend", &[0]),
("rt_sigtimedwait", &[0, 1, 2]),
("rt_sigtimedwait_time64", &[0, 1, 2]),
("rt_tgsigqueueinfo", &[3]),
("sched_getaffinity", &[2]),
("sched_getattr", &[1]),
("sched_getparam", &[1]),
("sched_rr_get_interval", &[1]),
("sched_rr_get_interval_time64", &[1]),
("sched_setaffinity", &[2]),
("sched_setattr", &[1]),
("sched_setparam", &[1]),
("sched_setscheduler", &[2]),
("seccomp", &[2]),
("select", &[1, 2, 3, 4]),
("semctl", &[3]),
("semop", &[1]),
("semtimedop", &[1, 3]),
("semtimedop_time64", &[1, 3]),
("send", &[1]),
("sendfile", &[2]),
("sendfile64", &[2]),
("sendmmsg", &[1]),
("sendmsg", &[1]),
("sendto", &[1, 4]),
("set_mempolicy", &[1]),
("set_robust_list", &[0]),
("set_thread_area", &[0]),
("set_tid_address", &[0]),
("setdomainname", &[0]),
("setgroups", &[1]),
("setgroups32", &[1]),
("sethostname", &[0]),
("setitimer", &[1, 2]),
("setrlimit", &[1]),
("setsockopt", &[3, 4]),
("settimeofday", &[0, 1]),
("setxattr", &[0, 1, 2]),
("setxattrat", &[1, 3]),
("shmat", &[1]),
("shmctl", &[2]),
("shmdt", &[0]),
("sigaction", &[1, 2]),
("sigaltstack", &[0, 1]),
("signal", &[1]),
("signalfd", &[1]),
("signalfd4", &[1]),
("sigpending", &[0]),
("sigprocmask", &[1, 2]),
("sigsuspend", &[0]),
("socketcall", &[1]),
("socketpair", &[3]),
("splice", &[1, 3]),
("stat", &[0, 1]),
("stat64", &[0, 1]),
("statfs", &[0, 1]),
("statfs64", &[0, 1]),
("statx", &[1, 4]),
("swapoff", &[0]),
("swapon", &[0]),
("symlink", &[0, 1]),
("symlinkat", &[0, 2]),
("sysinfo", &[0]),
("syslog", &[]), ("time", &[0]),
("timer_create", &[1, 2]),
("timer_gettime", &[1]),
("timer_gettime64", &[1]),
("timer_settime", &[2, 3]),
("timer_settime64", &[2, 3]),
("timerfd_gettime", &[1]),
("timerfd_gettime64", &[1]),
("timerfd_settime", &[2, 3]),
("timerfd_settime64", &[2, 3]),
("times", &[0]),
("truncate", &[0]),
("truncate64", &[0]),
("ugetrlimit", &[1]),
("umount", &[0]),
("umount2", &[0]),
("uname", &[0]),
("unlink", &[0]),
("unlinkat", &[1]),
("uselib", &[0]),
("ustat", &[1]),
("utime", &[0, 1]),
("utimensat", &[1, 2]),
("utimensat_time64", &[1, 2]),
("utimes", &[0, 1]),
("vmsplice", &[1]),
("wait4", &[1, 3]),
("waitid", &[2]),
("waitpid", &[1]),
("write", &[1]),
("writev", &[1]),
];
#[expect(clippy::disallowed_methods)]
pub static KERNEL_VERSION: LazyLock<(u32, u32)> = LazyLock::new(|| {
let version = if let Some(version) = secure_getenv(ENV_ASSUME_KERNEL) {
version.as_bytes().to_owned()
} else {
let version = uname().unwrap();
version.release().as_bytes().to_owned()
};
let nextdot = memchr(b'.', &version).expect("BUG: Invalid kernel version!");
let major = btoi::<u32>(&version[..nextdot]).expect("BUG: Invalid kernel version!");
let version = &version[nextdot + 1..];
let nextdot = memchr(b'.', version).unwrap_or(version.len());
let minor = btoi::<u32>(&version[..nextdot]).expect("BUG: Invalid kernel version!");
(major, minor)
});
#[expect(clippy::disallowed_methods)]
pub static KERNEL_VERSION_STR: LazyLock<String> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
let micro = randint(0u8..=u8::MAX).expect("BUG: Failed to randomize kernel micro version!");
format!("{major}.{minor}.{micro}")
});
pub static HAVE_MFD_NOEXEC_SEAL: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 3)
});
pub static SAFE_MFD_FLAGS: LazyLock<MFdFlags> = LazyLock::new(|| {
(if *HAVE_MFD_NOEXEC_SEAL {
MFdFlags::MFD_NOEXEC_SEAL
} else {
MFdFlags::MFD_ALLOW_SEALING
} | MFdFlags::MFD_CLOEXEC)
});
pub static HAVE_PIDFD_THREAD: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 9)
});
pub static HAVE_PIDFD_GET_INFO: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 13)
});
pub static HAVE_SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 6)
});
pub(crate) static HAVE_STATX_MNT_ID_UNIQUE: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 8)
});
pub static HAVE_AT_EXECVE_CHECK: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 14)
});
pub static HAVE_PTRACE_SET_SYSCALL_INFO: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 14)
});
pub static HAVE_PROCMAP_QUERY: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 11)
});
pub static HAVE_MADV_GUARD: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 13)
});
pub static HAVE_CROSS_MEMORY_ATTACH: LazyLock<bool> = LazyLock::new(check_cross_memory_attach);
pub static HAVE_PROC_PID_FD_STAT_SIZE: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 2)
});
pub static HAVE_RWF_NOAPPEND: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 9)
});
pub static HAVE_NAMESPACED_PID_MAX: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
major > 6 || (major == 6 && minor >= 14)
});
pub static HAVE_LANDLOCK_ACCESS_FS_REFER: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
(major > 5 || (major == 5 && minor >= 19)) && *LANDLOCK_ABI >= ABI::V2
});
pub static HAVE_LANDLOCK_SCOPED_SIGNALS: LazyLock<bool> = LazyLock::new(|| {
let (major, minor) = *KERNEL_VERSION;
(major > 6 || (major == 6 && minor >= 12)) && *LANDLOCK_ABI >= ABI::V6
});
pub static LANDLOCK_ABI: LazyLock<ABI> = LazyLock::new(ABI::new_current);
#[cfg(feature = "kcov")]
pub(crate) const KCOV_HEART_BEAT: u64 = 0x0000_DEAD_4200;
pub(crate) const EAGAIN_INITIAL_DELAY: u64 = 10;
pub(crate) const EAGAIN_BACKOFF_FACTOR: f64 = 2.0;
pub(crate) const EAGAIN_MAX_DELAY: u64 = 1000;
pub(crate) const EAGAIN_MAX_RETRY: usize = 7;
pub(crate) const SHM_UNSAFE_MASK: u64 = 0o177;
pub const MFD_NAME_PREFIX: &[u8] = b"!memfd:";
pub const MFD_HUGETLB_NAME_PREFIX: &[u8] = b"!memfd-hugetlb:";
pub const MFD_SECRET_NAME: &[u8] = b"!secretmem";
pub const LOOPBACK_BIGTCP_MAX: u32 = 0x30d40;
pub static MMAP_MIN_ADDR: LazyLock<u64> =
LazyLock::new(|| proc_mmap_min_addr().unwrap_or(*PAGE_SIZE).max(*PAGE_SIZE));
pub(crate) static HASH_CACHE: LazyLock<Mutex<HashCache>> =
LazyLock::new(|| Mutex::new(HashCache::new()));
pub(crate) const PTRACE_DATA_CHDIR: u16 = 0;
pub(crate) const PTRACE_DATA_FCHDIR: u16 = 1;
pub(crate) const PTRACE_DATA_EXECVE: u16 = 2;
pub(crate) const PTRACE_DATA_EXECVEAT: u16 = 3;
pub(crate) const PTRACE_DATA_SIGRETURN: u16 = 4;
pub(crate) const PTRACE_DATA_RT_SIGRETURN: u16 = 5;
pub(crate) const PTRACE_DATA_MMAP: u16 = 6;
pub(crate) const PTRACE_DATA_MMAP2: u16 = 7;
pub(crate) const PTRACE_DATA_SETGROUPS: u16 = 8;
pub(crate) const PTRACE_DATA_SETGROUPS32: u16 = 9;
pub(crate) const NGROUPS_MAX: u32 = 0x10000;
pub(crate) static _RAND_TIMER: OnceLock<RandTimer> = OnceLock::new();
#[expect(clippy::disallowed_methods)]
#[expect(non_snake_case)]
#[inline(always)]
pub(crate) fn RAND_TIMER() -> &'static RandTimer {
_RAND_TIMER.get().unwrap()
}
pub fn timer_init(timens: bool) -> Result<(), Errno> {
let timer = RandTimer::new(timens)?;
info!("ctx": "run", "op": "sysinfo_init_timer",
"msg": format!("initialized sysinfo(2) timer with {} offset{}",
if timens { "zero" } else { "random" },
if timens { " in time namespace" } else { "" }),
"off": [timer.uptime_offset, timer.idle_offset]);
_RAND_TIMER.set(timer).or(Err(Errno::EAGAIN))?;
Ok(())
}
pub const PINK_FLOYD: &str = concat!(
"\x1b[01;35m",
" ..uu. \n",
" ?$\"\"`?i z' \n",
" `M .@\" x\" \n",
" 'Z :#\" . . f 8M \n",
" '&H?` :$f U8 < MP x#' \n",
" d#` XM $5. $ M' xM\" \n",
" .!\"> @ 'f`$L:M R.@!` \n",
" +` > R X \"NXF R\"*L \n",
" k 'f M \"$$ :E 5. \n",
" %% `~ \" ` 'K 'M \n",
" .uH 'E `h \n",
" .x*` X ` \n",
" .uf` * \n",
" .@8 . \n",
" 'E9F uf\" , , \n",
" 9h+\" $M eH. 8b. .8 ..... \n",
" .8` $' M 'E `R;' d?\"\"\"`\"# \n",
" ` E @ b d 9R ?* @ \n",
" > K.zM `%%M' 9' Xf .f \n",
" ; R' 9 M .=` \n",
" t M Mx~ \n",
" @ lR z\" \n",
" @ ` ;\" \n",
" ` \n",
"\x1b[0m",
);
pub const SEE_EMILY_PLAY: &str = concat!(
"\x1b[0;1;35;95mTh",
"\x1b[0;1;31;91mer",
"\x1b[0;1;33;93me",
"\x1b[0m ",
"\x1b[0;1;32;92mis",
"\x1b[0m ",
"\x1b[0;1;36;96mn",
"\x1b[0;1;34;94mo",
"\x1b[0m ",
"\x1b[0;1;35;95mot",
"\x1b[0;1;31;91mhe",
"\x1b[0;1;33;93mr",
"\x1b[0m ",
"\x1b[0;1;32;92mda",
"\x1b[0;1;36;96my",
"\x1b[0m",
"\n",
"\x1b[0;1;35;95mLe",
"\x1b[0;1;31;91mt'",
"\x1b[0;1;33;93ms",
"\x1b[0m ",
"\x1b[0;1;32;92mtr",
"\x1b[0;1;36;96my",
"\x1b[0m ",
"\x1b[0;1;34;94mit",
"\x1b[0m ",
"\x1b[0;1;35;95ma",
"\x1b[0;1;31;91mno",
"\x1b[0;1;33;93mth",
"\x1b[0;1;32;92mer",
"\x1b[0m ",
"\x1b[0;1;36;96mw",
"\x1b[0;1;34;94may",
"\x1b[0m",
"\n",
"\x1b[0;1;35;95mYo",
"\x1b[0;1;31;91mu'",
"\x1b[0;1;33;93mll",
"\x1b[0m ",
"\x1b[0;1;32;92ml",
"\x1b[0;1;36;96mos",
"\x1b[0;1;34;94me",
"\x1b[0m ",
"\x1b[0;1;35;95myo",
"\x1b[0;1;31;91mur",
"\x1b[0m ",
"\x1b[0;1;33;93mm",
"\x1b[0;1;32;92min",
"\x1b[0;1;36;96md",
"\x1b[0m ",
"\x1b[0;1;34;94man",
"\x1b[0;1;35;95md",
"\x1b[0m ",
"\x1b[0;1;31;91mpl",
"\x1b[0;1;33;93may",
"\x1b[0m",
"\n",
"\x1b[0;1;35;95mFr",
"\x1b[0;1;31;91mee",
"\x1b[0m \x1b[0;1;33;93mg",
"\x1b[0;1;32;92mam",
"\x1b[0;1;36;96mes",
"\x1b[0m ",
"\x1b[0;1;34;94mf",
"\x1b[0;1;35;95mor",
"\x1b[0m ",
"\x1b[0;1;31;91mm",
"\x1b[0;1;33;93may",
"\x1b[0m",
"\n",
"\x1b[0;1;35;95mSe",
"\x1b[0;1;31;91me",
"\x1b[0m ",
"\x1b[0;1;33;93mEm",
"\x1b[0;1;32;92mil",
"\x1b[0;1;36;96my",
"\x1b[0m ",
"\x1b[0;1;34;94mpl",
"\x1b[0;1;35;95may",
"\x1b[0m",
"\n",
);
pub const THE_PIPER: &str = concat!(
"Helper and healer, I cheer\n",
"Small waifs in the woodland wet\n",
"Strays I find in it, wounds I bind in it\n",
"Bidding them all forget!\n",
);
#[cfg(panic = "abort")]
#[deprecated(
note = "Built with panic=abort. This configuration is not supported; you have been warned."
)]
#[allow(dead_code)]
const SYD_PANIC_ABORT_BUILD: () = ();
#[cfg(panic = "abort")]
const _: () = {
let _ = SYD_PANIC_ABORT_BUILD;
};