nc/platform/linux-types/uapi/linux/
seccomp.rs1#![allow(clippy::module_name_repetitions)]
8
9use crate::{IO, IOR, IOW, IOWR};
10
11pub const SECCOMP_MODE_DISABLED: u32 = 0;
14pub const SECCOMP_MODE_STRICT: u32 = 1;
16pub const SECCOMP_MODE_FILTER: u32 = 2;
18
19pub const SECCOMP_SET_MODE_STRICT: u32 = 0;
21pub const SECCOMP_SET_MODE_FILTER: u32 = 1;
22pub const SECCOMP_GET_ACTION_AVAIL: u32 = 2;
23pub const SECCOMP_GET_NOTIF_SIZES: u32 = 3;
24
25pub const SECCOMP_FILTER_FLAG_TSYNC: usize = 1;
27pub const SECCOMP_FILTER_FLAG_LOG: usize = 1 << 1;
28pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: usize = 1 << 2;
29pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: usize = 1 << 3;
30
31pub const SECCOMP_RET_KILL_PROCESS: u32 = 0x8000_0000;
41pub const SECCOMP_RET_KILL_THREAD: u32 = 0x0000_0000;
43pub const SECCOMP_RET_KILL: u32 = SECCOMP_RET_KILL_THREAD;
44pub const SECCOMP_RET_TRAP: u32 = 0x0003_0000;
46pub const SECCOMP_RET_ERRNO: u32 = 0x0005_0000;
48pub const SECCOMP_RET_USER_NOTIF: u32 = 0x7fc0_0000;
50pub const SECCOMP_RET_TRACE: u32 = 0x7ff0_0000;
52pub const SECCOMP_RET_LOG: u32 = 0x7ffc_0000;
54pub const SECCOMP_RET_ALLOW: u32 = 0x7fff_0000;
56
57pub const SECCOMP_RET_ACTION_FULL: u32 = 0xffff_0000;
59pub const SECCOMP_RET_ACTION: u32 = 0x7fff_0000;
60pub const SECCOMP_RET_DATA: u32 = 0x0000_ffff;
61
62#[repr(C)]
71#[derive(Debug, Default, Clone, Copy)]
72pub struct seccomp_data_t {
73 pub nr: i32,
74 pub arch: u32,
75 pub instruction_pointer: u64,
76 pub args: [u64; 6],
77}
78
79#[repr(C)]
80#[derive(Debug, Default, Clone, Copy)]
81pub struct seccomp_notif_sizes_t {
82 pub seccomp_notif: u16,
83 pub seccomp_notif_resp: u16,
84 pub seccomp_data: u16,
85}
86
87#[repr(C)]
88#[derive(Debug, Default, Clone, Copy)]
89pub struct seccomp_notif_t {
90 pub id: u64,
91 pub pid: u32,
92 pub flags: u32,
93 pub data: seccomp_data_t,
94}
95
96#[repr(C)]
97#[derive(Debug, Default, Clone, Copy)]
98pub struct seccomp_notif_resp_t {
99 pub id: u64,
100 pub val: i64,
101 pub error: i32,
102 pub flags: u32,
103}
104
105pub const SECCOMP_IOC_MAGIC: u8 = b'!';
106
107#[must_use]
108#[inline]
109pub const fn SECCOMP_IO(nr: u32) -> u32 {
110 IO(SECCOMP_IOC_MAGIC, nr)
111}
112
113#[must_use]
114#[inline]
115pub const fn SECCOMP_IOR<T>(nr: u32) -> u32 {
116 IOR::<T>(SECCOMP_IOC_MAGIC, nr)
117}
118
119#[must_use]
120#[inline]
121pub const fn SECCOMP_IOW<T>(nr: u32) -> u32 {
122 IOW::<T>(SECCOMP_IOC_MAGIC, nr)
123}
124
125#[must_use]
126#[inline]
127pub const fn SECCOMP_IOWR<T>(nr: u32) -> u32 {
128 IOWR::<T>(SECCOMP_IOC_MAGIC, nr)
129}
130
131pub const SECCOMP_IOCTL_NOTIF_RECV: u32 = SECCOMP_IOWR::<seccomp_notif_t>(0);
133
134pub const SECCOMP_IOCTL_NOTIF_SEND: u32 = SECCOMP_IOWR::<seccomp_notif_resp_t>(1);
135
136pub const SECCOMP_IOCTL_NOTIF_ID_VALID: u32 = SECCOMP_IOR::<u64>(2);