Debian Codegraph @

capability/enum.go

raw symbols SCIP
1 // Copyright (c) 2013, Suryandaru Triandana <[email protected]>
2 // All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
6
7 package capability
8
9 type CapType uint
10
11 func (c CapType) String() string {
12 switch c {
13 case EFFECTIVE:
14 return "effective"
15 case PERMITTED:
16 return "permitted"
17 case INHERITABLE:
18 return "inheritable"
19 case BOUNDING:
20 return "bounding"
21 case CAPS:
22 return "caps"
23 case AMBIENT:
24 return "ambient"
25 }
26 return "unknown"
27 }
28
29 const (
30 EFFECTIVE CapType = 1 << iota
31 PERMITTED
32 INHERITABLE
33 BOUNDING
34 AMBIENT
35
36 CAPS = EFFECTIVE | PERMITTED | INHERITABLE
37 BOUNDS = BOUNDING
38 AMBS = AMBIENT
39 )
40
41 //go:generate go run enumgen/gen.go
42 type Cap int
43
44 // POSIX-draft defined capabilities and Linux extensions.
45 //
46 // Defined in https://github.com/torvalds/linux/blob/master/include/uapi/linux/capability.h
47 const (
48 // In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this
49 // overrides the restriction of changing file ownership and group
50 // ownership.
51 CAP_CHOWN = Cap(0)
52
53 // Override all DAC access, including ACL execute access if
54 // [_POSIX_ACL] is defined. Excluding DAC access covered by
55 // CAP_LINUX_IMMUTABLE.
56 CAP_DAC_OVERRIDE = Cap(1)
57
58 // Overrides all DAC restrictions regarding read and search on files
59 // and directories, including ACL restrictions if [_POSIX_ACL] is
60 // defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE.
61 CAP_DAC_READ_SEARCH = Cap(2)
62
63 // Overrides all restrictions about allowed operations on files, where
64 // file owner ID must be equal to the user ID, except where CAP_FSETID
65 // is applicable. It doesn't override MAC and DAC restrictions.
66 CAP_FOWNER = Cap(3)
67
68 // Overrides the following restrictions that the effective user ID
69 // shall match the file owner ID when setting the S_ISUID and S_ISGID
70 // bits on that file; that the effective group ID (or one of the
71 // supplementary group IDs) shall match the file owner ID when setting
72 // the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are
73 // cleared on successful return from chown(2) (not implemented).
74 CAP_FSETID = Cap(4)
75
76 // Overrides the restriction that the real or effective user ID of a
77 // process sending a signal must match the real or effective user ID
78 // of the process receiving the signal.
79 CAP_KILL = Cap(5)
80
81 // Allows setgid(2) manipulation
82 // Allows setgroups(2)
83 // Allows forged gids on socket credentials passing.
84 CAP_SETGID = Cap(6)
85
86 // Allows set*uid(2) manipulation (including fsuid).
87 // Allows forged pids on socket credentials passing.
88 CAP_SETUID = Cap(7)
89
90 // Linux-specific capabilities
91
92 // Without VFS support for capabilities:
93 // Transfer any capability in your permitted set to any pid,
94 // remove any capability in your permitted set from any pid
95 // With VFS support for capabilities (neither of above, but)
96 // Add any capability from current's capability bounding set
97 // to the current process' inheritable set
98 // Allow taking bits out of capability bounding set
99 // Allow modification of the securebits for a process
100 CAP_SETPCAP = Cap(8)
101
102 // Allow modification of S_IMMUTABLE and S_APPEND file attributes
103 CAP_LINUX_IMMUTABLE = Cap(9)
104
105 // Allows binding to TCP/UDP sockets below 1024
106 // Allows binding to ATM VCIs below 32
107 CAP_NET_BIND_SERVICE = Cap(10)
108
109 // Allow broadcasting, listen to multicast
110 CAP_NET_BROADCAST = Cap(11)
111
112 // Allow interface configuration
113 // Allow administration of IP firewall, masquerading and accounting
114 // Allow setting debug option on sockets
115 // Allow modification of routing tables
116 // Allow setting arbitrary process / process group ownership on
117 // sockets
118 // Allow binding to any address for transparent proxying (also via NET_RAW)
119 // Allow setting TOS (type of service)
120 // Allow setting promiscuous mode
121 // Allow clearing driver statistics
122 // Allow multicasting
123 // Allow read/write of device-specific registers
124 // Allow activation of ATM control sockets
125 CAP_NET_ADMIN = Cap(12)
126
127 // Allow use of RAW sockets
128 // Allow use of PACKET sockets
129 // Allow binding to any address for transparent proxying (also via NET_ADMIN)
130 CAP_NET_RAW = Cap(13)
131
132 // Allow locking of shared memory segments
133 // Allow mlock and mlockall (which doesn't really have anything to do
134 // with IPC)
135 CAP_IPC_LOCK = Cap(14)
136
137 // Override IPC ownership checks
138 CAP_IPC_OWNER = Cap(15)
139
140 // Insert and remove kernel modules - modify kernel without limit
141 CAP_SYS_MODULE = Cap(16)
142
143 // Allow ioperm/iopl access
144 // Allow sending USB messages to any device via /proc/bus/usb
145 CAP_SYS_RAWIO = Cap(17)
146
147 // Allow use of chroot()
148 CAP_SYS_CHROOT = Cap(18)
149
150 // Allow ptrace() of any process
151 CAP_SYS_PTRACE = Cap(19)
152
153 // Allow configuration of process accounting
154 CAP_SYS_PACCT = Cap(20)
155
156 // Allow configuration of the secure attention key
157 // Allow administration of the random device
158 // Allow examination and configuration of disk quotas
159 // Allow setting the domainname
160 // Allow setting the hostname
161 // Allow calling bdflush()
162 // Allow mount() and umount(), setting up new smb connection
163 // Allow some autofs root ioctls
164 // Allow nfsservctl
165 // Allow VM86_REQUEST_IRQ
166 // Allow to read/write pci config on alpha
167 // Allow irix_prctl on mips (setstacksize)
168 // Allow flushing all cache on m68k (sys_cacheflush)
169 // Allow removing semaphores
170 // Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores
171 // and shared memory
172 // Allow locking/unlocking of shared memory segment
173 // Allow turning swap on/off
174 // Allow forged pids on socket credentials passing
175 // Allow setting readahead and flushing buffers on block devices
176 // Allow setting geometry in floppy driver
177 // Allow turning DMA on/off in xd driver
178 // Allow administration of md devices (mostly the above, but some
179 // extra ioctls)
180 // Allow tuning the ide driver
181 // Allow access to the nvram device
182 // Allow administration of apm_bios, serial and bttv (TV) device
183 // Allow manufacturer commands in isdn CAPI support driver
184 // Allow reading non-standardized portions of pci configuration space
185 // Allow DDI debug ioctl on sbpcd driver
186 // Allow setting up serial ports
187 // Allow sending raw qic-117 commands
188 // Allow enabling/disabling tagged queuing on SCSI controllers and sending
189 // arbitrary SCSI commands
190 // Allow setting encryption key on loopback filesystem
191 // Allow setting zone reclaim policy
192 // Allow everything under CAP_BPF and CAP_PERFMON for backward compatibility
193 CAP_SYS_ADMIN = Cap(21)
194
195 // Allow use of reboot()
196 CAP_SYS_BOOT = Cap(22)
197
198 // Allow raising priority and setting priority on other (different
199 // UID) processes
200 // Allow use of FIFO and round-robin (realtime) scheduling on own
201 // processes and setting the scheduling algorithm used by another
202 // process.
203 // Allow setting cpu affinity on other processes
204 CAP_SYS_NICE = Cap(23)
205
206 // Override resource limits. Set resource limits.
207 // Override quota limits.
208 // Override reserved space on ext2 filesystem
209 // Modify data journaling mode on ext3 filesystem (uses journaling
210 // resources)
211 // NOTE: ext2 honors fsuid when checking for resource overrides, so
212 // you can override using fsuid too
213 // Override size restrictions on IPC message queues
214 // Allow more than 64hz interrupts from the real-time clock
215 // Override max number of consoles on console allocation
216 // Override max number of keymaps
217 // Control memory reclaim behavior
218 CAP_SYS_RESOURCE = Cap(24)
219
220 // Allow manipulation of system clock
221 // Allow irix_stime on mips
222 // Allow setting the real-time clock
223 CAP_SYS_TIME = Cap(25)
224
225 // Allow configuration of tty devices
226 // Allow vhangup() of tty
227 CAP_SYS_TTY_CONFIG = Cap(26)
228
229 // Allow the privileged aspects of mknod()
230 CAP_MKNOD = Cap(27)
231
232 // Allow taking of leases on files
233 CAP_LEASE = Cap(28)
234
235 CAP_AUDIT_WRITE = Cap(29)
236 CAP_AUDIT_CONTROL = Cap(30)
237 CAP_SETFCAP = Cap(31)
238
239 // Override MAC access.
240 // The base kernel enforces no MAC policy.
241 // An LSM may enforce a MAC policy, and if it does and it chooses
242 // to implement capability based overrides of that policy, this is
243 // the capability it should use to do so.
244 CAP_MAC_OVERRIDE = Cap(32)
245
246 // Allow MAC configuration or state changes.
247 // The base kernel requires no MAC configuration.
248 // An LSM may enforce a MAC policy, and if it does and it chooses
249 // to implement capability based checks on modifications to that
250 // policy or the data required to maintain it, this is the
251 // capability it should use to do so.
252 CAP_MAC_ADMIN = Cap(33)
253
254 // Allow configuring the kernel's syslog (printk behaviour)
255 CAP_SYSLOG = Cap(34)
256
257 // Allow triggering something that will wake the system
258 CAP_WAKE_ALARM = Cap(35)
259
260 // Allow preventing system suspends
261 CAP_BLOCK_SUSPEND = Cap(36)
262
263 // Allow reading the audit log via multicast netlink socket
264 CAP_AUDIT_READ = Cap(37)
265
266 // Allow system performance and observability privileged operations
267 // using perf_events, i915_perf and other kernel subsystems
268 CAP_PERFMON = Cap(38)
269
270 // CAP_BPF allows the following BPF operations:
271 // - Creating all types of BPF maps
272 // - Advanced verifier features
273 // - Indirect variable access
274 // - Bounded loops
275 // - BPF to BPF function calls
276 // - Scalar precision tracking
277 // - Larger complexity limits
278 // - Dead code elimination
279 // - And potentially other features
280 // - Loading BPF Type Format (BTF) data
281 // - Retrieve xlated and JITed code of BPF programs
282 // - Use bpf_spin_lock() helper
283 //
284 // CAP_PERFMON relaxes the verifier checks further:
285 // - BPF progs can use of pointer-to-integer conversions
286 // - speculation attack hardening measures are bypassed
287 // - bpf_probe_read to read arbitrary kernel memory is allowed
288 // - bpf_trace_printk to print kernel memory is allowed
289 //
290 // CAP_SYS_ADMIN is required to use bpf_probe_write_user.
291 //
292 // CAP_SYS_ADMIN is required to iterate system wide loaded
293 // programs, maps, links, BTFs and convert their IDs to file descriptors.
294 //
295 // CAP_PERFMON and CAP_BPF are required to load tracing programs.
296 // CAP_NET_ADMIN and CAP_BPF are required to load networking programs.
297 CAP_BPF = Cap(39)
298
299 // Allow checkpoint/restore related operations.
300 // Introduced in kernel 5.9
301 CAP_CHECKPOINT_RESTORE = Cap(40)
302 )
303
304 var (
305 // Highest valid capability of the running kernel.
306 CAP_LAST_CAP = Cap(63)
307
308 capUpperMask = ^uint32(0)
309 )