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