]>
Commit | Line | Data |
---|---|---|
6d2010ae A |
1 | #include <sys/param.h> |
2 | #include <sys/systm.h> /* XXX printf() */ | |
3 | ||
4 | #include <sys/types.h> | |
5 | #include <sys/fcntl.h> | |
6 | #include <sys/file.h> | |
7 | #include <sys/kauth.h> | |
8 | #include <sys/mount.h> | |
9 | #include <sys/msg.h> | |
10 | #include <sys/proc.h> | |
11 | #include <sys/socketvar.h> | |
12 | #include <sys/vnode.h> | |
13 | #include <security/mac.h> | |
14 | #include <security/mac_policy.h> | |
15 | ||
5ba3f43e | 16 | #include <libkern/section_keywords.h> |
6d2010ae A |
17 | #include <libkern/OSDebug.h> /* OSBPrintBacktrace */ |
18 | ||
19 | ||
20 | /* forward declaration; see bsd_init.c */ | |
21 | errno_t check_policy_init(int); | |
22 | int get_thread_lock_count(thread_t th); /* forced forward */ | |
23 | ||
24 | /* | |
25 | * Policy flags used when the policy is enabled | |
26 | * | |
27 | * Note: CHECK_POLICY_CHECK is probably not very useful unless you | |
28 | * are kernel debugging and set a breakpoint. | |
29 | */ | |
30 | #define CHECK_POLICY_CHECK 0x00000001 /* Check on calls */ | |
31 | #define CHECK_POLICY_FAIL 0x00000002 /* EPERM on fails */ | |
32 | #define CHECK_POLICY_BACKTRACE 0x00000004 /* Show call stack on fails */ | |
33 | #define CHECK_POLICY_PANIC 0x00000008 /* Panic on fails */ | |
34 | #define CHECK_POLICY_PERIODIC 0x00000010 /* Show fails periodically */ | |
35 | ||
36 | static int policy_flags = 0; | |
37 | ||
38 | ||
39236c6e | 39 | #define CHECK_SET_HOOK(x) .mpo_##x = (mpo_##x##_t *)common_hook, |
6d2010ae A |
40 | |
41 | /* | |
42 | * Init; currently, we only print our arrival notice. | |
43 | */ | |
44 | static void | |
45 | hook_policy_init(struct mac_policy_conf *mpc) | |
46 | { | |
47 | printf("Policy '%s' = '%s' ready\n", mpc->mpc_name, mpc->mpc_fullname); | |
48 | } | |
49 | ||
50 | static void | |
51 | hook_policy_initbsd(struct mac_policy_conf *mpc) | |
52 | { | |
53 | /* called with policy_grab_exclusive mutex held; exempt */ | |
54 | printf("hook_policy_initbsd: %s\n", mpc->mpc_name); | |
55 | } | |
56 | ||
57 | ||
58 | /* Implementation */ | |
59 | #define CLASS_PERIOD_LIMIT 10000 | |
60 | #define CLASS_PERIOD_MULT 20 | |
61 | ||
62 | static int policy_check_event = 1; | |
63 | static int policy_check_period = 1; | |
64 | static int policy_check_next = CLASS_PERIOD_MULT; | |
65 | ||
66 | ||
67 | static int | |
39236c6e | 68 | common_hook(void) |
6d2010ae A |
69 | { |
70 | int i; | |
71 | int rv = 0; | |
72 | ||
73 | if ((i = get_thread_lock_count(current_thread())) != 0) { | |
74 | /* | |
75 | * fail the MACF check if we hold a lock; this assumes a | |
76 | * a non-void (authorization) MACF hook. | |
77 | */ | |
78 | if (policy_flags & CHECK_POLICY_FAIL) | |
79 | rv = EPERM; | |
80 | ||
81 | /* | |
82 | * display a backtrace if we hold a lock and we are not | |
83 | * going to panic | |
84 | */ | |
85 | if ((policy_flags & (CHECK_POLICY_BACKTRACE | CHECK_POLICY_PANIC)) == CHECK_POLICY_BACKTRACE) { | |
86 | if (policy_flags & CHECK_POLICY_PERIODIC) { | |
87 | /* at exponentially increasing intervals */ | |
88 | if (!(policy_check_event % policy_check_period)) { | |
89 | if (policy_check_event <= policy_check_next || policy_check_period == CLASS_PERIOD_LIMIT) { | |
90 | /* | |
91 | * According to Derek, we could | |
92 | * technically get a symbolicated name | |
93 | * here, if we refactered some code | |
94 | * and set the "keepsyms=1" boot | |
95 | * argument... | |
96 | */ | |
97 | OSReportWithBacktrace("calling MACF hook with mutex count %d (event %d) ", i, policy_check_event); | |
98 | } | |
99 | } else { | |
100 | if (policy_check_period < CLASS_PERIOD_LIMIT) { | |
101 | policy_check_next *= CLASS_PERIOD_MULT; | |
102 | policy_check_period *= CLASS_PERIOD_MULT; | |
103 | } | |
104 | } | |
105 | } else { | |
106 | /* always */ | |
107 | OSReportWithBacktrace("calling MACF hook with mutex count %d (event %d) ", i, policy_check_event); | |
108 | } | |
109 | } | |
110 | ||
111 | /* Panic */ | |
112 | if (policy_flags & CHECK_POLICY_PANIC) | |
113 | panic("calling MACF hook with mutex count %d\n", i); | |
114 | ||
115 | /* count for non-fatal tracing */ | |
116 | policy_check_event++; | |
117 | } | |
118 | ||
119 | return rv; | |
120 | } | |
121 | ||
527f9951 | 122 | #if (MAC_POLICY_OPS_VERSION != 53) |
39236c6e A |
123 | # error "struct mac_policy_ops doesn't match definition in mac_policy.h" |
124 | #endif | |
6d2010ae A |
125 | /* |
126 | * Policy hooks; one per possible hook | |
39236c6e A |
127 | * |
128 | * Please note that this struct initialization should be kept in sync with | |
129 | * security/mac_policy.h (mac_policy_ops struct definition). | |
6d2010ae | 130 | */ |
5ba3f43e | 131 | const static struct mac_policy_ops policy_ops = { |
39236c6e A |
132 | CHECK_SET_HOOK(audit_check_postselect) |
133 | CHECK_SET_HOOK(audit_check_preselect) | |
134 | ||
135 | CHECK_SET_HOOK(bpfdesc_label_associate) | |
136 | CHECK_SET_HOOK(bpfdesc_label_destroy) | |
137 | CHECK_SET_HOOK(bpfdesc_label_init) | |
138 | CHECK_SET_HOOK(bpfdesc_check_receive) | |
139 | ||
140 | CHECK_SET_HOOK(cred_check_label_update_execve) | |
141 | CHECK_SET_HOOK(cred_check_label_update) | |
142 | CHECK_SET_HOOK(cred_check_visible) | |
143 | CHECK_SET_HOOK(cred_label_associate_fork) | |
144 | CHECK_SET_HOOK(cred_label_associate_kernel) | |
145 | CHECK_SET_HOOK(cred_label_associate) | |
146 | CHECK_SET_HOOK(cred_label_associate_user) | |
147 | CHECK_SET_HOOK(cred_label_destroy) | |
148 | CHECK_SET_HOOK(cred_label_externalize_audit) | |
149 | CHECK_SET_HOOK(cred_label_externalize) | |
150 | CHECK_SET_HOOK(cred_label_init) | |
151 | CHECK_SET_HOOK(cred_label_internalize) | |
152 | CHECK_SET_HOOK(cred_label_update_execve) | |
153 | CHECK_SET_HOOK(cred_label_update) | |
154 | ||
155 | CHECK_SET_HOOK(devfs_label_associate_device) | |
156 | CHECK_SET_HOOK(devfs_label_associate_directory) | |
157 | CHECK_SET_HOOK(devfs_label_copy) | |
158 | CHECK_SET_HOOK(devfs_label_destroy) | |
159 | CHECK_SET_HOOK(devfs_label_init) | |
160 | CHECK_SET_HOOK(devfs_label_update) | |
161 | ||
162 | CHECK_SET_HOOK(file_check_change_offset) | |
163 | CHECK_SET_HOOK(file_check_create) | |
164 | CHECK_SET_HOOK(file_check_dup) | |
165 | CHECK_SET_HOOK(file_check_fcntl) | |
166 | CHECK_SET_HOOK(file_check_get_offset) | |
167 | CHECK_SET_HOOK(file_check_get) | |
168 | CHECK_SET_HOOK(file_check_inherit) | |
169 | CHECK_SET_HOOK(file_check_ioctl) | |
170 | CHECK_SET_HOOK(file_check_lock) | |
171 | CHECK_SET_HOOK(file_check_mmap_downgrade) | |
172 | CHECK_SET_HOOK(file_check_mmap) | |
173 | CHECK_SET_HOOK(file_check_receive) | |
174 | CHECK_SET_HOOK(file_check_set) | |
175 | CHECK_SET_HOOK(file_label_init) | |
176 | CHECK_SET_HOOK(file_label_destroy) | |
177 | CHECK_SET_HOOK(file_label_associate) | |
178 | ||
179 | CHECK_SET_HOOK(ifnet_check_label_update) | |
180 | CHECK_SET_HOOK(ifnet_check_transmit) | |
181 | CHECK_SET_HOOK(ifnet_label_associate) | |
182 | CHECK_SET_HOOK(ifnet_label_copy) | |
183 | CHECK_SET_HOOK(ifnet_label_destroy) | |
184 | CHECK_SET_HOOK(ifnet_label_externalize) | |
185 | CHECK_SET_HOOK(ifnet_label_init) | |
186 | CHECK_SET_HOOK(ifnet_label_internalize) | |
187 | CHECK_SET_HOOK(ifnet_label_update) | |
188 | CHECK_SET_HOOK(ifnet_label_recycle) | |
189 | ||
190 | CHECK_SET_HOOK(inpcb_check_deliver) | |
191 | CHECK_SET_HOOK(inpcb_label_associate) | |
192 | CHECK_SET_HOOK(inpcb_label_destroy) | |
193 | CHECK_SET_HOOK(inpcb_label_init) | |
194 | CHECK_SET_HOOK(inpcb_label_recycle) | |
195 | CHECK_SET_HOOK(inpcb_label_update) | |
196 | ||
197 | CHECK_SET_HOOK(iokit_check_device) | |
198 | ||
199 | CHECK_SET_HOOK(ipq_label_associate) | |
200 | CHECK_SET_HOOK(ipq_label_compare) | |
201 | CHECK_SET_HOOK(ipq_label_destroy) | |
202 | CHECK_SET_HOOK(ipq_label_init) | |
203 | CHECK_SET_HOOK(ipq_label_update) | |
204 | ||
39037602 A |
205 | CHECK_SET_HOOK(file_check_library_validation) |
206 | ||
207 | CHECK_SET_HOOK(vnode_notify_setacl) | |
208 | CHECK_SET_HOOK(vnode_notify_setattrlist) | |
209 | CHECK_SET_HOOK(vnode_notify_setextattr) | |
210 | CHECK_SET_HOOK(vnode_notify_setflags) | |
211 | CHECK_SET_HOOK(vnode_notify_setmode) | |
212 | CHECK_SET_HOOK(vnode_notify_setowner) | |
213 | CHECK_SET_HOOK(vnode_notify_setutimes) | |
214 | CHECK_SET_HOOK(vnode_notify_truncate) | |
39236c6e A |
215 | |
216 | CHECK_SET_HOOK(mbuf_label_associate_bpfdesc) | |
217 | CHECK_SET_HOOK(mbuf_label_associate_ifnet) | |
218 | CHECK_SET_HOOK(mbuf_label_associate_inpcb) | |
219 | CHECK_SET_HOOK(mbuf_label_associate_ipq) | |
220 | CHECK_SET_HOOK(mbuf_label_associate_linklayer) | |
221 | CHECK_SET_HOOK(mbuf_label_associate_multicast_encap) | |
222 | CHECK_SET_HOOK(mbuf_label_associate_netlayer) | |
223 | CHECK_SET_HOOK(mbuf_label_associate_socket) | |
224 | CHECK_SET_HOOK(mbuf_label_copy) | |
225 | CHECK_SET_HOOK(mbuf_label_destroy) | |
226 | CHECK_SET_HOOK(mbuf_label_init) | |
227 | ||
228 | CHECK_SET_HOOK(mount_check_fsctl) | |
229 | CHECK_SET_HOOK(mount_check_getattr) | |
230 | CHECK_SET_HOOK(mount_check_label_update) | |
231 | CHECK_SET_HOOK(mount_check_mount) | |
232 | CHECK_SET_HOOK(mount_check_remount) | |
233 | CHECK_SET_HOOK(mount_check_setattr) | |
234 | CHECK_SET_HOOK(mount_check_stat) | |
235 | CHECK_SET_HOOK(mount_check_umount) | |
236 | CHECK_SET_HOOK(mount_label_associate) | |
237 | CHECK_SET_HOOK(mount_label_destroy) | |
238 | CHECK_SET_HOOK(mount_label_externalize) | |
239 | CHECK_SET_HOOK(mount_label_init) | |
240 | CHECK_SET_HOOK(mount_label_internalize) | |
241 | ||
242 | CHECK_SET_HOOK(netinet_fragment) | |
243 | CHECK_SET_HOOK(netinet_icmp_reply) | |
244 | CHECK_SET_HOOK(netinet_tcp_reply) | |
245 | ||
246 | CHECK_SET_HOOK(pipe_check_ioctl) | |
247 | CHECK_SET_HOOK(pipe_check_kqfilter) | |
248 | CHECK_SET_HOOK(pipe_check_label_update) | |
249 | CHECK_SET_HOOK(pipe_check_read) | |
250 | CHECK_SET_HOOK(pipe_check_select) | |
251 | CHECK_SET_HOOK(pipe_check_stat) | |
252 | CHECK_SET_HOOK(pipe_check_write) | |
253 | CHECK_SET_HOOK(pipe_label_associate) | |
254 | CHECK_SET_HOOK(pipe_label_copy) | |
255 | CHECK_SET_HOOK(pipe_label_destroy) | |
256 | CHECK_SET_HOOK(pipe_label_externalize) | |
257 | CHECK_SET_HOOK(pipe_label_init) | |
258 | CHECK_SET_HOOK(pipe_label_internalize) | |
259 | CHECK_SET_HOOK(pipe_label_update) | |
260 | ||
261 | CHECK_SET_HOOK(policy_destroy) | |
262 | /* special hooks for policy init's */ | |
6d2010ae A |
263 | .mpo_policy_init = hook_policy_init, |
264 | .mpo_policy_initbsd = hook_policy_initbsd, | |
39236c6e A |
265 | CHECK_SET_HOOK(policy_syscall) |
266 | ||
fe8ab488 A |
267 | CHECK_SET_HOOK(system_check_sysctlbyname) |
268 | CHECK_SET_HOOK(proc_check_inherit_ipc_ports) | |
269 | CHECK_SET_HOOK(vnode_check_rename) | |
3e170ce0 A |
270 | CHECK_SET_HOOK(kext_check_query) |
271 | CHECK_SET_HOOK(iokit_check_nvram_get) | |
272 | CHECK_SET_HOOK(iokit_check_nvram_set) | |
273 | CHECK_SET_HOOK(iokit_check_nvram_delete) | |
274 | CHECK_SET_HOOK(proc_check_expose_task) | |
275 | CHECK_SET_HOOK(proc_check_set_host_special_port) | |
276 | CHECK_SET_HOOK(proc_check_set_host_exception_port) | |
39037602 A |
277 | CHECK_SET_HOOK(exc_action_check_exception_send) |
278 | CHECK_SET_HOOK(exc_action_label_associate) | |
5ba3f43e | 279 | CHECK_SET_HOOK(exc_action_label_populate) |
39037602 A |
280 | CHECK_SET_HOOK(exc_action_label_destroy) |
281 | CHECK_SET_HOOK(exc_action_label_init) | |
282 | CHECK_SET_HOOK(exc_action_label_update) | |
283 | ||
527f9951 | 284 | CHECK_SET_HOOK(vnode_check_trigger_resolve) |
743345f9 A |
285 | .mpo_reserved1 = (mpo_reserved_hook_t *)common_hook, |
286 | .mpo_reserved2 = (mpo_reserved_hook_t *)common_hook, | |
287 | .mpo_reserved3 = (mpo_reserved_hook_t *)common_hook, | |
5ba3f43e A |
288 | CHECK_SET_HOOK(skywalk_flow_check_connect) |
289 | CHECK_SET_HOOK(skywalk_flow_check_listen) | |
39236c6e A |
290 | |
291 | CHECK_SET_HOOK(posixsem_check_create) | |
292 | CHECK_SET_HOOK(posixsem_check_open) | |
293 | CHECK_SET_HOOK(posixsem_check_post) | |
294 | CHECK_SET_HOOK(posixsem_check_unlink) | |
295 | CHECK_SET_HOOK(posixsem_check_wait) | |
296 | CHECK_SET_HOOK(posixsem_label_associate) | |
297 | CHECK_SET_HOOK(posixsem_label_destroy) | |
298 | CHECK_SET_HOOK(posixsem_label_init) | |
299 | CHECK_SET_HOOK(posixshm_check_create) | |
300 | CHECK_SET_HOOK(posixshm_check_mmap) | |
301 | CHECK_SET_HOOK(posixshm_check_open) | |
302 | CHECK_SET_HOOK(posixshm_check_stat) | |
303 | CHECK_SET_HOOK(posixshm_check_truncate) | |
304 | CHECK_SET_HOOK(posixshm_check_unlink) | |
305 | CHECK_SET_HOOK(posixshm_label_associate) | |
306 | CHECK_SET_HOOK(posixshm_label_destroy) | |
307 | CHECK_SET_HOOK(posixshm_label_init) | |
308 | ||
309 | CHECK_SET_HOOK(proc_check_debug) | |
310 | CHECK_SET_HOOK(proc_check_fork) | |
311 | CHECK_SET_HOOK(proc_check_get_task_name) | |
312 | CHECK_SET_HOOK(proc_check_get_task) | |
313 | CHECK_SET_HOOK(proc_check_getaudit) | |
314 | CHECK_SET_HOOK(proc_check_getauid) | |
315 | CHECK_SET_HOOK(proc_check_getlcid) | |
316 | CHECK_SET_HOOK(proc_check_mprotect) | |
317 | CHECK_SET_HOOK(proc_check_sched) | |
318 | CHECK_SET_HOOK(proc_check_setaudit) | |
319 | CHECK_SET_HOOK(proc_check_setauid) | |
320 | CHECK_SET_HOOK(proc_check_setlcid) | |
321 | CHECK_SET_HOOK(proc_check_signal) | |
322 | CHECK_SET_HOOK(proc_check_wait) | |
323 | CHECK_SET_HOOK(proc_label_destroy) | |
324 | CHECK_SET_HOOK(proc_label_init) | |
325 | ||
326 | CHECK_SET_HOOK(socket_check_accept) | |
327 | CHECK_SET_HOOK(socket_check_accepted) | |
328 | CHECK_SET_HOOK(socket_check_bind) | |
329 | CHECK_SET_HOOK(socket_check_connect) | |
330 | CHECK_SET_HOOK(socket_check_create) | |
331 | CHECK_SET_HOOK(socket_check_deliver) | |
332 | CHECK_SET_HOOK(socket_check_kqfilter) | |
333 | CHECK_SET_HOOK(socket_check_label_update) | |
334 | CHECK_SET_HOOK(socket_check_listen) | |
335 | CHECK_SET_HOOK(socket_check_receive) | |
336 | CHECK_SET_HOOK(socket_check_received) | |
337 | CHECK_SET_HOOK(socket_check_select) | |
338 | CHECK_SET_HOOK(socket_check_send) | |
339 | CHECK_SET_HOOK(socket_check_stat) | |
340 | CHECK_SET_HOOK(socket_check_setsockopt) | |
341 | CHECK_SET_HOOK(socket_check_getsockopt) | |
342 | CHECK_SET_HOOK(socket_label_associate_accept) | |
343 | CHECK_SET_HOOK(socket_label_associate) | |
344 | CHECK_SET_HOOK(socket_label_copy) | |
345 | CHECK_SET_HOOK(socket_label_destroy) | |
346 | CHECK_SET_HOOK(socket_label_externalize) | |
347 | CHECK_SET_HOOK(socket_label_init) | |
348 | CHECK_SET_HOOK(socket_label_internalize) | |
349 | CHECK_SET_HOOK(socket_label_update) | |
350 | ||
351 | CHECK_SET_HOOK(socketpeer_label_associate_mbuf) | |
352 | CHECK_SET_HOOK(socketpeer_label_associate_socket) | |
353 | CHECK_SET_HOOK(socketpeer_label_destroy) | |
354 | CHECK_SET_HOOK(socketpeer_label_externalize) | |
355 | CHECK_SET_HOOK(socketpeer_label_init) | |
356 | ||
357 | CHECK_SET_HOOK(system_check_acct) | |
358 | CHECK_SET_HOOK(system_check_audit) | |
359 | CHECK_SET_HOOK(system_check_auditctl) | |
360 | CHECK_SET_HOOK(system_check_auditon) | |
361 | CHECK_SET_HOOK(system_check_host_priv) | |
362 | CHECK_SET_HOOK(system_check_nfsd) | |
363 | CHECK_SET_HOOK(system_check_reboot) | |
364 | CHECK_SET_HOOK(system_check_settime) | |
365 | CHECK_SET_HOOK(system_check_swapoff) | |
366 | CHECK_SET_HOOK(system_check_swapon) | |
5ba3f43e | 367 | CHECK_SET_HOOK(socket_check_ioctl) |
39236c6e A |
368 | |
369 | CHECK_SET_HOOK(sysvmsg_label_associate) | |
370 | CHECK_SET_HOOK(sysvmsg_label_destroy) | |
371 | CHECK_SET_HOOK(sysvmsg_label_init) | |
372 | CHECK_SET_HOOK(sysvmsg_label_recycle) | |
373 | CHECK_SET_HOOK(sysvmsq_check_enqueue) | |
374 | CHECK_SET_HOOK(sysvmsq_check_msgrcv) | |
375 | CHECK_SET_HOOK(sysvmsq_check_msgrmid) | |
376 | CHECK_SET_HOOK(sysvmsq_check_msqctl) | |
377 | CHECK_SET_HOOK(sysvmsq_check_msqget) | |
378 | CHECK_SET_HOOK(sysvmsq_check_msqrcv) | |
379 | CHECK_SET_HOOK(sysvmsq_check_msqsnd) | |
380 | CHECK_SET_HOOK(sysvmsq_label_associate) | |
381 | CHECK_SET_HOOK(sysvmsq_label_destroy) | |
382 | CHECK_SET_HOOK(sysvmsq_label_init) | |
383 | CHECK_SET_HOOK(sysvmsq_label_recycle) | |
384 | CHECK_SET_HOOK(sysvsem_check_semctl) | |
385 | CHECK_SET_HOOK(sysvsem_check_semget) | |
386 | CHECK_SET_HOOK(sysvsem_check_semop) | |
387 | CHECK_SET_HOOK(sysvsem_label_associate) | |
388 | CHECK_SET_HOOK(sysvsem_label_destroy) | |
389 | CHECK_SET_HOOK(sysvsem_label_init) | |
390 | CHECK_SET_HOOK(sysvsem_label_recycle) | |
391 | CHECK_SET_HOOK(sysvshm_check_shmat) | |
392 | CHECK_SET_HOOK(sysvshm_check_shmctl) | |
393 | CHECK_SET_HOOK(sysvshm_check_shmdt) | |
394 | CHECK_SET_HOOK(sysvshm_check_shmget) | |
395 | CHECK_SET_HOOK(sysvshm_label_associate) | |
396 | CHECK_SET_HOOK(sysvshm_label_destroy) | |
397 | CHECK_SET_HOOK(sysvshm_label_init) | |
398 | CHECK_SET_HOOK(sysvshm_label_recycle) | |
399 | ||
5ba3f43e | 400 | CHECK_SET_HOOK(proc_notify_exit) |
813fb2f6 | 401 | CHECK_SET_HOOK(mount_check_snapshot_revert) |
743345f9 | 402 | CHECK_SET_HOOK(vnode_check_getattr) |
39037602 A |
403 | CHECK_SET_HOOK(mount_check_snapshot_create) |
404 | CHECK_SET_HOOK(mount_check_snapshot_delete) | |
405 | CHECK_SET_HOOK(vnode_check_clone) | |
7e41aa88 A |
406 | CHECK_SET_HOOK(proc_check_get_cs_info) |
407 | CHECK_SET_HOOK(proc_check_set_cs_info) | |
39236c6e A |
408 | |
409 | CHECK_SET_HOOK(iokit_check_hid_control) | |
410 | ||
411 | CHECK_SET_HOOK(vnode_check_access) | |
412 | CHECK_SET_HOOK(vnode_check_chdir) | |
413 | CHECK_SET_HOOK(vnode_check_chroot) | |
414 | CHECK_SET_HOOK(vnode_check_create) | |
415 | CHECK_SET_HOOK(vnode_check_deleteextattr) | |
416 | CHECK_SET_HOOK(vnode_check_exchangedata) | |
417 | CHECK_SET_HOOK(vnode_check_exec) | |
418 | CHECK_SET_HOOK(vnode_check_getattrlist) | |
419 | CHECK_SET_HOOK(vnode_check_getextattr) | |
420 | CHECK_SET_HOOK(vnode_check_ioctl) | |
421 | CHECK_SET_HOOK(vnode_check_kqfilter) | |
422 | CHECK_SET_HOOK(vnode_check_label_update) | |
423 | CHECK_SET_HOOK(vnode_check_link) | |
424 | CHECK_SET_HOOK(vnode_check_listextattr) | |
425 | CHECK_SET_HOOK(vnode_check_lookup) | |
426 | CHECK_SET_HOOK(vnode_check_open) | |
427 | CHECK_SET_HOOK(vnode_check_read) | |
428 | CHECK_SET_HOOK(vnode_check_readdir) | |
429 | CHECK_SET_HOOK(vnode_check_readlink) | |
430 | CHECK_SET_HOOK(vnode_check_rename_from) | |
431 | CHECK_SET_HOOK(vnode_check_rename_to) | |
432 | CHECK_SET_HOOK(vnode_check_revoke) | |
433 | CHECK_SET_HOOK(vnode_check_select) | |
434 | CHECK_SET_HOOK(vnode_check_setattrlist) | |
435 | CHECK_SET_HOOK(vnode_check_setextattr) | |
436 | CHECK_SET_HOOK(vnode_check_setflags) | |
437 | CHECK_SET_HOOK(vnode_check_setmode) | |
438 | CHECK_SET_HOOK(vnode_check_setowner) | |
439 | CHECK_SET_HOOK(vnode_check_setutimes) | |
440 | CHECK_SET_HOOK(vnode_check_stat) | |
441 | CHECK_SET_HOOK(vnode_check_truncate) | |
442 | CHECK_SET_HOOK(vnode_check_unlink) | |
443 | CHECK_SET_HOOK(vnode_check_write) | |
444 | CHECK_SET_HOOK(vnode_label_associate_devfs) | |
445 | CHECK_SET_HOOK(vnode_label_associate_extattr) | |
446 | CHECK_SET_HOOK(vnode_label_associate_file) | |
447 | CHECK_SET_HOOK(vnode_label_associate_pipe) | |
448 | CHECK_SET_HOOK(vnode_label_associate_posixsem) | |
449 | CHECK_SET_HOOK(vnode_label_associate_posixshm) | |
450 | CHECK_SET_HOOK(vnode_label_associate_singlelabel) | |
451 | CHECK_SET_HOOK(vnode_label_associate_socket) | |
452 | CHECK_SET_HOOK(vnode_label_copy) | |
453 | CHECK_SET_HOOK(vnode_label_destroy) | |
454 | CHECK_SET_HOOK(vnode_label_externalize_audit) | |
455 | CHECK_SET_HOOK(vnode_label_externalize) | |
456 | CHECK_SET_HOOK(vnode_label_init) | |
457 | CHECK_SET_HOOK(vnode_label_internalize) | |
458 | CHECK_SET_HOOK(vnode_label_recycle) | |
459 | CHECK_SET_HOOK(vnode_label_store) | |
460 | CHECK_SET_HOOK(vnode_label_update_extattr) | |
461 | CHECK_SET_HOOK(vnode_label_update) | |
462 | CHECK_SET_HOOK(vnode_notify_create) | |
463 | CHECK_SET_HOOK(vnode_check_signature) | |
464 | CHECK_SET_HOOK(vnode_check_uipc_bind) | |
465 | CHECK_SET_HOOK(vnode_check_uipc_connect) | |
466 | ||
3e170ce0 | 467 | CHECK_SET_HOOK(proc_check_run_cs_invalid) |
39236c6e A |
468 | CHECK_SET_HOOK(proc_check_suspend_resume) |
469 | ||
470 | CHECK_SET_HOOK(thread_userret) | |
471 | ||
472 | CHECK_SET_HOOK(iokit_check_set_properties) | |
473 | ||
474 | CHECK_SET_HOOK(system_check_chud) | |
475 | ||
476 | CHECK_SET_HOOK(vnode_check_searchfs) | |
477 | ||
478 | CHECK_SET_HOOK(priv_check) | |
479 | CHECK_SET_HOOK(priv_grant) | |
480 | ||
481 | CHECK_SET_HOOK(proc_check_map_anon) | |
482 | ||
483 | CHECK_SET_HOOK(vnode_check_fsgetpath) | |
484 | ||
485 | CHECK_SET_HOOK(iokit_check_open) | |
486 | ||
487 | CHECK_SET_HOOK(proc_check_ledger) | |
488 | ||
489 | CHECK_SET_HOOK(vnode_notify_rename) | |
490 | ||
39037602 A |
491 | CHECK_SET_HOOK(vnode_check_setacl) |
492 | ||
493 | CHECK_SET_HOOK(vnode_notify_deleteextattr) | |
39236c6e A |
494 | |
495 | CHECK_SET_HOOK(system_check_kas_info) | |
496 | ||
5ba3f43e | 497 | CHECK_SET_HOOK(vnode_check_lookup_preflight) |
39236c6e A |
498 | |
499 | CHECK_SET_HOOK(vnode_notify_open) | |
500 | ||
501 | CHECK_SET_HOOK(system_check_info) | |
502 | ||
503 | CHECK_SET_HOOK(pty_notify_grant) | |
504 | CHECK_SET_HOOK(pty_notify_close) | |
505 | ||
506 | CHECK_SET_HOOK(vnode_find_sigs) | |
507 | ||
508 | ||
509 | CHECK_SET_HOOK(kext_check_load) | |
510 | CHECK_SET_HOOK(kext_check_unload) | |
511 | ||
512 | CHECK_SET_HOOK(proc_check_proc_info) | |
513 | ||
514 | CHECK_SET_HOOK(vnode_notify_link) | |
515 | ||
fe8ab488 A |
516 | CHECK_SET_HOOK(iokit_check_filter_properties) |
517 | CHECK_SET_HOOK(iokit_check_get_property) | |
6d2010ae A |
518 | }; |
519 | ||
520 | /* | |
521 | * Policy definition | |
522 | */ | |
5ba3f43e | 523 | static SECURITY_READ_ONLY_LATE(struct mac_policy_conf) policy_conf = { |
6d2010ae A |
524 | .mpc_name = "CHECK", |
525 | .mpc_fullname = "Check Assumptions Policy", | |
526 | .mpc_field_off = NULL, /* no label slot */ | |
527 | .mpc_labelnames = NULL, /* no policy label names */ | |
528 | .mpc_labelname_count = 0, /* count of label names is 0 */ | |
529 | .mpc_ops = &policy_ops, /* policy operations */ | |
530 | .mpc_loadtime_flags = 0, | |
531 | .mpc_runtime_flags = 0, | |
532 | }; | |
533 | ||
5ba3f43e | 534 | static SECURITY_READ_ONLY_LATE(mac_policy_handle_t) policy_handle; |
6d2010ae A |
535 | |
536 | /* | |
537 | * Init routine; for a loadable policy, this would be called during the KEXT | |
538 | * initialization; we're going to call this from bsd_init() if the boot | |
539 | * argument for checking is present. | |
540 | */ | |
541 | errno_t | |
542 | check_policy_init(int flags) | |
543 | { | |
544 | /* Only instantiate the module if we have been asked to do checking */ | |
545 | if (!flags) | |
546 | return 0; | |
547 | ||
548 | policy_flags = flags; | |
549 | ||
550 | return mac_policy_register(&policy_conf, &policy_handle, NULL); | |
551 | } |