]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/security/mac_test/mac_test.c
Remove empty entry point functions (init, destroy, syscall) from
[FreeBSD/FreeBSD.git] / sys / security / mac_test / mac_test.c
1 /*-
2  * Copyright (c) 1999-2002, 2007 Robert N. M. Watson
3  * Copyright (c) 2001-2005 McAfee, Inc.
4  * All rights reserved.
5  *
6  * This software was developed by Robert Watson for the TrustedBSD Project.
7  *
8  * This software was developed for the FreeBSD Project in part by McAfee
9  * Research, the Security Research Division of McAfee, Inc. under
10  * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA
11  * CHATS research program.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $FreeBSD$
35  */
36
37 /*
38  * Developed by the TrustedBSD Project.
39  * Generic mandatory access module that does nothing.
40  */
41
42 #include <sys/types.h>
43 #include <sys/param.h>
44 #include <sys/acl.h>
45 #include <sys/conf.h>
46 #include <sys/kdb.h>
47 #include <sys/extattr.h>
48 #include <sys/kernel.h>
49 #include <sys/ksem.h>
50 #include <sys/malloc.h>
51 #include <sys/mount.h>
52 #include <sys/proc.h>
53 #include <sys/systm.h>
54 #include <sys/sysproto.h>
55 #include <sys/sysent.h>
56 #include <sys/vnode.h>
57 #include <sys/file.h>
58 #include <sys/socket.h>
59 #include <sys/socketvar.h>
60 #include <sys/sx.h>
61 #include <sys/sysctl.h>
62 #include <sys/msg.h>
63 #include <sys/sem.h>
64 #include <sys/shm.h>
65
66 #include <fs/devfs/devfs.h>
67
68 #include <net/bpfdesc.h>
69 #include <net/if.h>
70 #include <net/if_types.h>
71 #include <net/if_var.h>
72
73 #include <vm/vm.h>
74
75 #include <security/mac/mac_policy.h>
76
77 SYSCTL_DECL(_security_mac);
78
79 SYSCTL_NODE(_security_mac, OID_AUTO, test, CTLFLAG_RW, 0,
80     "TrustedBSD mac_test policy controls");
81
82 static int      mac_test_enabled = 1;
83 SYSCTL_INT(_security_mac_test, OID_AUTO, enabled, CTLFLAG_RW,
84     &mac_test_enabled, 0, "Enforce test policy");
85
86 #define BPFMAGIC        0xfe1ad1b6
87 #define DEVFSMAGIC      0x9ee79c32
88 #define IFNETMAGIC      0xc218b120
89 #define INPCBMAGIC      0x4440f7bb
90 #define IPQMAGIC        0x206188ef
91 #define MBUFMAGIC       0xbbefa5bb
92 #define MOUNTMAGIC      0xc7c46e47
93 #define SOCKETMAGIC     0x9199c6cd
94 #define SYSVIPCMSQMAGIC 0xea672391
95 #define SYSVIPCMSGMAGIC 0x8bbba61e
96 #define SYSVIPCSEMMAGIC 0x896e8a0b
97 #define SYSVIPCSHMMAGIC 0x76119ab0
98 #define PIPEMAGIC       0xdc6c9919
99 #define POSIXSEMMAGIC   0x78ae980c
100 #define PROCMAGIC       0x3b4be98f
101 #define CREDMAGIC       0x9a5a4987
102 #define VNODEMAGIC      0x1a67a45c
103 #define EXMAGIC         0x849ba1fd
104
105 #define SLOT(x) mac_label_get((x), test_slot)
106 #define SLOT_SET(x, v)  mac_label_set((x), test_slot, (v))
107
108 #define ASSERT_BPF_LABEL(x)     KASSERT(SLOT(x) == BPFMAGIC ||          \
109         SLOT(x) == 0, ("%s: Bad BPF label", __func__ ))
110 #define ASSERT_DEVFS_LABEL(x)   KASSERT(SLOT(x) == DEVFSMAGIC ||        \
111         SLOT(x) == 0, ("%s: Bad DEVFS label", __func__ ))
112 #define ASSERT_IFNET_LABEL(x)   KASSERT(SLOT(x) == IFNETMAGIC ||        \
113         SLOT(x) == 0, ("%s: Bad IFNET label", __func__ ))
114 #define ASSERT_INPCB_LABEL(x)   KASSERT(SLOT(x) == INPCBMAGIC ||        \
115         SLOT(x) == 0, ("%s: Bad INPCB label", __func__ ))
116 #define ASSERT_IPQ_LABEL(x)     KASSERT(SLOT(x) == IPQMAGIC ||  \
117         SLOT(x) == 0, ("%s: Bad IPQ label", __func__ ))
118 #define ASSERT_MBUF_LABEL(x)    KASSERT(x == NULL ||                    \
119         SLOT(x) == MBUFMAGIC || SLOT(x) == 0,                           \
120         ("%s: Bad MBUF label", __func__ ))
121 #define ASSERT_MOUNT_LABEL(x)   KASSERT(SLOT(x) == MOUNTMAGIC ||        \
122         SLOT(x) == 0, ("%s: Bad MOUNT label", __func__ ))
123 #define ASSERT_SOCKET_LABEL(x)  KASSERT(SLOT(x) == SOCKETMAGIC ||       \
124         SLOT(x) == 0, ("%s: Bad SOCKET label", __func__ ))
125 #define ASSERT_SYSVIPCMSQ_LABEL(x) KASSERT(SLOT(x) == SYSVIPCMSQMAGIC || \
126         SLOT(x) == 0, ("%s: Bad SYSVIPCMSQ label", __func__ ))
127 #define ASSERT_SYSVIPCMSG_LABEL(x) KASSERT(SLOT(x) == SYSVIPCMSGMAGIC || \
128         SLOT(x) == 0, ("%s: Bad SYSVIPCMSG label", __func__ ))
129 #define ASSERT_SYSVIPCSEM_LABEL(x) KASSERT(SLOT(x) == SYSVIPCSEMMAGIC || \
130         SLOT(x) == 0, ("%s: Bad SYSVIPCSEM label", __func__ ))
131 #define ASSERT_SYSVIPCSHM_LABEL(x) KASSERT(SLOT(x) == SYSVIPCSHMMAGIC || \
132         SLOT(x) == 0, ("%s: Bad SYSVIPCSHM label", __func__ ))
133 #define ASSERT_PIPE_LABEL(x)    KASSERT(SLOT(x) == PIPEMAGIC ||         \
134         SLOT(x) == 0, ("%s: Bad PIPE label", __func__ ))
135 #define ASSERT_POSIX_LABEL(x)   KASSERT(SLOT(x) == POSIXSEMMAGIC ||     \
136         SLOT(x) == 0, ("%s: Bad POSIX ksem label", __func__ ))
137 #define ASSERT_PROC_LABEL(x)    KASSERT(SLOT(x) == PROCMAGIC ||         \
138         SLOT(x) == 0, ("%s: Bad PROC label", __func__ ))
139 #define ASSERT_CRED_LABEL(x)    KASSERT(SLOT(x) == CREDMAGIC ||         \
140         SLOT(x) == 0, ("%s: Bad CRED label", __func__ ))
141 #define ASSERT_VNODE_LABEL(x)   KASSERT(SLOT(x) == VNODEMAGIC ||        \
142         SLOT(x) == 0, ("%s: Bad VNODE label", __func__ ))
143
144 static int      test_slot;
145 SYSCTL_INT(_security_mac_test, OID_AUTO, slot, CTLFLAG_RD,
146     &test_slot, 0, "Slot allocated by framework");
147
148 static int      init_count_bpfdesc;
149 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_bpfdesc, CTLFLAG_RD,
150     &init_count_bpfdesc, 0, "bpfdesc init calls");
151 static int      init_count_cred;
152 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_cred, CTLFLAG_RD,
153     &init_count_cred, 0, "cred init calls");
154 static int      init_count_devfsdirent;
155 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_devfsdirent, CTLFLAG_RD,
156     &init_count_devfsdirent, 0, "devfsdirent init calls");
157 static int      init_count_ifnet;
158 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_ifnet, CTLFLAG_RD,
159     &init_count_ifnet, 0, "ifnet init calls");
160 static int      init_count_inpcb;
161 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_inpcb, CTLFLAG_RD,
162     &init_count_inpcb, 0, "inpcb init calls");
163 static int      init_count_sysv_msg;
164 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_sysv_msg, CTLFLAG_RD,
165     &init_count_sysv_msg, 0, "ipc_msg init calls");
166 static int      init_count_sysv_msq;
167 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_sysv_msq, CTLFLAG_RD,
168     &init_count_sysv_msq, 0, "ipc_msq init calls");
169 static int      init_count_sysv_sem;
170 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_sysv_sem, CTLFLAG_RD,
171     &init_count_sysv_sem, 0, "ipc_sema init calls");
172 static int      init_count_sysv_shm;
173 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_sysv_shm, CTLFLAG_RD,
174     &init_count_sysv_shm, 0, "ipc_shm init calls");
175 static int      init_count_ipq;
176 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_ipq, CTLFLAG_RD,
177     &init_count_ipq, 0, "ipq init calls");
178 static int      init_count_mbuf;
179 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_mbuf, CTLFLAG_RD,
180     &init_count_mbuf, 0, "mbuf init calls");
181 static int      init_count_mount;
182 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_mount, CTLFLAG_RD,
183     &init_count_mount, 0, "mount init calls");
184 static int      init_count_mount_fslabel;
185 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_mount_fslabel, CTLFLAG_RD,
186     &init_count_mount_fslabel, 0, "mount_fslabel init calls");
187 static int      init_count_socket;
188 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_socket, CTLFLAG_RD,
189     &init_count_socket, 0, "socket init calls");
190 static int      init_count_socket_peerlabel;
191 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_socket_peerlabel,
192     CTLFLAG_RD, &init_count_socket_peerlabel, 0,
193     "socket_peerlabel init calls");
194 static int      init_count_pipe;
195 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_pipe, CTLFLAG_RD,
196     &init_count_pipe, 0, "pipe init calls");
197 static int      init_count_posixsems;
198 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_posixsems, CTLFLAG_RD,
199     &init_count_posixsems, 0, "posix sems init calls");
200 static int      init_count_proc;
201 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_proc, CTLFLAG_RD,
202     &init_count_proc, 0, "proc init calls");
203 static int      init_count_vnode;
204 SYSCTL_INT(_security_mac_test, OID_AUTO, init_count_vnode, CTLFLAG_RD,
205     &init_count_vnode, 0, "vnode init calls");
206
207 static int      destroy_count_bpfdesc;
208 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_bpfdesc, CTLFLAG_RD,
209     &destroy_count_bpfdesc, 0, "bpfdesc destroy calls");
210 static int      destroy_count_cred;
211 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_cred, CTLFLAG_RD,
212     &destroy_count_cred, 0, "cred destroy calls");
213 static int      destroy_count_devfsdirent;
214 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_devfsdirent, CTLFLAG_RD,
215     &destroy_count_devfsdirent, 0, "devfsdirent destroy calls");
216 static int      destroy_count_ifnet;
217 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_ifnet, CTLFLAG_RD,
218     &destroy_count_ifnet, 0, "ifnet destroy calls");
219 static int      destroy_count_inpcb;
220 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_inpcb, CTLFLAG_RD,
221     &destroy_count_inpcb, 0, "inpcb destroy calls");
222 static int      destroy_count_sysv_msg;
223 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_sysv_msg, CTLFLAG_RD,
224     &destroy_count_sysv_msg, 0, "ipc_msg destroy calls");
225 static int      destroy_count_sysv_msq;
226 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_sysv_msq, CTLFLAG_RD,
227     &destroy_count_sysv_msq, 0, "ipc_msq destroy calls");
228 static int      destroy_count_sysv_sem;
229 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_sysv_sem, CTLFLAG_RD,
230     &destroy_count_sysv_sem, 0, "ipc_sema destroy calls");
231 static int      destroy_count_sysv_shm;
232 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_sysv_shm, CTLFLAG_RD,
233     &destroy_count_sysv_shm, 0, "ipc_shm destroy calls");
234 static int      destroy_count_ipq;
235 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_ipq, CTLFLAG_RD,
236     &destroy_count_ipq, 0, "ipq destroy calls");
237 static int      destroy_count_mbuf;
238 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_mbuf, CTLFLAG_RD,
239     &destroy_count_mbuf, 0, "mbuf destroy calls");
240 static int      destroy_count_mount;
241 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_mount, CTLFLAG_RD,
242     &destroy_count_mount, 0, "mount destroy calls");
243 static int      destroy_count_mount_fslabel;
244 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_mount_fslabel,
245     CTLFLAG_RD, &destroy_count_mount_fslabel, 0,
246     "mount_fslabel destroy calls");
247 static int      destroy_count_socket;
248 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_socket, CTLFLAG_RD,
249     &destroy_count_socket, 0, "socket destroy calls");
250 static int      destroy_count_socket_peerlabel;
251 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_socket_peerlabel,
252     CTLFLAG_RD, &destroy_count_socket_peerlabel, 0,
253     "socket_peerlabel destroy calls");
254 static int      destroy_count_pipe;
255 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_pipe, CTLFLAG_RD,
256     &destroy_count_pipe, 0, "pipe destroy calls");
257 static int      destroy_count_posixsems;
258 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_posixsems, CTLFLAG_RD,
259     &destroy_count_posixsems, 0, "posix sems destroy calls");
260 static int      destroy_count_proc;
261 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_proc, CTLFLAG_RD,
262     &destroy_count_proc, 0, "proc destroy calls");
263 static int      destroy_count_vnode;
264 SYSCTL_INT(_security_mac_test, OID_AUTO, destroy_count_vnode, CTLFLAG_RD,
265     &destroy_count_vnode, 0, "vnode destroy calls");
266
267 static int externalize_count;
268 SYSCTL_INT(_security_mac_test, OID_AUTO, externalize_count, CTLFLAG_RD,
269     &externalize_count, 0, "Subject/object externalize calls");
270 static int internalize_count;
271 SYSCTL_INT(_security_mac_test, OID_AUTO, internalize_count, CTLFLAG_RD,
272     &internalize_count, 0, "Subject/object internalize calls");
273
274 #ifdef KDB
275 #define DEBUGGER(x)     kdb_enter(x)
276 #else
277 #define DEBUGGER(x)     printf("mac_test: %s\n", (x))
278 #endif
279
280 /*
281  * Label operations.
282  */
283 static void
284 mac_test_init_bpfdesc_label(struct label *label)
285 {
286
287         SLOT_SET(label, BPFMAGIC);
288         atomic_add_int(&init_count_bpfdesc, 1);
289 }
290
291 static void
292 mac_test_init_cred_label(struct label *label)
293 {
294
295         SLOT_SET(label, CREDMAGIC);
296         atomic_add_int(&init_count_cred, 1);
297 }
298
299 static void
300 mac_test_init_devfsdirent_label(struct label *label)
301 {
302
303         SLOT_SET(label, DEVFSMAGIC);
304         atomic_add_int(&init_count_devfsdirent, 1);
305 }
306
307 static void
308 mac_test_init_ifnet_label(struct label *label)
309 {
310
311         SLOT_SET(label, IFNETMAGIC);
312         atomic_add_int(&init_count_ifnet, 1);
313 }
314
315 static int
316 mac_test_init_inpcb_label(struct label *label, int flag)
317 {
318
319         if (flag & M_WAITOK)
320                 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
321                     "mac_test_init_inpcb_label() at %s:%d", __FILE__,
322                     __LINE__);
323
324         SLOT_SET(label, INPCBMAGIC);
325         atomic_add_int(&init_count_inpcb, 1);
326         return (0);
327 }
328
329 static void
330 mac_test_init_sysv_msgmsg_label(struct label *label)
331 {
332         SLOT_SET(label, SYSVIPCMSGMAGIC);
333         atomic_add_int(&init_count_sysv_msg, 1);
334 }
335
336 static void
337 mac_test_init_sysv_msgqueue_label(struct label *label)
338 {
339         SLOT_SET(label, SYSVIPCMSQMAGIC);
340         atomic_add_int(&init_count_sysv_msq, 1);
341 }
342
343 static void
344 mac_test_init_sysv_sem_label(struct label *label)
345 {
346         SLOT_SET(label, SYSVIPCSEMMAGIC);
347         atomic_add_int(&init_count_sysv_sem, 1);
348 }
349
350 static void
351 mac_test_init_sysv_shm_label(struct label *label)
352 {
353         SLOT_SET(label, SYSVIPCSHMMAGIC);
354         atomic_add_int(&init_count_sysv_shm, 1);
355 }
356
357 static int
358 mac_test_init_ipq_label(struct label *label, int flag)
359 {
360
361         if (flag & M_WAITOK)
362                 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
363                     "mac_test_init_ipq_label() at %s:%d", __FILE__,
364                     __LINE__);
365
366         SLOT_SET(label, IPQMAGIC);
367         atomic_add_int(&init_count_ipq, 1);
368         return (0);
369 }
370
371 static int
372 mac_test_init_mbuf_label(struct label *label, int flag)
373 {
374
375         if (flag & M_WAITOK)
376                 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
377                     "mac_test_init_mbuf_label() at %s:%d", __FILE__,
378                     __LINE__);
379
380         SLOT_SET(label, MBUFMAGIC);
381         atomic_add_int(&init_count_mbuf, 1);
382         return (0);
383 }
384
385 static void
386 mac_test_init_mount_label(struct label *label)
387 {
388
389         SLOT_SET(label, MOUNTMAGIC);
390         atomic_add_int(&init_count_mount, 1);
391 }
392
393 static void
394 mac_test_init_mount_fs_label(struct label *label)
395 {
396
397         SLOT_SET(label, MOUNTMAGIC);
398         atomic_add_int(&init_count_mount_fslabel, 1);
399 }
400
401 static int
402 mac_test_init_socket_label(struct label *label, int flag)
403 {
404
405         if (flag & M_WAITOK)
406                 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
407                     "mac_test_init_socket_label() at %s:%d", __FILE__,
408                     __LINE__);
409
410         SLOT_SET(label, SOCKETMAGIC);
411         atomic_add_int(&init_count_socket, 1);
412         return (0);
413 }
414
415 static int
416 mac_test_init_socket_peer_label(struct label *label, int flag)
417 {
418
419         if (flag & M_WAITOK)
420                 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
421                     "mac_test_init_socket_peer_label() at %s:%d", __FILE__,
422                     __LINE__);
423
424         SLOT_SET(label, SOCKETMAGIC);
425         atomic_add_int(&init_count_socket_peerlabel, 1);
426         return (0);
427 }
428
429 static void
430 mac_test_init_pipe_label(struct label *label)
431 {
432
433         SLOT_SET(label, PIPEMAGIC);
434         atomic_add_int(&init_count_pipe, 1);
435 }
436
437 static void
438 mac_test_init_posix_sem_label(struct label *label)
439 {
440
441         SLOT_SET(label, POSIXSEMMAGIC);
442         atomic_add_int(&init_count_posixsems, 1);
443 }
444
445 static void
446 mac_test_init_proc_label(struct label *label)
447 {
448
449         SLOT_SET(label, PROCMAGIC);
450         atomic_add_int(&init_count_proc, 1);
451 }
452
453 static void
454 mac_test_init_vnode_label(struct label *label)
455 {
456
457         SLOT_SET(label, VNODEMAGIC);
458         atomic_add_int(&init_count_vnode, 1);
459 }
460
461 static void
462 mac_test_destroy_bpfdesc_label(struct label *label)
463 {
464
465         if (SLOT(label) == BPFMAGIC || SLOT(label) == 0) {
466                 atomic_add_int(&destroy_count_bpfdesc, 1);
467                 SLOT_SET(label, EXMAGIC);
468         } else if (SLOT(label) == EXMAGIC) {
469                 DEBUGGER("mac_test_destroy_bpfdesc: dup destroy");
470         } else {
471                 DEBUGGER("mac_test_destroy_bpfdesc: corrupted label");
472         }
473 }
474
475 static void
476 mac_test_destroy_cred_label(struct label *label)
477 {
478
479         if (SLOT(label) == CREDMAGIC || SLOT(label) == 0) {
480                 atomic_add_int(&destroy_count_cred, 1);
481                 SLOT_SET(label, EXMAGIC);
482         } else if (SLOT(label) == EXMAGIC) {
483                 DEBUGGER("mac_test_destroy_cred: dup destroy");
484         } else {
485                 DEBUGGER("mac_test_destroy_cred: corrupted label");
486         }
487 }
488
489 static void
490 mac_test_destroy_devfsdirent_label(struct label *label)
491 {
492
493         if (SLOT(label) == DEVFSMAGIC || SLOT(label) == 0) {
494                 atomic_add_int(&destroy_count_devfsdirent, 1);
495                 SLOT_SET(label, EXMAGIC);
496         } else if (SLOT(label) == EXMAGIC) {
497                 DEBUGGER("mac_test_destroy_devfsdirent: dup destroy");
498         } else {
499                 DEBUGGER("mac_test_destroy_devfsdirent: corrupted label");
500         }
501 }
502
503 static void
504 mac_test_destroy_ifnet_label(struct label *label)
505 {
506
507         if (SLOT(label) == IFNETMAGIC || SLOT(label) == 0) {
508                 atomic_add_int(&destroy_count_ifnet, 1);
509                 SLOT_SET(label, EXMAGIC);
510         } else if (SLOT(label) == EXMAGIC) {
511                 DEBUGGER("mac_test_destroy_ifnet: dup destroy");
512         } else {
513                 DEBUGGER("mac_test_destroy_ifnet: corrupted label");
514         }
515 }
516
517 static void
518 mac_test_destroy_inpcb_label(struct label *label)
519 {
520
521         if (SLOT(label) == INPCBMAGIC || SLOT(label) == 0) {
522                 atomic_add_int(&destroy_count_inpcb, 1);
523                 SLOT_SET(label, EXMAGIC);
524         } else if (SLOT(label) == EXMAGIC) {
525                 DEBUGGER("mac_test_destroy_inpcb: dup destroy");
526         } else {
527                 DEBUGGER("mac_test_destroy_inpcb: corrupted label");
528         }
529 }
530
531 static void
532 mac_test_destroy_sysv_msgmsg_label(struct label *label)
533 {
534
535         if (SLOT(label) == SYSVIPCMSGMAGIC || SLOT(label) == 0) {
536                 atomic_add_int(&destroy_count_sysv_msg, 1);
537                 SLOT_SET(label, EXMAGIC);
538         } else if (SLOT(label) == EXMAGIC) {
539                 DEBUGGER("mac_test_destroy_sysv_msgmsg_label: dup destroy");
540         } else {
541                 DEBUGGER(
542                     "mac_test_destroy_sysv_msgmsg_label: corrupted label");
543         }
544 }
545
546 static void
547 mac_test_destroy_sysv_msgqueue_label(struct label *label)
548 {
549
550         if (SLOT(label) == SYSVIPCMSQMAGIC || SLOT(label) == 0) {
551                 atomic_add_int(&destroy_count_sysv_msq, 1);
552                 SLOT_SET(label, EXMAGIC);
553         } else if (SLOT(label) == EXMAGIC) {
554                 DEBUGGER("mac_test_destroy_sysv_msgqueue_label: dup destroy");
555         } else {
556                 DEBUGGER(
557                     "mac_test_destroy_sysv_msgqueue_label: corrupted label");
558         }
559 }
560
561 static void
562 mac_test_destroy_sysv_sem_label(struct label *label)
563 {
564
565         if (SLOT(label) == SYSVIPCSEMMAGIC || SLOT(label) == 0) {
566                 atomic_add_int(&destroy_count_sysv_sem, 1);
567                 SLOT_SET(label, EXMAGIC);
568         } else if (SLOT(label) == EXMAGIC) {
569                 DEBUGGER("mac_test_destroy_sysv_sem_label: dup destroy");
570         } else {
571                 DEBUGGER("mac_test_destroy_sysv_sem_label: corrupted label");
572         }
573 }
574
575 static void
576 mac_test_destroy_sysv_shm_label(struct label *label)
577 {
578
579         if (SLOT(label) == SYSVIPCSHMMAGIC || SLOT(label) == 0) {
580                 atomic_add_int(&destroy_count_sysv_shm, 1);
581                 SLOT_SET(label, EXMAGIC);
582         } else if (SLOT(label) == EXMAGIC) {
583                 DEBUGGER("mac_test_destroy_sysv_shm_label: dup destroy");
584         } else {
585                 DEBUGGER("mac_test_destroy_sysv_shm_label: corrupted label");
586         }
587 }
588
589 static void
590 mac_test_destroy_ipq_label(struct label *label)
591 {
592
593         if (SLOT(label) == IPQMAGIC || SLOT(label) == 0) {
594                 atomic_add_int(&destroy_count_ipq, 1);
595                 SLOT_SET(label, EXMAGIC);
596         } else if (SLOT(label) == EXMAGIC) {
597                 DEBUGGER("mac_test_destroy_ipq: dup destroy");
598         } else {
599                 DEBUGGER("mac_test_destroy_ipq: corrupted label");
600         }
601 }
602
603 static void
604 mac_test_destroy_mbuf_label(struct label *label)
605 {
606
607         /*
608          * If we're loaded dynamically, there may be mbufs in flight that
609          * didn't have label storage allocated for them.  Handle this
610          * gracefully.
611          */
612         if (label == NULL)
613                 return;
614
615         if (SLOT(label) == MBUFMAGIC || SLOT(label) == 0) {
616                 atomic_add_int(&destroy_count_mbuf, 1);
617                 SLOT_SET(label, EXMAGIC);
618         } else if (SLOT(label) == EXMAGIC) {
619                 DEBUGGER("mac_test_destroy_mbuf: dup destroy");
620         } else {
621                 DEBUGGER("mac_test_destroy_mbuf: corrupted label");
622         }
623 }
624
625 static void
626 mac_test_destroy_mount_label(struct label *label)
627 {
628
629         if ((SLOT(label) == MOUNTMAGIC || SLOT(label) == 0)) {
630                 atomic_add_int(&destroy_count_mount, 1);
631                 SLOT_SET(label, EXMAGIC);
632         } else if (SLOT(label) == EXMAGIC) {
633                 DEBUGGER("mac_test_destroy_mount: dup destroy");
634         } else {
635                 DEBUGGER("mac_test_destroy_mount: corrupted label");
636         }
637 }
638
639 static void
640 mac_test_destroy_mount_fs_label(struct label *label)
641 {
642
643         if ((SLOT(label) == MOUNTMAGIC || SLOT(label) == 0)) {
644                 atomic_add_int(&destroy_count_mount_fslabel, 1);
645                 SLOT_SET(label, EXMAGIC);
646         } else if (SLOT(label) == EXMAGIC) {
647                 DEBUGGER("mac_test_destroy_mount_fslabel: dup destroy");
648         } else {
649                 DEBUGGER("mac_test_destroy_mount_fslabel: corrupted label");
650         }
651 }
652
653 static void
654 mac_test_destroy_socket_label(struct label *label)
655 {
656
657         if ((SLOT(label) == SOCKETMAGIC || SLOT(label) == 0)) {
658                 atomic_add_int(&destroy_count_socket, 1);
659                 SLOT_SET(label, EXMAGIC);
660         } else if (SLOT(label) == EXMAGIC) {
661                 DEBUGGER("mac_test_destroy_socket: dup destroy");
662         } else {
663                 DEBUGGER("mac_test_destroy_socket: corrupted label");
664         }
665 }
666
667 static void
668 mac_test_destroy_socket_peer_label(struct label *label)
669 {
670
671         if ((SLOT(label) == SOCKETMAGIC || SLOT(label) == 0)) {
672                 atomic_add_int(&destroy_count_socket_peerlabel, 1);
673                 SLOT_SET(label, EXMAGIC);
674         } else if (SLOT(label) == EXMAGIC) {
675                 DEBUGGER("mac_test_destroy_socket_peerlabel: dup destroy");
676         } else {
677                 DEBUGGER("mac_test_destroy_socket_peerlabel: corrupted label");
678         }
679 }
680
681 static void
682 mac_test_destroy_pipe_label(struct label *label)
683 {
684
685         if ((SLOT(label) == PIPEMAGIC || SLOT(label) == 0)) {
686                 atomic_add_int(&destroy_count_pipe, 1);
687                 SLOT_SET(label, EXMAGIC);
688         } else if (SLOT(label) == EXMAGIC) {
689                 DEBUGGER("mac_test_destroy_pipe: dup destroy");
690         } else {
691                 DEBUGGER("mac_test_destroy_pipe: corrupted label");
692         }
693 }
694
695 static void
696 mac_test_destroy_posix_sem_label(struct label *label)
697 {
698
699         if ((SLOT(label) == POSIXSEMMAGIC || SLOT(label) == 0)) {
700                 atomic_add_int(&destroy_count_posixsems, 1);
701                 SLOT_SET(label, EXMAGIC);
702         } else if (SLOT(label) == EXMAGIC) {
703                 DEBUGGER("mac_test_destroy_posix_sem: dup destroy");
704         } else {
705                 DEBUGGER("mac_test_destroy_posix_sem: corrupted label");
706         }
707 }
708
709 static void
710 mac_test_destroy_proc_label(struct label *label)
711 {
712
713         if ((SLOT(label) == PROCMAGIC || SLOT(label) == 0)) {
714                 atomic_add_int(&destroy_count_proc, 1);
715                 SLOT_SET(label, EXMAGIC);
716         } else if (SLOT(label) == EXMAGIC) {
717                 DEBUGGER("mac_test_destroy_proc: dup destroy");
718         } else {
719                 DEBUGGER("mac_test_destroy_proc: corrupted label");
720         }
721 }
722
723 static void
724 mac_test_destroy_vnode_label(struct label *label)
725 {
726
727         if (SLOT(label) == VNODEMAGIC || SLOT(label) == 0) {
728                 atomic_add_int(&destroy_count_vnode, 1);
729                 SLOT_SET(label, EXMAGIC);
730         } else if (SLOT(label) == EXMAGIC) {
731                 DEBUGGER("mac_test_destroy_vnode: dup destroy");
732         } else {
733                 DEBUGGER("mac_test_destroy_vnode: corrupted label");
734         }
735 }
736
737 static void
738 mac_test_copy_cred_label(struct label *src, struct label *dest)
739 {
740
741         ASSERT_CRED_LABEL(src);
742         ASSERT_CRED_LABEL(dest);
743 }
744
745 static void
746 mac_test_copy_ifnet_label(struct label *src, struct label *dest)
747 {
748
749         ASSERT_IFNET_LABEL(src);
750         ASSERT_IFNET_LABEL(dest);
751 }
752
753 static void
754 mac_test_copy_mbuf_label(struct label *src, struct label *dest)
755 {
756
757         ASSERT_MBUF_LABEL(src);
758         ASSERT_MBUF_LABEL(dest);
759 }
760
761 static void
762 mac_test_copy_pipe_label(struct label *src, struct label *dest)
763 {
764
765         ASSERT_PIPE_LABEL(src);
766         ASSERT_PIPE_LABEL(dest);
767 }
768
769 static void
770 mac_test_copy_socket_label(struct label *src, struct label *dest)
771 {
772
773         ASSERT_SOCKET_LABEL(src);
774         ASSERT_SOCKET_LABEL(dest);
775 }
776
777 static void
778 mac_test_copy_vnode_label(struct label *src, struct label *dest)
779 {
780
781         ASSERT_VNODE_LABEL(src);
782         ASSERT_VNODE_LABEL(dest);
783 }
784
785 static int
786 mac_test_externalize_label(struct label *label, char *element_name,
787     struct sbuf *sb, int *claimed)
788 {
789
790         atomic_add_int(&externalize_count, 1);
791
792         KASSERT(SLOT(label) != EXMAGIC,
793             ("mac_test_externalize_label: destroyed label"));
794
795         return (0);
796 }
797
798 static int
799 mac_test_internalize_label(struct label *label, char *element_name,
800     char *element_data, int *claimed)
801 {
802
803         atomic_add_int(&internalize_count, 1);
804
805         KASSERT(SLOT(label) != EXMAGIC,
806             ("mac_test_internalize_label: destroyed label"));
807
808         return (0);
809 }
810
811 /*
812  * Labeling event operations: file system objects, and things that look
813  * a lot like file system objects.
814  */
815 static void
816 mac_test_associate_vnode_devfs(struct mount *mp, struct label *fslabel,
817     struct devfs_dirent *de, struct label *delabel, struct vnode *vp,
818     struct label *vlabel)
819 {
820
821         ASSERT_MOUNT_LABEL(fslabel);
822         ASSERT_DEVFS_LABEL(delabel);
823         ASSERT_VNODE_LABEL(vlabel);
824 }
825
826 static int
827 mac_test_associate_vnode_extattr(struct mount *mp, struct label *fslabel,
828     struct vnode *vp, struct label *vlabel)
829 {
830
831         ASSERT_MOUNT_LABEL(fslabel);
832         ASSERT_VNODE_LABEL(vlabel);
833         return (0);
834 }
835
836 static void
837 mac_test_associate_vnode_singlelabel(struct mount *mp,
838     struct label *fslabel, struct vnode *vp, struct label *vlabel)
839 {
840
841         ASSERT_MOUNT_LABEL(fslabel);
842         ASSERT_VNODE_LABEL(vlabel);
843 }
844
845 static void
846 mac_test_create_devfs_device(struct ucred *cred, struct mount *mp,
847     struct cdev *dev, struct devfs_dirent *devfs_dirent, struct label *label)
848 {
849
850         if (cred != NULL) {
851                 ASSERT_CRED_LABEL(cred->cr_label);
852         }
853         ASSERT_DEVFS_LABEL(label);
854 }
855
856 static void
857 mac_test_create_devfs_directory(struct mount *mp, char *dirname,
858     int dirnamelen, struct devfs_dirent *devfs_dirent, struct label *label)
859 {
860
861         ASSERT_DEVFS_LABEL(label);
862 }
863
864 static void
865 mac_test_create_devfs_symlink(struct ucred *cred, struct mount *mp,
866     struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de,
867     struct label *delabel)
868 {
869
870         ASSERT_CRED_LABEL(cred->cr_label);
871         ASSERT_DEVFS_LABEL(ddlabel);
872         ASSERT_DEVFS_LABEL(delabel);
873 }
874
875 static int
876 mac_test_create_vnode_extattr(struct ucred *cred, struct mount *mp,
877     struct label *fslabel, struct vnode *dvp, struct label *dlabel,
878     struct vnode *vp, struct label *vlabel, struct componentname *cnp)
879 {
880
881         ASSERT_CRED_LABEL(cred->cr_label);
882         ASSERT_MOUNT_LABEL(fslabel);
883         ASSERT_VNODE_LABEL(dlabel);
884
885         return (0);
886 }
887
888 static void
889 mac_test_create_mount(struct ucred *cred, struct mount *mp,
890     struct label *mntlabel, struct label *fslabel)
891 {
892
893         ASSERT_CRED_LABEL(cred->cr_label);
894         ASSERT_MOUNT_LABEL(mntlabel);
895         ASSERT_MOUNT_LABEL(fslabel);
896 }
897
898 static void
899 mac_test_relabel_vnode(struct ucred *cred, struct vnode *vp,
900     struct label *vnodelabel, struct label *label)
901 {
902
903         ASSERT_CRED_LABEL(cred->cr_label);
904         ASSERT_VNODE_LABEL(vnodelabel);
905         ASSERT_VNODE_LABEL(label);
906 }
907
908 static int
909 mac_test_setlabel_vnode_extattr(struct ucred *cred, struct vnode *vp,
910     struct label *vlabel, struct label *intlabel)
911 {
912
913         ASSERT_CRED_LABEL(cred->cr_label);
914         ASSERT_VNODE_LABEL(vlabel);
915         ASSERT_VNODE_LABEL(intlabel);
916         return (0);
917 }
918
919 static void
920 mac_test_update_devfsdirent(struct mount *mp,
921     struct devfs_dirent *devfs_dirent, struct label *direntlabel,
922     struct vnode *vp, struct label *vnodelabel)
923 {
924
925         ASSERT_DEVFS_LABEL(direntlabel);
926         ASSERT_VNODE_LABEL(vnodelabel);
927 }
928
929 /*
930  * Labeling event operations: IPC object.
931  */
932 static void
933 mac_test_create_mbuf_from_socket(struct socket *so, struct label *socketlabel,
934     struct mbuf *m, struct label *mbuflabel)
935 {
936
937         ASSERT_SOCKET_LABEL(socketlabel);
938         ASSERT_MBUF_LABEL(mbuflabel);
939 }
940
941 static void
942 mac_test_create_socket(struct ucred *cred, struct socket *socket,
943    struct label *socketlabel)
944 {
945
946         ASSERT_CRED_LABEL(cred->cr_label);
947         ASSERT_SOCKET_LABEL(socketlabel);
948 }
949
950 static void
951 mac_test_create_pipe(struct ucred *cred, struct pipepair *pp,
952    struct label *pipelabel)
953 {
954
955         ASSERT_CRED_LABEL(cred->cr_label);
956         ASSERT_PIPE_LABEL(pipelabel);
957 }
958
959 static void
960 mac_test_create_posix_sem(struct ucred *cred, struct ksem *ksem,
961    struct label *posixlabel)
962 {
963
964         ASSERT_CRED_LABEL(cred->cr_label);
965         ASSERT_POSIX_LABEL(posixlabel);
966 }
967
968 static void
969 mac_test_create_socket_from_socket(struct socket *oldsocket,
970     struct label *oldsocketlabel, struct socket *newsocket,
971     struct label *newsocketlabel)
972 {
973
974         ASSERT_SOCKET_LABEL(oldsocketlabel);
975         ASSERT_SOCKET_LABEL(newsocketlabel);
976 }
977
978 static void
979 mac_test_relabel_socket(struct ucred *cred, struct socket *socket,
980     struct label *socketlabel, struct label *newlabel)
981 {
982
983         ASSERT_CRED_LABEL(cred->cr_label);
984         ASSERT_SOCKET_LABEL(newlabel);
985 }
986
987 static void
988 mac_test_relabel_pipe(struct ucred *cred, struct pipepair *pp,
989     struct label *pipelabel, struct label *newlabel)
990 {
991
992         ASSERT_CRED_LABEL(cred->cr_label);
993         ASSERT_PIPE_LABEL(pipelabel);
994         ASSERT_PIPE_LABEL(newlabel);
995 }
996
997 static void
998 mac_test_set_socket_peer_from_mbuf(struct mbuf *mbuf, struct label *mbuflabel,
999     struct socket *socket, struct label *socketpeerlabel)
1000 {
1001
1002         ASSERT_MBUF_LABEL(mbuflabel);
1003         ASSERT_SOCKET_LABEL(socketpeerlabel);
1004 }
1005
1006 /*
1007  * Labeling event operations: network objects.
1008  */
1009 static void
1010 mac_test_set_socket_peer_from_socket(struct socket *oldsocket,
1011     struct label *oldsocketlabel, struct socket *newsocket,
1012     struct label *newsocketpeerlabel)
1013 {
1014
1015         ASSERT_SOCKET_LABEL(oldsocketlabel);
1016         ASSERT_SOCKET_LABEL(newsocketpeerlabel);
1017 }
1018
1019 static void
1020 mac_test_create_bpfdesc(struct ucred *cred, struct bpf_d *bpf_d,
1021     struct label *bpflabel)
1022 {
1023
1024         ASSERT_CRED_LABEL(cred->cr_label);
1025         ASSERT_BPF_LABEL(bpflabel);
1026 }
1027
1028 static void
1029 mac_test_create_datagram_from_ipq(struct ipq *ipq, struct label *ipqlabel,
1030     struct mbuf *datagram, struct label *datagramlabel)
1031 {
1032
1033         ASSERT_IPQ_LABEL(ipqlabel);
1034         ASSERT_MBUF_LABEL(datagramlabel);
1035 }
1036
1037 static void
1038 mac_test_create_fragment(struct mbuf *datagram, struct label *datagramlabel,
1039     struct mbuf *fragment, struct label *fragmentlabel)
1040 {
1041
1042         ASSERT_MBUF_LABEL(datagramlabel);
1043         ASSERT_MBUF_LABEL(fragmentlabel);
1044 }
1045
1046 static void
1047 mac_test_create_ifnet(struct ifnet *ifnet, struct label *ifnetlabel)
1048 {
1049
1050         ASSERT_IFNET_LABEL(ifnetlabel);
1051 }
1052
1053 static void
1054 mac_test_create_inpcb_from_socket(struct socket *so, struct label *solabel,
1055     struct inpcb *inp, struct label *inplabel)
1056 {
1057
1058         ASSERT_SOCKET_LABEL(solabel);
1059         ASSERT_INPCB_LABEL(inplabel);
1060 }
1061
1062 static void
1063 mac_test_create_sysv_msgmsg(struct ucred *cred, struct msqid_kernel *msqkptr,
1064     struct label *msqlabel, struct msg *msgptr, struct label *msglabel)
1065 {
1066
1067         ASSERT_SYSVIPCMSG_LABEL(msglabel);
1068         ASSERT_SYSVIPCMSQ_LABEL(msqlabel);
1069 }
1070
1071 static void
1072 mac_test_create_sysv_msgqueue(struct ucred *cred,
1073     struct msqid_kernel *msqkptr, struct label *msqlabel)
1074 {
1075
1076         ASSERT_SYSVIPCMSQ_LABEL(msqlabel);
1077 }
1078
1079 static void
1080 mac_test_create_sysv_sem(struct ucred *cred, struct semid_kernel *semakptr,
1081     struct label *semalabel)
1082 {
1083
1084         ASSERT_SYSVIPCSEM_LABEL(semalabel);
1085 }
1086
1087 static void
1088 mac_test_create_sysv_shm(struct ucred *cred, struct shmid_kernel *shmsegptr,
1089     struct label *shmlabel)
1090 {
1091
1092         ASSERT_SYSVIPCSHM_LABEL(shmlabel);
1093 }
1094
1095 static void
1096 mac_test_create_ipq(struct mbuf *fragment, struct label *fragmentlabel,
1097     struct ipq *ipq, struct label *ipqlabel)
1098 {
1099
1100         ASSERT_MBUF_LABEL(fragmentlabel);
1101         ASSERT_IPQ_LABEL(ipqlabel);
1102 }
1103
1104 static void
1105 mac_test_create_mbuf_from_inpcb(struct inpcb *inp, struct label *inplabel,
1106     struct mbuf *m, struct label *mlabel)
1107 {
1108
1109         ASSERT_INPCB_LABEL(inplabel);
1110         ASSERT_MBUF_LABEL(mlabel);
1111 }
1112
1113 static void
1114 mac_test_create_mbuf_linklayer(struct ifnet *ifnet, struct label *ifnetlabel,
1115     struct mbuf *mbuf, struct label *mbuflabel)
1116 {
1117
1118         ASSERT_IFNET_LABEL(ifnetlabel);
1119         ASSERT_MBUF_LABEL(mbuflabel);
1120 }
1121
1122 static void
1123 mac_test_create_mbuf_from_bpfdesc(struct bpf_d *bpf_d, struct label *bpflabel,
1124     struct mbuf *mbuf, struct label *mbuflabel)
1125 {
1126
1127         ASSERT_BPF_LABEL(bpflabel);
1128         ASSERT_MBUF_LABEL(mbuflabel);
1129 }
1130
1131 static void
1132 mac_test_create_mbuf_from_ifnet(struct ifnet *ifnet, struct label *ifnetlabel,
1133     struct mbuf *m, struct label *mbuflabel)
1134 {
1135
1136         ASSERT_IFNET_LABEL(ifnetlabel);
1137         ASSERT_MBUF_LABEL(mbuflabel);
1138 }
1139
1140 static void
1141 mac_test_create_mbuf_multicast_encap(struct mbuf *oldmbuf,
1142     struct label *oldmbuflabel, struct ifnet *ifnet, struct label *ifnetlabel,
1143     struct mbuf *newmbuf, struct label *newmbuflabel)
1144 {
1145
1146         ASSERT_MBUF_LABEL(oldmbuflabel);
1147         ASSERT_IFNET_LABEL(ifnetlabel);
1148         ASSERT_MBUF_LABEL(newmbuflabel);
1149 }
1150
1151 static void
1152 mac_test_create_mbuf_netlayer(struct mbuf *oldmbuf,
1153     struct label *oldmbuflabel, struct mbuf *newmbuf,
1154     struct label *newmbuflabel)
1155 {
1156
1157         ASSERT_MBUF_LABEL(oldmbuflabel);
1158         ASSERT_MBUF_LABEL(newmbuflabel);
1159 }
1160
1161 static int
1162 mac_test_fragment_match(struct mbuf *fragment, struct label *fragmentlabel,
1163     struct ipq *ipq, struct label *ipqlabel)
1164 {
1165
1166         ASSERT_MBUF_LABEL(fragmentlabel);
1167         ASSERT_IPQ_LABEL(ipqlabel);
1168
1169         return (1);
1170 }
1171
1172 static void
1173 mac_test_reflect_mbuf_icmp(struct mbuf *m, struct label *mlabel)
1174 {
1175
1176         ASSERT_MBUF_LABEL(mlabel);
1177 }
1178
1179 static void
1180 mac_test_reflect_mbuf_tcp(struct mbuf *m, struct label *mlabel)
1181 {
1182
1183         ASSERT_MBUF_LABEL(mlabel);
1184 }
1185
1186 static void
1187 mac_test_relabel_ifnet(struct ucred *cred, struct ifnet *ifnet,
1188     struct label *ifnetlabel, struct label *newlabel)
1189 {
1190
1191         ASSERT_CRED_LABEL(cred->cr_label);
1192         ASSERT_IFNET_LABEL(ifnetlabel);
1193         ASSERT_IFNET_LABEL(newlabel);
1194 }
1195
1196 static void
1197 mac_test_update_ipq(struct mbuf *fragment, struct label *fragmentlabel,
1198     struct ipq *ipq, struct label *ipqlabel)
1199 {
1200
1201         ASSERT_MBUF_LABEL(fragmentlabel);
1202         ASSERT_IPQ_LABEL(ipqlabel);
1203 }
1204
1205 static void
1206 mac_test_inpcb_sosetlabel(struct socket *so, struct label *solabel,
1207     struct inpcb *inp, struct label *inplabel)
1208 {
1209
1210         ASSERT_SOCKET_LABEL(solabel);
1211         ASSERT_INPCB_LABEL(inplabel);
1212 }
1213
1214 /*
1215  * Labeling event operations: processes.
1216  */
1217 static void
1218 mac_test_execve_transition(struct ucred *old, struct ucred *new,
1219     struct vnode *vp, struct label *filelabel,
1220     struct label *interpvnodelabel, struct image_params *imgp,
1221     struct label *execlabel)
1222 {
1223
1224         ASSERT_CRED_LABEL(old->cr_label);
1225         ASSERT_CRED_LABEL(new->cr_label);
1226         ASSERT_VNODE_LABEL(filelabel);
1227         if (interpvnodelabel != NULL) {
1228                 ASSERT_VNODE_LABEL(interpvnodelabel);
1229         }
1230         if (execlabel != NULL) {
1231                 ASSERT_CRED_LABEL(execlabel);
1232         }
1233 }
1234
1235 static int
1236 mac_test_execve_will_transition(struct ucred *old, struct vnode *vp,
1237     struct label *filelabel, struct label *interpvnodelabel,
1238     struct image_params *imgp, struct label *execlabel)
1239 {
1240
1241         ASSERT_CRED_LABEL(old->cr_label);
1242         ASSERT_VNODE_LABEL(filelabel);
1243         if (interpvnodelabel != NULL) {
1244                 ASSERT_VNODE_LABEL(interpvnodelabel);
1245         }
1246         if (execlabel != NULL) {
1247                 ASSERT_CRED_LABEL(execlabel);
1248         }
1249
1250         return (0);
1251 }
1252
1253 static void
1254 mac_test_create_proc0(struct ucred *cred)
1255 {
1256
1257         ASSERT_CRED_LABEL(cred->cr_label);
1258 }
1259
1260 static void
1261 mac_test_create_proc1(struct ucred *cred)
1262 {
1263
1264         ASSERT_CRED_LABEL(cred->cr_label);
1265 }
1266
1267 static void
1268 mac_test_relabel_cred(struct ucred *cred, struct label *newlabel)
1269 {
1270
1271         ASSERT_CRED_LABEL(cred->cr_label);
1272         ASSERT_CRED_LABEL(newlabel);
1273 }
1274
1275 static void
1276 mac_test_thread_userret(struct thread *td)
1277 {
1278
1279         printf("mac_test_thread_userret(process = %d)\n",
1280             curthread->td_proc->p_pid);
1281 }
1282
1283 /*
1284  * Label cleanup/flush operations
1285  */
1286 static void
1287 mac_test_cleanup_sysv_msgmsg(struct label *msglabel)
1288 {
1289
1290         ASSERT_SYSVIPCMSG_LABEL(msglabel);
1291 }
1292
1293 static void
1294 mac_test_cleanup_sysv_msgqueue(struct label *msqlabel)
1295 {
1296
1297         ASSERT_SYSVIPCMSQ_LABEL(msqlabel);
1298 }
1299
1300 static void
1301 mac_test_cleanup_sysv_sem(struct label *semalabel)
1302 {
1303
1304         ASSERT_SYSVIPCSEM_LABEL(semalabel);
1305 }
1306
1307 static void
1308 mac_test_cleanup_sysv_shm(struct label *shmlabel)
1309 {
1310
1311         ASSERT_SYSVIPCSHM_LABEL(shmlabel);
1312 }
1313
1314 /*
1315  * Access control checks.
1316  */
1317 static int
1318 mac_test_check_bpfdesc_receive(struct bpf_d *bpf_d, struct label *bpflabel,
1319     struct ifnet *ifnet, struct label *ifnetlabel)
1320 {
1321
1322         ASSERT_BPF_LABEL(bpflabel);
1323         ASSERT_IFNET_LABEL(ifnetlabel);
1324
1325         return (0);
1326 }
1327
1328 static int
1329 mac_test_check_cred_relabel(struct ucred *cred, struct label *newlabel)
1330 {
1331
1332         ASSERT_CRED_LABEL(cred->cr_label);
1333         ASSERT_CRED_LABEL(newlabel);
1334
1335         return (0);
1336 }
1337
1338 static int
1339 mac_test_check_cred_visible(struct ucred *u1, struct ucred *u2)
1340 {
1341
1342         ASSERT_CRED_LABEL(u1->cr_label);
1343         ASSERT_CRED_LABEL(u2->cr_label);
1344
1345         return (0);
1346 }
1347
1348 static int
1349 mac_test_check_ifnet_relabel(struct ucred *cred, struct ifnet *ifnet,
1350     struct label *ifnetlabel, struct label *newlabel)
1351 {
1352
1353         ASSERT_CRED_LABEL(cred->cr_label);
1354         ASSERT_IFNET_LABEL(ifnetlabel);
1355         ASSERT_IFNET_LABEL(newlabel);
1356         return (0);
1357 }
1358
1359 static int
1360 mac_test_check_ifnet_transmit(struct ifnet *ifnet, struct label *ifnetlabel,
1361     struct mbuf *m, struct label *mbuflabel)
1362 {
1363
1364         ASSERT_IFNET_LABEL(ifnetlabel);
1365         ASSERT_MBUF_LABEL(mbuflabel);
1366
1367         return (0);
1368 }
1369
1370 static int
1371 mac_test_check_inpcb_deliver(struct inpcb *inp, struct label *inplabel,
1372     struct mbuf *m, struct label *mlabel)
1373 {
1374
1375         ASSERT_INPCB_LABEL(inplabel);
1376         ASSERT_MBUF_LABEL(mlabel);
1377
1378         return (0);
1379 }
1380
1381 static int
1382 mac_test_check_sysv_msgmsq(struct ucred *cred, struct msg *msgptr,
1383     struct label *msglabel, struct msqid_kernel *msqkptr,
1384     struct label *msqklabel)
1385 {
1386
1387         ASSERT_SYSVIPCMSQ_LABEL(msqklabel);
1388         ASSERT_SYSVIPCMSG_LABEL(msglabel);
1389         ASSERT_CRED_LABEL(cred->cr_label);
1390
1391         return (0);
1392 }
1393
1394 static int
1395 mac_test_check_sysv_msgrcv(struct ucred *cred, struct msg *msgptr,
1396     struct label *msglabel)
1397 {
1398
1399         ASSERT_SYSVIPCMSG_LABEL(msglabel);
1400         ASSERT_CRED_LABEL(cred->cr_label);
1401
1402          return (0);
1403 }
1404
1405
1406 static int
1407 mac_test_check_sysv_msgrmid(struct ucred *cred, struct msg *msgptr,
1408     struct label *msglabel)
1409 {
1410
1411         ASSERT_SYSVIPCMSG_LABEL(msglabel);
1412         ASSERT_CRED_LABEL(cred->cr_label);
1413
1414         return (0);
1415 }
1416
1417 static int
1418 mac_test_check_sysv_msqget(struct ucred *cred, struct msqid_kernel *msqkptr,
1419     struct label *msqklabel)
1420 {
1421
1422         ASSERT_SYSVIPCMSQ_LABEL(msqklabel);
1423         ASSERT_CRED_LABEL(cred->cr_label);
1424
1425         return (0);
1426 }
1427
1428 static int
1429 mac_test_check_sysv_msqsnd(struct ucred *cred, struct msqid_kernel *msqkptr,
1430     struct label *msqklabel)
1431 {
1432
1433         ASSERT_SYSVIPCMSQ_LABEL(msqklabel);
1434         ASSERT_CRED_LABEL(cred->cr_label);
1435
1436         return (0);
1437 }
1438
1439 static int
1440 mac_test_check_sysv_msqrcv(struct ucred *cred, struct msqid_kernel *msqkptr,
1441     struct label *msqklabel)
1442 {
1443
1444         ASSERT_SYSVIPCMSQ_LABEL(msqklabel);
1445         ASSERT_CRED_LABEL(cred->cr_label);
1446
1447         return (0);
1448 }
1449
1450 static int
1451 mac_test_check_sysv_msqctl(struct ucred *cred, struct msqid_kernel *msqkptr,
1452     struct label *msqklabel, int cmd)
1453 {
1454
1455         ASSERT_SYSVIPCMSQ_LABEL(msqklabel);
1456         ASSERT_CRED_LABEL(cred->cr_label);
1457
1458         return (0);
1459 }
1460
1461 static int
1462 mac_test_check_sysv_semctl(struct ucred *cred, struct semid_kernel *semakptr,
1463     struct label *semaklabel, int cmd)
1464 {
1465
1466         ASSERT_CRED_LABEL(cred->cr_label);
1467         ASSERT_SYSVIPCSEM_LABEL(semaklabel);
1468
1469         return (0);
1470 }
1471
1472 static int
1473 mac_test_check_sysv_semget(struct ucred *cred, struct semid_kernel *semakptr,
1474     struct label *semaklabel)
1475 {
1476
1477         ASSERT_CRED_LABEL(cred->cr_label);
1478         ASSERT_SYSVIPCSEM_LABEL(semaklabel);
1479
1480         return (0);
1481 }
1482
1483 static int
1484 mac_test_check_sysv_semop(struct ucred *cred, struct semid_kernel *semakptr,
1485     struct label *semaklabel, size_t accesstype)
1486 {
1487
1488         ASSERT_CRED_LABEL(cred->cr_label);
1489         ASSERT_SYSVIPCSEM_LABEL(semaklabel);
1490
1491         return (0);
1492 }
1493
1494 static int
1495 mac_test_check_sysv_shmat(struct ucred *cred, struct shmid_kernel *shmsegptr,
1496     struct label *shmseglabel, int shmflg)
1497 {
1498
1499         ASSERT_CRED_LABEL(cred->cr_label);
1500         ASSERT_SYSVIPCSHM_LABEL(shmseglabel);
1501
1502         return (0);
1503 }
1504
1505 static int
1506 mac_test_check_sysv_shmctl(struct ucred *cred, struct shmid_kernel *shmsegptr,
1507     struct label *shmseglabel, int cmd)
1508 {
1509
1510         ASSERT_CRED_LABEL(cred->cr_label);
1511         ASSERT_SYSVIPCSHM_LABEL(shmseglabel);
1512
1513         return (0);
1514 }
1515
1516 static int
1517 mac_test_check_sysv_shmdt(struct ucred *cred, struct shmid_kernel *shmsegptr,
1518     struct label *shmseglabel)
1519 {
1520
1521         ASSERT_CRED_LABEL(cred->cr_label);
1522         ASSERT_SYSVIPCSHM_LABEL(shmseglabel);
1523
1524         return (0);
1525 }
1526
1527 static int
1528 mac_test_check_sysv_shmget(struct ucred *cred, struct shmid_kernel *shmsegptr,
1529     struct label *shmseglabel, int shmflg)
1530 {
1531
1532         ASSERT_CRED_LABEL(cred->cr_label);
1533         ASSERT_SYSVIPCSHM_LABEL(shmseglabel);
1534
1535         return (0);
1536 }
1537
1538 static int
1539 mac_test_check_kenv_dump(struct ucred *cred)
1540 {
1541
1542         ASSERT_CRED_LABEL(cred->cr_label);
1543
1544         return (0);
1545 }
1546
1547 static int
1548 mac_test_check_kenv_get(struct ucred *cred, char *name)
1549 {
1550
1551         ASSERT_CRED_LABEL(cred->cr_label);
1552
1553         return (0);
1554 }
1555
1556 static int
1557 mac_test_check_kenv_set(struct ucred *cred, char *name, char *value)
1558 {
1559
1560         ASSERT_CRED_LABEL(cred->cr_label);
1561
1562         return (0);
1563 }
1564
1565 static int
1566 mac_test_check_kenv_unset(struct ucred *cred, char *name)
1567 {
1568
1569         ASSERT_CRED_LABEL(cred->cr_label);
1570
1571         return (0);
1572 }
1573
1574 static int
1575 mac_test_check_kld_load(struct ucred *cred, struct vnode *vp,
1576     struct label *label)
1577 {
1578
1579         ASSERT_CRED_LABEL(cred->cr_label);
1580         ASSERT_VNODE_LABEL(label);
1581
1582         return (0);
1583 }
1584
1585 static int
1586 mac_test_check_kld_stat(struct ucred *cred)
1587 {
1588
1589         ASSERT_CRED_LABEL(cred->cr_label);
1590
1591         return (0);
1592 }
1593
1594 static int
1595 mac_test_check_kld_unload(struct ucred *cred)
1596 {
1597
1598         ASSERT_CRED_LABEL(cred->cr_label);
1599
1600         return (0);
1601 }
1602
1603 static int
1604 mac_test_check_mount_stat(struct ucred *cred, struct mount *mp,
1605     struct label *mntlabel)
1606 {
1607
1608         ASSERT_CRED_LABEL(cred->cr_label);
1609         ASSERT_MOUNT_LABEL(mntlabel);
1610
1611         return (0);
1612 }
1613
1614 static int
1615 mac_test_check_pipe_ioctl(struct ucred *cred, struct pipepair *pp,
1616     struct label *pipelabel, unsigned long cmd, void /* caddr_t */ *data)
1617 {
1618
1619         ASSERT_CRED_LABEL(cred->cr_label);
1620         ASSERT_PIPE_LABEL(pipelabel);
1621
1622         return (0);
1623 }
1624
1625 static int
1626 mac_test_check_pipe_poll(struct ucred *cred, struct pipepair *pp,
1627     struct label *pipelabel)
1628 {
1629
1630         ASSERT_CRED_LABEL(cred->cr_label);
1631         ASSERT_PIPE_LABEL(pipelabel);
1632
1633         return (0);
1634 }
1635
1636 static int
1637 mac_test_check_pipe_read(struct ucred *cred, struct pipepair *pp,
1638     struct label *pipelabel)
1639 {
1640
1641         ASSERT_CRED_LABEL(cred->cr_label);
1642         ASSERT_PIPE_LABEL(pipelabel);
1643
1644         return (0);
1645 }
1646
1647 static int
1648 mac_test_check_pipe_relabel(struct ucred *cred, struct pipepair *pp,
1649     struct label *pipelabel, struct label *newlabel)
1650 {
1651
1652         ASSERT_CRED_LABEL(cred->cr_label);
1653         ASSERT_PIPE_LABEL(pipelabel);
1654         ASSERT_PIPE_LABEL(newlabel);
1655
1656         return (0);
1657 }
1658
1659 static int
1660 mac_test_check_pipe_stat(struct ucred *cred, struct pipepair *pp,
1661     struct label *pipelabel)
1662 {
1663
1664         ASSERT_CRED_LABEL(cred->cr_label);
1665         ASSERT_PIPE_LABEL(pipelabel);
1666
1667         return (0);
1668 }
1669
1670 static int
1671 mac_test_check_pipe_write(struct ucred *cred, struct pipepair *pp,
1672     struct label *pipelabel)
1673 {
1674
1675         ASSERT_CRED_LABEL(cred->cr_label);
1676         ASSERT_PIPE_LABEL(pipelabel);
1677
1678         return (0);
1679 }
1680
1681 static int
1682 mac_test_check_posix_sem(struct ucred *cred, struct ksem *ksemptr,
1683     struct label *ks_label)
1684 {
1685
1686         ASSERT_CRED_LABEL(cred->cr_label);
1687         ASSERT_POSIX_LABEL(ks_label);
1688
1689         return (0);
1690 }
1691
1692 static int
1693 mac_test_check_proc_debug(struct ucred *cred, struct proc *proc)
1694 {
1695
1696         ASSERT_CRED_LABEL(cred->cr_label);
1697         ASSERT_CRED_LABEL(proc->p_ucred->cr_label);
1698
1699         return (0);
1700 }
1701
1702 static int
1703 mac_test_check_proc_sched(struct ucred *cred, struct proc *proc)
1704 {
1705
1706         ASSERT_CRED_LABEL(cred->cr_label);
1707         ASSERT_CRED_LABEL(proc->p_ucred->cr_label);
1708
1709         return (0);
1710 }
1711
1712 static int
1713 mac_test_check_proc_signal(struct ucred *cred, struct proc *proc, int signum)
1714 {
1715
1716         ASSERT_CRED_LABEL(cred->cr_label);
1717         ASSERT_CRED_LABEL(proc->p_ucred->cr_label);
1718
1719         return (0);
1720 }
1721
1722 static int
1723 mac_test_check_proc_setuid(struct ucred *cred, uid_t uid)
1724 {
1725
1726         ASSERT_CRED_LABEL(cred->cr_label);
1727
1728         return (0);
1729 }
1730
1731 static int
1732 mac_test_check_proc_seteuid(struct ucred *cred, uid_t euid)
1733 {
1734
1735         ASSERT_CRED_LABEL(cred->cr_label);
1736
1737         return (0);
1738 }
1739
1740 static int
1741 mac_test_check_proc_setgid(struct ucred *cred, gid_t gid)
1742 {
1743
1744         ASSERT_CRED_LABEL(cred->cr_label);
1745
1746         return (0);
1747 }
1748
1749 static int
1750 mac_test_check_proc_setegid(struct ucred *cred, gid_t egid)
1751 {
1752
1753         ASSERT_CRED_LABEL(cred->cr_label);
1754
1755         return (0);
1756 }
1757
1758 static int
1759 mac_test_check_proc_setgroups(struct ucred *cred, int ngroups,
1760         gid_t *gidset)
1761 {
1762
1763         ASSERT_CRED_LABEL(cred->cr_label);
1764
1765         return (0);
1766 }
1767
1768 static int
1769 mac_test_check_proc_setreuid(struct ucred *cred, uid_t ruid, uid_t euid)
1770 {
1771
1772         ASSERT_CRED_LABEL(cred->cr_label);
1773
1774         return (0);
1775 }
1776
1777 static int
1778 mac_test_check_proc_setregid(struct ucred *cred, gid_t rgid, gid_t egid)
1779 {
1780
1781         ASSERT_CRED_LABEL(cred->cr_label);
1782
1783         return (0);
1784 }
1785
1786 static int
1787 mac_test_check_proc_setresuid(struct ucred *cred, uid_t ruid, uid_t euid,
1788         uid_t suid)
1789 {
1790
1791         ASSERT_CRED_LABEL(cred->cr_label);
1792
1793         return (0);
1794 }
1795
1796 static int
1797 mac_test_check_proc_setresgid(struct ucred *cred, gid_t rgid, gid_t egid,
1798         gid_t sgid)
1799 {
1800
1801         ASSERT_CRED_LABEL(cred->cr_label);
1802
1803         return (0);
1804 }
1805
1806 static int
1807 mac_test_check_proc_wait(struct ucred *cred, struct proc *proc)
1808 {
1809
1810         ASSERT_CRED_LABEL(cred->cr_label);
1811         ASSERT_CRED_LABEL(proc->p_ucred->cr_label);
1812
1813         return (0);
1814 }
1815
1816 static int
1817 mac_test_check_socket_accept(struct ucred *cred, struct socket *socket,
1818     struct label *socketlabel)
1819 {
1820
1821         ASSERT_CRED_LABEL(cred->cr_label);
1822         ASSERT_SOCKET_LABEL(socketlabel);
1823
1824         return (0);
1825 }
1826
1827 static int
1828 mac_test_check_socket_bind(struct ucred *cred, struct socket *socket,
1829     struct label *socketlabel, struct sockaddr *sockaddr)
1830 {
1831
1832         ASSERT_CRED_LABEL(cred->cr_label);
1833         ASSERT_SOCKET_LABEL(socketlabel);
1834
1835         return (0);
1836 }
1837
1838 static int
1839 mac_test_check_socket_connect(struct ucred *cred, struct socket *socket,
1840     struct label *socketlabel, struct sockaddr *sockaddr)
1841 {
1842
1843         ASSERT_CRED_LABEL(cred->cr_label);
1844         ASSERT_SOCKET_LABEL(socketlabel);
1845
1846         return (0);
1847 }
1848
1849 static int
1850 mac_test_check_socket_deliver(struct socket *socket, struct label *socketlabel,
1851     struct mbuf *m, struct label *mbuflabel)
1852 {
1853
1854         ASSERT_SOCKET_LABEL(socketlabel);
1855         ASSERT_MBUF_LABEL(mbuflabel);
1856
1857         return (0);
1858 }
1859
1860 static int
1861 mac_test_check_socket_listen(struct ucred *cred, struct socket *socket,
1862     struct label *socketlabel)
1863 {
1864
1865         ASSERT_CRED_LABEL(cred->cr_label);
1866         ASSERT_SOCKET_LABEL(socketlabel);
1867
1868         return (0);
1869 }
1870
1871 static int
1872 mac_test_check_socket_poll(struct ucred *cred, struct socket *socket,
1873     struct label *socketlabel)
1874 {
1875
1876         ASSERT_CRED_LABEL(cred->cr_label);
1877         ASSERT_SOCKET_LABEL(socketlabel);
1878
1879         return (0);
1880 }
1881
1882 static int
1883 mac_test_check_socket_receive(struct ucred *cred, struct socket *socket,
1884     struct label *socketlabel)
1885 {
1886
1887         ASSERT_CRED_LABEL(cred->cr_label);
1888         ASSERT_SOCKET_LABEL(socketlabel);
1889
1890         return (0);
1891 }
1892
1893 static int
1894 mac_test_check_socket_relabel(struct ucred *cred, struct socket *socket,
1895     struct label *socketlabel, struct label *newlabel)
1896 {
1897
1898         ASSERT_CRED_LABEL(cred->cr_label);
1899         ASSERT_SOCKET_LABEL(socketlabel);
1900         ASSERT_SOCKET_LABEL(newlabel);
1901
1902         return (0);
1903 }
1904
1905 static int
1906 mac_test_check_socket_send(struct ucred *cred, struct socket *socket,
1907     struct label *socketlabel)
1908 {
1909
1910         ASSERT_CRED_LABEL(cred->cr_label);
1911         ASSERT_SOCKET_LABEL(socketlabel);
1912
1913         return (0);
1914 }
1915
1916 static int
1917 mac_test_check_socket_stat(struct ucred *cred, struct socket *socket,
1918     struct label *socketlabel)
1919 {
1920
1921         ASSERT_CRED_LABEL(cred->cr_label);
1922         ASSERT_SOCKET_LABEL(socketlabel);
1923
1924         return (0);
1925 }
1926
1927 static int
1928 mac_test_check_socket_visible(struct ucred *cred, struct socket *socket,
1929     struct label *socketlabel)
1930 {
1931
1932         ASSERT_CRED_LABEL(cred->cr_label);
1933         ASSERT_SOCKET_LABEL(socketlabel);
1934
1935         return (0);
1936 }
1937
1938 static int
1939 mac_test_check_sysarch_ioperm(struct ucred *cred)
1940 {
1941
1942         ASSERT_CRED_LABEL(cred->cr_label);
1943
1944         return (0);
1945 }
1946
1947 static int
1948 mac_test_check_system_acct(struct ucred *cred, struct vnode *vp,
1949     struct label *label)
1950 {
1951
1952         ASSERT_CRED_LABEL(cred->cr_label);
1953
1954         return (0);
1955 }
1956
1957 static int
1958 mac_test_check_system_reboot(struct ucred *cred, int how)
1959 {
1960
1961         ASSERT_CRED_LABEL(cred->cr_label);
1962
1963         return (0);
1964 }
1965
1966 static int
1967 mac_test_check_system_settime(struct ucred *cred)
1968 {
1969
1970         ASSERT_CRED_LABEL(cred->cr_label);
1971
1972         return (0);
1973 }
1974
1975 static int
1976 mac_test_check_system_swapon(struct ucred *cred, struct vnode *vp,
1977     struct label *label)
1978 {
1979
1980         ASSERT_CRED_LABEL(cred->cr_label);
1981         ASSERT_VNODE_LABEL(label);
1982
1983         return (0);
1984 }
1985
1986 static int
1987 mac_test_check_system_swapoff(struct ucred *cred, struct vnode *vp,
1988     struct label *label)
1989 {
1990
1991         ASSERT_CRED_LABEL(cred->cr_label);
1992         ASSERT_VNODE_LABEL(label);
1993
1994         return (0);
1995 }
1996
1997 static int
1998 mac_test_check_system_sysctl(struct ucred *cred, struct sysctl_oid *oidp,
1999     void *arg1, int arg2, struct sysctl_req *req)
2000 {
2001
2002         ASSERT_CRED_LABEL(cred->cr_label);
2003
2004         return (0);
2005 }
2006
2007 static int
2008 mac_test_check_vnode_access(struct ucred *cred, struct vnode *vp,
2009     struct label *label, int acc_mode)
2010 {
2011
2012         ASSERT_CRED_LABEL(cred->cr_label);
2013         ASSERT_VNODE_LABEL(label);
2014
2015         return (0);
2016 }
2017
2018 static int
2019 mac_test_check_vnode_chdir(struct ucred *cred, struct vnode *dvp,
2020     struct label *dlabel)
2021 {
2022
2023         ASSERT_CRED_LABEL(cred->cr_label);
2024         ASSERT_VNODE_LABEL(dlabel);
2025
2026         return (0);
2027 }
2028
2029 static int
2030 mac_test_check_vnode_chroot(struct ucred *cred, struct vnode *dvp,
2031     struct label *dlabel)
2032 {
2033
2034         ASSERT_CRED_LABEL(cred->cr_label);
2035         ASSERT_VNODE_LABEL(dlabel);
2036
2037         return (0);
2038 }
2039
2040 static int
2041 mac_test_check_vnode_create(struct ucred *cred, struct vnode *dvp,
2042     struct label *dlabel, struct componentname *cnp, struct vattr *vap)
2043 {
2044
2045         ASSERT_CRED_LABEL(cred->cr_label);
2046         ASSERT_VNODE_LABEL(dlabel);
2047
2048         return (0);
2049 }
2050
2051 static int
2052 mac_test_check_vnode_delete(struct ucred *cred, struct vnode *dvp,
2053     struct label *dlabel, struct vnode *vp, struct label *label,
2054     struct componentname *cnp)
2055 {
2056
2057         ASSERT_CRED_LABEL(cred->cr_label);
2058         ASSERT_VNODE_LABEL(dlabel);
2059         ASSERT_VNODE_LABEL(label);
2060
2061         return (0);
2062 }
2063
2064 static int
2065 mac_test_check_vnode_deleteacl(struct ucred *cred, struct vnode *vp,
2066     struct label *label, acl_type_t type)
2067 {
2068
2069         ASSERT_CRED_LABEL(cred->cr_label);
2070         ASSERT_VNODE_LABEL(label);
2071
2072         return (0);
2073 }
2074
2075 static int
2076 mac_test_check_vnode_deleteextattr(struct ucred *cred, struct vnode *vp,
2077     struct label *label, int attrnamespace, const char *name)
2078 {
2079
2080         ASSERT_CRED_LABEL(cred->cr_label);
2081         ASSERT_VNODE_LABEL(label);
2082
2083         return (0);
2084 }
2085
2086 static int
2087 mac_test_check_vnode_exec(struct ucred *cred, struct vnode *vp,
2088     struct label *label, struct image_params *imgp,
2089     struct label *execlabel)
2090 {
2091
2092         ASSERT_CRED_LABEL(cred->cr_label);
2093         ASSERT_VNODE_LABEL(label);
2094         if (execlabel != NULL) {
2095                 ASSERT_CRED_LABEL(execlabel);
2096         }
2097
2098         return (0);
2099 }
2100
2101 static int
2102 mac_test_check_vnode_getacl(struct ucred *cred, struct vnode *vp,
2103     struct label *label, acl_type_t type)
2104 {
2105
2106         ASSERT_CRED_LABEL(cred->cr_label);
2107         ASSERT_VNODE_LABEL(label);
2108
2109         return (0);
2110 }
2111
2112 static int
2113 mac_test_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
2114     struct label *label, int attrnamespace, const char *name, struct uio *uio)
2115 {
2116
2117         ASSERT_CRED_LABEL(cred->cr_label);
2118         ASSERT_VNODE_LABEL(label);
2119
2120         return (0);
2121 }
2122
2123 static int
2124 mac_test_check_vnode_link(struct ucred *cred, struct vnode *dvp,
2125     struct label *dlabel, struct vnode *vp, struct label *label,
2126     struct componentname *cnp)
2127 {
2128
2129         ASSERT_CRED_LABEL(cred->cr_label);
2130         ASSERT_VNODE_LABEL(dlabel);
2131         ASSERT_VNODE_LABEL(label);
2132
2133         return (0);
2134 }
2135
2136 static int
2137 mac_test_check_vnode_listextattr(struct ucred *cred, struct vnode *vp,
2138     struct label *label, int attrnamespace)
2139 {
2140
2141         ASSERT_CRED_LABEL(cred->cr_label);
2142         ASSERT_VNODE_LABEL(label);
2143
2144         return (0);
2145 }
2146
2147 static int
2148 mac_test_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
2149     struct label *dlabel, struct componentname *cnp)
2150 {
2151
2152         ASSERT_CRED_LABEL(cred->cr_label);
2153         ASSERT_VNODE_LABEL(dlabel);
2154
2155         return (0);
2156 }
2157
2158 static int
2159 mac_test_check_vnode_mmap(struct ucred *cred, struct vnode *vp,
2160     struct label *label, int prot, int flags)
2161 {
2162
2163         ASSERT_CRED_LABEL(cred->cr_label);
2164         ASSERT_VNODE_LABEL(label);
2165
2166         return (0);
2167 }
2168
2169 static int
2170 mac_test_check_vnode_open(struct ucred *cred, struct vnode *vp,
2171     struct label *filelabel, int acc_mode)
2172 {
2173
2174         ASSERT_CRED_LABEL(cred->cr_label);
2175         ASSERT_VNODE_LABEL(filelabel);
2176
2177         return (0);
2178 }
2179
2180 static int
2181 mac_test_check_vnode_poll(struct ucred *active_cred, struct ucred *file_cred,
2182     struct vnode *vp, struct label *label)
2183 {
2184
2185         ASSERT_CRED_LABEL(active_cred->cr_label);
2186         ASSERT_CRED_LABEL(file_cred->cr_label);
2187         ASSERT_VNODE_LABEL(label);
2188
2189         return (0);
2190 }
2191
2192 static int
2193 mac_test_check_vnode_read(struct ucred *active_cred, struct ucred *file_cred,
2194     struct vnode *vp, struct label *label)
2195 {
2196
2197         ASSERT_CRED_LABEL(active_cred->cr_label);
2198         if (file_cred != NULL) {
2199                 ASSERT_CRED_LABEL(file_cred->cr_label);
2200         }
2201         ASSERT_VNODE_LABEL(label);
2202
2203         return (0);
2204 }
2205
2206 static int
2207 mac_test_check_vnode_readdir(struct ucred *cred, struct vnode *dvp,
2208     struct label *dlabel)
2209 {
2210
2211         ASSERT_CRED_LABEL(cred->cr_label);
2212         ASSERT_VNODE_LABEL(dlabel);
2213
2214         return (0);
2215 }
2216
2217 static int
2218 mac_test_check_vnode_readlink(struct ucred *cred, struct vnode *vp,
2219     struct label *vnodelabel)
2220 {
2221
2222         ASSERT_CRED_LABEL(cred->cr_label);
2223         ASSERT_VNODE_LABEL(vnodelabel);
2224
2225         return (0);
2226 }
2227
2228 static int
2229 mac_test_check_vnode_relabel(struct ucred *cred, struct vnode *vp,
2230     struct label *vnodelabel, struct label *newlabel)
2231 {
2232
2233         ASSERT_CRED_LABEL(cred->cr_label);
2234         ASSERT_VNODE_LABEL(vnodelabel);
2235         ASSERT_VNODE_LABEL(newlabel);
2236
2237         return (0);
2238 }
2239
2240 static int
2241 mac_test_check_vnode_rename_from(struct ucred *cred, struct vnode *dvp,
2242     struct label *dlabel, struct vnode *vp, struct label *label,
2243     struct componentname *cnp)
2244 {
2245
2246         ASSERT_CRED_LABEL(cred->cr_label);
2247         ASSERT_VNODE_LABEL(dlabel);
2248         ASSERT_VNODE_LABEL(label);
2249
2250         return (0);
2251 }
2252
2253 static int
2254 mac_test_check_vnode_rename_to(struct ucred *cred, struct vnode *dvp,
2255     struct label *dlabel, struct vnode *vp, struct label *label, int samedir,
2256     struct componentname *cnp)
2257 {
2258
2259         ASSERT_CRED_LABEL(cred->cr_label);
2260         ASSERT_VNODE_LABEL(dlabel);
2261
2262         if (vp != NULL) {
2263                 ASSERT_VNODE_LABEL(label);
2264         }
2265
2266         return (0);
2267 }
2268
2269 static int
2270 mac_test_check_vnode_revoke(struct ucred *cred, struct vnode *vp,
2271     struct label *label)
2272 {
2273
2274         ASSERT_CRED_LABEL(cred->cr_label);
2275         ASSERT_VNODE_LABEL(label);
2276
2277         return (0);
2278 }
2279
2280 static int
2281 mac_test_check_vnode_setacl(struct ucred *cred, struct vnode *vp,
2282     struct label *label, acl_type_t type, struct acl *acl)
2283 {
2284
2285         ASSERT_CRED_LABEL(cred->cr_label);
2286         ASSERT_VNODE_LABEL(label);
2287
2288         return (0);
2289 }
2290
2291 static int
2292 mac_test_check_vnode_setextattr(struct ucred *cred, struct vnode *vp,
2293     struct label *label, int attrnamespace, const char *name, struct uio *uio)
2294 {
2295
2296         ASSERT_CRED_LABEL(cred->cr_label);
2297         ASSERT_VNODE_LABEL(label);
2298
2299         return (0);
2300 }
2301
2302 static int
2303 mac_test_check_vnode_setflags(struct ucred *cred, struct vnode *vp,
2304     struct label *label, u_long flags)
2305 {
2306
2307         ASSERT_CRED_LABEL(cred->cr_label);
2308         ASSERT_VNODE_LABEL(label);
2309
2310         return (0);
2311 }
2312
2313 static int
2314 mac_test_check_vnode_setmode(struct ucred *cred, struct vnode *vp,
2315     struct label *label, mode_t mode)
2316 {
2317
2318         ASSERT_CRED_LABEL(cred->cr_label);
2319         ASSERT_VNODE_LABEL(label);
2320
2321         return (0);
2322 }
2323
2324 static int
2325 mac_test_check_vnode_setowner(struct ucred *cred, struct vnode *vp,
2326     struct label *label, uid_t uid, gid_t gid)
2327 {
2328
2329         ASSERT_CRED_LABEL(cred->cr_label);
2330         ASSERT_VNODE_LABEL(label);
2331
2332         return (0);
2333 }
2334
2335 static int
2336 mac_test_check_vnode_setutimes(struct ucred *cred, struct vnode *vp,
2337     struct label *label, struct timespec atime, struct timespec mtime)
2338 {
2339
2340         ASSERT_CRED_LABEL(cred->cr_label);
2341         ASSERT_VNODE_LABEL(label);
2342
2343         return (0);
2344 }
2345
2346 static int
2347 mac_test_check_vnode_stat(struct ucred *active_cred, struct ucred *file_cred,
2348     struct vnode *vp, struct label *label)
2349 {
2350
2351         ASSERT_CRED_LABEL(active_cred->cr_label);
2352         if (file_cred != NULL) {
2353                 ASSERT_CRED_LABEL(file_cred->cr_label);
2354         }
2355         ASSERT_VNODE_LABEL(label);
2356
2357         return (0);
2358 }
2359
2360 static int
2361 mac_test_check_vnode_write(struct ucred *active_cred,
2362     struct ucred *file_cred, struct vnode *vp, struct label *label)
2363 {
2364
2365         ASSERT_CRED_LABEL(active_cred->cr_label);
2366         if (file_cred != NULL) {
2367                 ASSERT_CRED_LABEL(file_cred->cr_label);
2368         }
2369         ASSERT_VNODE_LABEL(label);
2370
2371         return (0);
2372 }
2373
2374 static struct mac_policy_ops mac_test_ops =
2375 {
2376         .mpo_init_bpfdesc_label = mac_test_init_bpfdesc_label,
2377         .mpo_init_cred_label = mac_test_init_cred_label,
2378         .mpo_init_devfsdirent_label = mac_test_init_devfsdirent_label,
2379         .mpo_init_ifnet_label = mac_test_init_ifnet_label,
2380         .mpo_init_sysv_msgmsg_label = mac_test_init_sysv_msgmsg_label,
2381         .mpo_init_sysv_msgqueue_label = mac_test_init_sysv_msgqueue_label,
2382         .mpo_init_sysv_sem_label = mac_test_init_sysv_sem_label,
2383         .mpo_init_sysv_shm_label = mac_test_init_sysv_shm_label,
2384         .mpo_init_inpcb_label = mac_test_init_inpcb_label,
2385         .mpo_init_ipq_label = mac_test_init_ipq_label,
2386         .mpo_init_mbuf_label = mac_test_init_mbuf_label,
2387         .mpo_init_mount_label = mac_test_init_mount_label,
2388         .mpo_init_mount_fs_label = mac_test_init_mount_fs_label,
2389         .mpo_init_pipe_label = mac_test_init_pipe_label,
2390         .mpo_init_posix_sem_label = mac_test_init_posix_sem_label,
2391         .mpo_init_proc_label = mac_test_init_proc_label,
2392         .mpo_init_socket_label = mac_test_init_socket_label,
2393         .mpo_init_socket_peer_label = mac_test_init_socket_peer_label,
2394         .mpo_init_vnode_label = mac_test_init_vnode_label,
2395         .mpo_destroy_bpfdesc_label = mac_test_destroy_bpfdesc_label,
2396         .mpo_destroy_cred_label = mac_test_destroy_cred_label,
2397         .mpo_destroy_devfsdirent_label = mac_test_destroy_devfsdirent_label,
2398         .mpo_destroy_ifnet_label = mac_test_destroy_ifnet_label,
2399         .mpo_destroy_sysv_msgmsg_label = mac_test_destroy_sysv_msgmsg_label,
2400         .mpo_destroy_sysv_msgqueue_label =
2401             mac_test_destroy_sysv_msgqueue_label,
2402         .mpo_destroy_sysv_sem_label = mac_test_destroy_sysv_sem_label,
2403         .mpo_destroy_sysv_shm_label = mac_test_destroy_sysv_shm_label,
2404         .mpo_destroy_inpcb_label = mac_test_destroy_inpcb_label,
2405         .mpo_destroy_ipq_label = mac_test_destroy_ipq_label,
2406         .mpo_destroy_mbuf_label = mac_test_destroy_mbuf_label,
2407         .mpo_destroy_mount_label = mac_test_destroy_mount_label,
2408         .mpo_destroy_mount_fs_label = mac_test_destroy_mount_fs_label,
2409         .mpo_destroy_pipe_label = mac_test_destroy_pipe_label,
2410         .mpo_destroy_posix_sem_label = mac_test_destroy_posix_sem_label,
2411         .mpo_destroy_proc_label = mac_test_destroy_proc_label,
2412         .mpo_destroy_socket_label = mac_test_destroy_socket_label,
2413         .mpo_destroy_socket_peer_label = mac_test_destroy_socket_peer_label,
2414         .mpo_destroy_vnode_label = mac_test_destroy_vnode_label,
2415         .mpo_copy_cred_label = mac_test_copy_cred_label,
2416         .mpo_copy_ifnet_label = mac_test_copy_ifnet_label,
2417         .mpo_copy_mbuf_label = mac_test_copy_mbuf_label,
2418         .mpo_copy_pipe_label = mac_test_copy_pipe_label,
2419         .mpo_copy_socket_label = mac_test_copy_socket_label,
2420         .mpo_copy_vnode_label = mac_test_copy_vnode_label,
2421         .mpo_externalize_cred_label = mac_test_externalize_label,
2422         .mpo_externalize_ifnet_label = mac_test_externalize_label,
2423         .mpo_externalize_pipe_label = mac_test_externalize_label,
2424         .mpo_externalize_socket_label = mac_test_externalize_label,
2425         .mpo_externalize_socket_peer_label = mac_test_externalize_label,
2426         .mpo_externalize_vnode_label = mac_test_externalize_label,
2427         .mpo_internalize_cred_label = mac_test_internalize_label,
2428         .mpo_internalize_ifnet_label = mac_test_internalize_label,
2429         .mpo_internalize_pipe_label = mac_test_internalize_label,
2430         .mpo_internalize_socket_label = mac_test_internalize_label,
2431         .mpo_internalize_vnode_label = mac_test_internalize_label,
2432         .mpo_associate_vnode_devfs = mac_test_associate_vnode_devfs,
2433         .mpo_associate_vnode_extattr = mac_test_associate_vnode_extattr,
2434         .mpo_associate_vnode_singlelabel = mac_test_associate_vnode_singlelabel,
2435         .mpo_create_devfs_device = mac_test_create_devfs_device,
2436         .mpo_create_devfs_directory = mac_test_create_devfs_directory,
2437         .mpo_create_devfs_symlink = mac_test_create_devfs_symlink,
2438         .mpo_create_vnode_extattr = mac_test_create_vnode_extattr,
2439         .mpo_create_mount = mac_test_create_mount,
2440         .mpo_relabel_vnode = mac_test_relabel_vnode,
2441         .mpo_setlabel_vnode_extattr = mac_test_setlabel_vnode_extattr,
2442         .mpo_update_devfsdirent = mac_test_update_devfsdirent,
2443         .mpo_create_mbuf_from_socket = mac_test_create_mbuf_from_socket,
2444         .mpo_create_pipe = mac_test_create_pipe,
2445         .mpo_create_posix_sem = mac_test_create_posix_sem,
2446         .mpo_create_socket = mac_test_create_socket,
2447         .mpo_create_socket_from_socket = mac_test_create_socket_from_socket,
2448         .mpo_relabel_pipe = mac_test_relabel_pipe,
2449         .mpo_relabel_socket = mac_test_relabel_socket,
2450         .mpo_set_socket_peer_from_mbuf = mac_test_set_socket_peer_from_mbuf,
2451         .mpo_set_socket_peer_from_socket = mac_test_set_socket_peer_from_socket,
2452         .mpo_create_bpfdesc = mac_test_create_bpfdesc,
2453         .mpo_create_ifnet = mac_test_create_ifnet,
2454         .mpo_create_inpcb_from_socket = mac_test_create_inpcb_from_socket,
2455         .mpo_create_sysv_msgmsg = mac_test_create_sysv_msgmsg,
2456         .mpo_create_sysv_msgqueue = mac_test_create_sysv_msgqueue,
2457         .mpo_create_sysv_sem = mac_test_create_sysv_sem,
2458         .mpo_create_sysv_shm = mac_test_create_sysv_shm,
2459         .mpo_create_datagram_from_ipq = mac_test_create_datagram_from_ipq,
2460         .mpo_create_fragment = mac_test_create_fragment,
2461         .mpo_create_ipq = mac_test_create_ipq,
2462         .mpo_create_mbuf_from_inpcb = mac_test_create_mbuf_from_inpcb,
2463         .mpo_create_mbuf_linklayer = mac_test_create_mbuf_linklayer,
2464         .mpo_create_mbuf_from_bpfdesc = mac_test_create_mbuf_from_bpfdesc,
2465         .mpo_create_mbuf_from_ifnet = mac_test_create_mbuf_from_ifnet,
2466         .mpo_create_mbuf_multicast_encap = mac_test_create_mbuf_multicast_encap,
2467         .mpo_create_mbuf_netlayer = mac_test_create_mbuf_netlayer,
2468         .mpo_fragment_match = mac_test_fragment_match,
2469         .mpo_reflect_mbuf_icmp = mac_test_reflect_mbuf_icmp,
2470         .mpo_reflect_mbuf_tcp = mac_test_reflect_mbuf_tcp,
2471         .mpo_relabel_ifnet = mac_test_relabel_ifnet,
2472         .mpo_update_ipq = mac_test_update_ipq,
2473         .mpo_inpcb_sosetlabel = mac_test_inpcb_sosetlabel,
2474         .mpo_execve_transition = mac_test_execve_transition,
2475         .mpo_execve_will_transition = mac_test_execve_will_transition,
2476         .mpo_create_proc0 = mac_test_create_proc0,
2477         .mpo_create_proc1 = mac_test_create_proc1,
2478         .mpo_relabel_cred = mac_test_relabel_cred,
2479         .mpo_thread_userret = mac_test_thread_userret,
2480         .mpo_cleanup_sysv_msgmsg = mac_test_cleanup_sysv_msgmsg,
2481         .mpo_cleanup_sysv_msgqueue = mac_test_cleanup_sysv_msgqueue,
2482         .mpo_cleanup_sysv_sem = mac_test_cleanup_sysv_sem,
2483         .mpo_cleanup_sysv_shm = mac_test_cleanup_sysv_shm,
2484         .mpo_check_bpfdesc_receive = mac_test_check_bpfdesc_receive,
2485         .mpo_check_cred_relabel = mac_test_check_cred_relabel,
2486         .mpo_check_cred_visible = mac_test_check_cred_visible,
2487         .mpo_check_ifnet_relabel = mac_test_check_ifnet_relabel,
2488         .mpo_check_ifnet_transmit = mac_test_check_ifnet_transmit,
2489         .mpo_check_inpcb_deliver = mac_test_check_inpcb_deliver,
2490         .mpo_check_sysv_msgmsq = mac_test_check_sysv_msgmsq,
2491         .mpo_check_sysv_msgrcv = mac_test_check_sysv_msgrcv,
2492         .mpo_check_sysv_msgrmid = mac_test_check_sysv_msgrmid,
2493         .mpo_check_sysv_msqget = mac_test_check_sysv_msqget,
2494         .mpo_check_sysv_msqsnd = mac_test_check_sysv_msqsnd,
2495         .mpo_check_sysv_msqrcv = mac_test_check_sysv_msqrcv,
2496         .mpo_check_sysv_msqctl = mac_test_check_sysv_msqctl,
2497         .mpo_check_sysv_semctl = mac_test_check_sysv_semctl,
2498         .mpo_check_sysv_semget = mac_test_check_sysv_semget,
2499         .mpo_check_sysv_semop = mac_test_check_sysv_semop,
2500         .mpo_check_sysv_shmat = mac_test_check_sysv_shmat,
2501         .mpo_check_sysv_shmctl = mac_test_check_sysv_shmctl,
2502         .mpo_check_sysv_shmdt = mac_test_check_sysv_shmdt,
2503         .mpo_check_sysv_shmget = mac_test_check_sysv_shmget,
2504         .mpo_check_kenv_dump = mac_test_check_kenv_dump,
2505         .mpo_check_kenv_get = mac_test_check_kenv_get,
2506         .mpo_check_kenv_set = mac_test_check_kenv_set,
2507         .mpo_check_kenv_unset = mac_test_check_kenv_unset,
2508         .mpo_check_kld_load = mac_test_check_kld_load,
2509         .mpo_check_kld_stat = mac_test_check_kld_stat,
2510         .mpo_check_kld_unload = mac_test_check_kld_unload,
2511         .mpo_check_mount_stat = mac_test_check_mount_stat,
2512         .mpo_check_pipe_ioctl = mac_test_check_pipe_ioctl,
2513         .mpo_check_pipe_poll = mac_test_check_pipe_poll,
2514         .mpo_check_pipe_read = mac_test_check_pipe_read,
2515         .mpo_check_pipe_relabel = mac_test_check_pipe_relabel,
2516         .mpo_check_pipe_stat = mac_test_check_pipe_stat,
2517         .mpo_check_pipe_write = mac_test_check_pipe_write,
2518         .mpo_check_posix_sem_destroy = mac_test_check_posix_sem,
2519         .mpo_check_posix_sem_getvalue = mac_test_check_posix_sem,
2520         .mpo_check_posix_sem_open = mac_test_check_posix_sem,
2521         .mpo_check_posix_sem_post = mac_test_check_posix_sem,
2522         .mpo_check_posix_sem_unlink = mac_test_check_posix_sem,
2523         .mpo_check_posix_sem_wait = mac_test_check_posix_sem,
2524         .mpo_check_proc_debug = mac_test_check_proc_debug,
2525         .mpo_check_proc_sched = mac_test_check_proc_sched,
2526         .mpo_check_proc_setuid = mac_test_check_proc_setuid,
2527         .mpo_check_proc_seteuid = mac_test_check_proc_seteuid,
2528         .mpo_check_proc_setgid = mac_test_check_proc_setgid,
2529         .mpo_check_proc_setegid = mac_test_check_proc_setegid,
2530         .mpo_check_proc_setgroups = mac_test_check_proc_setgroups,
2531         .mpo_check_proc_setreuid = mac_test_check_proc_setreuid,
2532         .mpo_check_proc_setregid = mac_test_check_proc_setregid,
2533         .mpo_check_proc_setresuid = mac_test_check_proc_setresuid,
2534         .mpo_check_proc_setresgid = mac_test_check_proc_setresgid,
2535         .mpo_check_proc_signal = mac_test_check_proc_signal,
2536         .mpo_check_proc_wait = mac_test_check_proc_wait,
2537         .mpo_check_socket_accept = mac_test_check_socket_accept,
2538         .mpo_check_socket_bind = mac_test_check_socket_bind,
2539         .mpo_check_socket_connect = mac_test_check_socket_connect,
2540         .mpo_check_socket_deliver = mac_test_check_socket_deliver,
2541         .mpo_check_socket_listen = mac_test_check_socket_listen,
2542         .mpo_check_socket_poll = mac_test_check_socket_poll,
2543         .mpo_check_socket_receive = mac_test_check_socket_receive,
2544         .mpo_check_socket_relabel = mac_test_check_socket_relabel,
2545         .mpo_check_socket_send = mac_test_check_socket_send,
2546         .mpo_check_socket_stat = mac_test_check_socket_stat,
2547         .mpo_check_socket_visible = mac_test_check_socket_visible,
2548         .mpo_check_sysarch_ioperm = mac_test_check_sysarch_ioperm,
2549         .mpo_check_system_acct = mac_test_check_system_acct,
2550         .mpo_check_system_reboot = mac_test_check_system_reboot,
2551         .mpo_check_system_settime = mac_test_check_system_settime,
2552         .mpo_check_system_swapon = mac_test_check_system_swapon,
2553         .mpo_check_system_swapoff = mac_test_check_system_swapoff,
2554         .mpo_check_system_sysctl = mac_test_check_system_sysctl,
2555         .mpo_check_vnode_access = mac_test_check_vnode_access,
2556         .mpo_check_vnode_chdir = mac_test_check_vnode_chdir,
2557         .mpo_check_vnode_chroot = mac_test_check_vnode_chroot,
2558         .mpo_check_vnode_create = mac_test_check_vnode_create,
2559         .mpo_check_vnode_delete = mac_test_check_vnode_delete,
2560         .mpo_check_vnode_deleteacl = mac_test_check_vnode_deleteacl,
2561         .mpo_check_vnode_deleteextattr = mac_test_check_vnode_deleteextattr,
2562         .mpo_check_vnode_exec = mac_test_check_vnode_exec,
2563         .mpo_check_vnode_getacl = mac_test_check_vnode_getacl,
2564         .mpo_check_vnode_getextattr = mac_test_check_vnode_getextattr,
2565         .mpo_check_vnode_link = mac_test_check_vnode_link,
2566         .mpo_check_vnode_listextattr = mac_test_check_vnode_listextattr,
2567         .mpo_check_vnode_lookup = mac_test_check_vnode_lookup,
2568         .mpo_check_vnode_mmap = mac_test_check_vnode_mmap,
2569         .mpo_check_vnode_open = mac_test_check_vnode_open,
2570         .mpo_check_vnode_poll = mac_test_check_vnode_poll,
2571         .mpo_check_vnode_read = mac_test_check_vnode_read,
2572         .mpo_check_vnode_readdir = mac_test_check_vnode_readdir,
2573         .mpo_check_vnode_readlink = mac_test_check_vnode_readlink,
2574         .mpo_check_vnode_relabel = mac_test_check_vnode_relabel,
2575         .mpo_check_vnode_rename_from = mac_test_check_vnode_rename_from,
2576         .mpo_check_vnode_rename_to = mac_test_check_vnode_rename_to,
2577         .mpo_check_vnode_revoke = mac_test_check_vnode_revoke,
2578         .mpo_check_vnode_setacl = mac_test_check_vnode_setacl,
2579         .mpo_check_vnode_setextattr = mac_test_check_vnode_setextattr,
2580         .mpo_check_vnode_setflags = mac_test_check_vnode_setflags,
2581         .mpo_check_vnode_setmode = mac_test_check_vnode_setmode,
2582         .mpo_check_vnode_setowner = mac_test_check_vnode_setowner,
2583         .mpo_check_vnode_setutimes = mac_test_check_vnode_setutimes,
2584         .mpo_check_vnode_stat = mac_test_check_vnode_stat,
2585         .mpo_check_vnode_write = mac_test_check_vnode_write,
2586 };
2587
2588 MAC_POLICY_SET(&mac_test_ops, mac_test, "TrustedBSD MAC/Test",
2589     MPC_LOADTIME_FLAG_UNLOADOK | MPC_LOADTIME_FLAG_LABELMBUFS, &test_slot);