xref: /freebsd/sys/security/mac/mac_policy.h (revision 0efd6615cd5f39b67cec82a7034e655f3b5801e3)
1 /*-
2  * Copyright (c) 1999-2002 Robert N. M. Watson
3  * Copyright (c) 2001-2005 Networks Associates Technology, Inc.
4  * Copyright (c) 2005-2006 SPARTA, Inc.
5  * All rights reserved.
6  *
7  * This software was developed by Robert Watson for the TrustedBSD Project.
8  *
9  * This software was developed for the FreeBSD Project in part by Network
10  * Associates Laboratories, the Security Research Division of Network
11  * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
12  * as part of the DARPA CHATS research program.
13  *
14  * This software was enhanced by SPARTA ISSO under SPAWAR contract
15  * N66001-04-C-6019 ("SEFOS").
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  * 1. Redistributions of source code must retain the above copyright
21  *    notice, this list of conditions and the following disclaimer.
22  * 2. Redistributions in binary form must reproduce the above copyright
23  *    notice, this list of conditions and the following disclaimer in the
24  *    documentation and/or other materials provided with the distribution.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  * $FreeBSD$
39  */
40 /*
41  * Kernel interface for MAC policy modules.
42  */
43 #ifndef _SYS_MAC_POLICY_H_
44 #define _SYS_MAC_POLICY_H_
45 
46 /*-
47  * Pluggable access control policy definition structure.
48  *
49  * List of operations that are performed as part of the implementation
50  * of a MAC policy.  Policy implementors declare operations with a
51  * mac_policy_ops structure, and using the MAC_POLICY_SET() macro.
52  * If an entry point is not declared, then then the policy will be ignored
53  * during evaluation of that event or check.
54  *
55  * Operations are sorted first by general class of operation, then
56  * alphabetically.
57  */
58 #include <sys/acl.h>	/* XXX acl_type_t */
59 
60 struct acl;
61 struct bpf_d;
62 struct cdev;
63 struct componentname;
64 struct devfs_dirent;
65 struct ifnet;
66 struct image_params;
67 struct inpcb;
68 struct ipq;
69 struct ksem;
70 struct label;
71 struct mac_policy_conf;
72 struct mbuf;
73 struct mount;
74 struct msg;
75 struct msqid_kernel;
76 struct pipepair;
77 struct proc;
78 struct sbuf;
79 struct semid_kernel;
80 struct shmid_kernel;
81 struct sockaddr;
82 struct socket;
83 struct sysctl_oid;
84 struct sysctl_req;
85 struct thread;
86 struct ucred;
87 struct uio;
88 struct vattr;
89 struct vnode;
90 
91 /*
92  * Policy module operations.
93  */
94 typedef void	(*mpo_destroy_t)(struct mac_policy_conf *mpc);
95 typedef void	(*mpo_init_t)(struct mac_policy_conf *mpc);
96 
97 /*
98  * General policy-directed security system call so that policies may
99  * implement new services without reserving explicit system call
100  * numbers.
101  */
102 typedef int	(*mpo_syscall_t)(struct thread *td, int call, void *arg);
103 
104 /*
105  * Place-holder function pointers for ABI-compatibility purposes.
106  */
107 typedef void	(*mpo_placeholder_t)(void);
108 
109 /*
110  * Label operations.  Initialize label storage, destroy label
111  * storage, recycle for re-use without init/destroy, copy a label to
112  * initialized storage, and externalize/internalize from/to
113  * initialized storage.
114  */
115 typedef void	(*mpo_init_bpfdesc_label_t)(struct label *label);
116 typedef void	(*mpo_init_cred_label_t)(struct label *label);
117 typedef void	(*mpo_init_devfsdirent_label_t)(struct label *label);
118 typedef void	(*mpo_init_ifnet_label_t)(struct label *label);
119 typedef int	(*mpo_init_inpcb_label_t)(struct label *label, int flag);
120 typedef void	(*mpo_init_sysv_msgmsg_label_t)(struct label *label);
121 typedef void	(*mpo_init_sysv_msgqueue_label_t)(struct label *label);
122 typedef void	(*mpo_init_sysv_sem_label_t)(struct label *label);
123 typedef void	(*mpo_init_sysv_shm_label_t)(struct label *label);
124 typedef int	(*mpo_init_ipq_label_t)(struct label *label, int flag);
125 typedef int	(*mpo_init_mbuf_label_t)(struct label *label, int flag);
126 typedef void	(*mpo_init_mount_label_t)(struct label *label);
127 typedef void	(*mpo_init_mount_fs_label_t)(struct label *label);
128 typedef int	(*mpo_init_socket_label_t)(struct label *label, int flag);
129 typedef int	(*mpo_init_socket_peer_label_t)(struct label *label,
130 		    int flag);
131 typedef void	(*mpo_init_pipe_label_t)(struct label *label);
132 typedef void    (*mpo_init_posix_sem_label_t)(struct label *label);
133 typedef void	(*mpo_init_proc_label_t)(struct label *label);
134 typedef void	(*mpo_init_vnode_label_t)(struct label *label);
135 typedef void	(*mpo_destroy_bpfdesc_label_t)(struct label *label);
136 typedef void	(*mpo_destroy_cred_label_t)(struct label *label);
137 typedef void	(*mpo_destroy_devfsdirent_label_t)(struct label *label);
138 typedef void	(*mpo_destroy_ifnet_label_t)(struct label *label);
139 typedef void	(*mpo_destroy_inpcb_label_t)(struct label *label);
140 typedef void	(*mpo_destroy_sysv_msgmsg_label_t)(struct label *label);
141 typedef void	(*mpo_destroy_sysv_msgqueue_label_t)(struct label *label);
142 typedef void	(*mpo_destroy_sysv_sem_label_t)(struct label *label);
143 typedef void	(*mpo_destroy_sysv_shm_label_t)(struct label *label);
144 typedef void	(*mpo_destroy_ipq_label_t)(struct label *label);
145 typedef void	(*mpo_destroy_mbuf_label_t)(struct label *label);
146 typedef void	(*mpo_destroy_mount_label_t)(struct label *label);
147 typedef void	(*mpo_destroy_mount_fs_label_t)(struct label *label);
148 typedef void	(*mpo_destroy_socket_label_t)(struct label *label);
149 typedef void	(*mpo_destroy_socket_peer_label_t)(struct label *label);
150 typedef void	(*mpo_destroy_pipe_label_t)(struct label *label);
151 typedef void    (*mpo_destroy_posix_sem_label_t)(struct label *label);
152 typedef void	(*mpo_destroy_proc_label_t)(struct label *label);
153 typedef void	(*mpo_destroy_vnode_label_t)(struct label *label);
154 typedef void	(*mpo_cleanup_sysv_msgmsg_t)(struct label *msglabel);
155 typedef void	(*mpo_cleanup_sysv_msgqueue_t)(struct label *msqlabel);
156 typedef void	(*mpo_cleanup_sysv_sem_t)(struct label *semalabel);
157 typedef void	(*mpo_cleanup_sysv_shm_t)(struct label *shmlabel);
158 typedef void	(*mpo_copy_cred_label_t)(struct label *src,
159 		    struct label *dest);
160 typedef void	(*mpo_copy_ifnet_label_t)(struct label *src,
161 		    struct label *dest);
162 typedef void	(*mpo_copy_mbuf_label_t)(struct label *src,
163 		    struct label *dest);
164 typedef void	(*mpo_copy_pipe_label_t)(struct label *src,
165 		    struct label *dest);
166 typedef void	(*mpo_copy_socket_label_t)(struct label *src,
167 		    struct label *dest);
168 typedef void	(*mpo_copy_vnode_label_t)(struct label *src,
169 		    struct label *dest);
170 typedef int	(*mpo_externalize_cred_label_t)(struct label *label,
171 		    char *element_name, struct sbuf *sb, int *claimed);
172 typedef int	(*mpo_externalize_ifnet_label_t)(struct label *label,
173 		    char *element_name, struct sbuf *sb, int *claimed);
174 typedef int	(*mpo_externalize_pipe_label_t)(struct label *label,
175 		    char *element_name, struct sbuf *sb, int *claimed);
176 typedef int	(*mpo_externalize_socket_label_t)(struct label *label,
177 		    char *element_name, struct sbuf *sb, int *claimed);
178 typedef int	(*mpo_externalize_socket_peer_label_t)(struct label *label,
179 		    char *element_name, struct sbuf *sb, int *claimed);
180 typedef int	(*mpo_externalize_vnode_label_t)(struct label *label,
181 		    char *element_name, struct sbuf *sb, int *claimed);
182 typedef int	(*mpo_internalize_cred_label_t)(struct label *label,
183 		    char *element_name, char *element_data, int *claimed);
184 typedef int	(*mpo_internalize_ifnet_label_t)(struct label *label,
185 		    char *element_name, char *element_data, int *claimed);
186 typedef int	(*mpo_internalize_pipe_label_t)(struct label *label,
187 		    char *element_name, char *element_data, int *claimed);
188 typedef int	(*mpo_internalize_socket_label_t)(struct label *label,
189 		    char *element_name, char *element_data, int *claimed);
190 typedef int	(*mpo_internalize_vnode_label_t)(struct label *label,
191 		    char *element_name, char *element_data, int *claimed);
192 
193 /*
194  * Labeling event operations: file system objects, and things that
195  * look a lot like file system objects.
196  */
197 typedef void	(*mpo_associate_vnode_devfs_t)(struct mount *mp,
198 		    struct label *fslabel, struct devfs_dirent *de,
199 		    struct label *delabel, struct vnode *vp,
200 		    struct label *vlabel);
201 typedef int	(*mpo_associate_vnode_extattr_t)(struct mount *mp,
202 		    struct label *fslabel, struct vnode *vp,
203 		    struct label *vlabel);
204 typedef void	(*mpo_associate_vnode_singlelabel_t)(struct mount *mp,
205 		    struct label *fslabel, struct vnode *vp,
206 		    struct label *vlabel);
207 typedef void	(*mpo_create_devfs_device_t)(struct ucred *cred,
208 		    struct mount *mp, struct cdev *dev,
209 		    struct devfs_dirent *de, struct label *label);
210 typedef void	(*mpo_create_devfs_directory_t)(struct mount *mp,
211 		    char *dirname, int dirnamelen, struct devfs_dirent *de,
212 		    struct label *label);
213 typedef void	(*mpo_create_devfs_symlink_t)(struct ucred *cred,
214 		    struct mount *mp, struct devfs_dirent *dd,
215 		    struct label *ddlabel, struct devfs_dirent *de,
216 		    struct label *delabel);
217 typedef int	(*mpo_create_vnode_extattr_t)(struct ucred *cred,
218 		    struct mount *mp, struct label *fslabel,
219 		    struct vnode *dvp, struct label *dlabel,
220 		    struct vnode *vp, struct label *vlabel,
221 		    struct componentname *cnp);
222 typedef void	(*mpo_create_mount_t)(struct ucred *cred, struct mount *mp,
223 		    struct label *mntlabel, struct label *fslabel);
224 typedef void	(*mpo_relabel_vnode_t)(struct ucred *cred, struct vnode *vp,
225 		    struct label *vnodelabel, struct label *label);
226 typedef int	(*mpo_setlabel_vnode_extattr_t)(struct ucred *cred,
227 		    struct vnode *vp, struct label *vlabel,
228 		    struct label *intlabel);
229 typedef void	(*mpo_update_devfsdirent_t)(struct mount *mp,
230 		    struct devfs_dirent *devfs_dirent,
231 		    struct label *direntlabel, struct vnode *vp,
232 		    struct label *vnodelabel);
233 
234 /*
235  * Labeling event operations: IPC objects.
236  */
237 typedef void	(*mpo_create_mbuf_from_socket_t)(struct socket *so,
238 		    struct label *socketlabel, struct mbuf *m,
239 		    struct label *mbuflabel);
240 typedef void	(*mpo_create_socket_t)(struct ucred *cred, struct socket *so,
241 		    struct label *socketlabel);
242 typedef void	(*mpo_create_socket_from_socket_t)(struct socket *oldsocket,
243 		    struct label *oldsocketlabel, struct socket *newsocket,
244 		    struct label *newsocketlabel);
245 typedef void	(*mpo_relabel_socket_t)(struct ucred *cred, struct socket *so,
246 		    struct label *oldlabel, struct label *newlabel);
247 typedef void	(*mpo_relabel_pipe_t)(struct ucred *cred, struct pipepair *pp,
248 		    struct label *oldlabel, struct label *newlabel);
249 typedef void	(*mpo_set_socket_peer_from_mbuf_t)(struct mbuf *mbuf,
250 		    struct label *mbuflabel, struct socket *so,
251 		    struct label *socketpeerlabel);
252 typedef void	(*mpo_set_socket_peer_from_socket_t)(struct socket *oldsocket,
253 		    struct label *oldsocketlabel, struct socket *newsocket,
254 		    struct label *newsocketpeerlabel);
255 typedef void	(*mpo_create_pipe_t)(struct ucred *cred, struct pipepair *pp,
256 		    struct label *pipelabel);
257 
258 /*
259  * Labeling event operations: System V IPC primitives.
260  */
261 typedef void	(*mpo_create_sysv_msgmsg_t)(struct ucred *cred,
262 		    struct msqid_kernel *msqkptr, struct label *msqlabel,
263 		    struct msg *msgptr, struct label *msglabel);
264 typedef void	(*mpo_create_sysv_msgqueue_t)(struct ucred *cred,
265 		    struct msqid_kernel *msqkptr, struct label *msqlabel);
266 typedef void	(*mpo_create_sysv_sem_t)(struct ucred *cred,
267 		    struct semid_kernel *semakptr, struct label *semalabel);
268 typedef void	(*mpo_create_sysv_shm_t)(struct ucred *cred,
269 		    struct shmid_kernel *shmsegptr, struct label *shmlabel);
270 
271 /*
272  * Labeling event operations: POSIX (global/inter-process) semaphores.
273  */
274 typedef void	(*mpo_create_posix_sem_t)(struct ucred *cred,
275 		    struct ksem *ksemptr, struct label *ks_label);
276 
277 /*
278  * Labeling event operations: network objects.
279  */
280 typedef void	(*mpo_create_bpfdesc_t)(struct ucred *cred,
281 		    struct bpf_d *bpf_d, struct label *bpflabel);
282 typedef void	(*mpo_create_ifnet_t)(struct ifnet *ifnet,
283 		    struct label *ifnetlabel);
284 typedef void	(*mpo_create_inpcb_from_socket_t)(struct socket *so,
285 		    struct label *solabel, struct inpcb *inp,
286 		    struct label *inplabel);
287 typedef void	(*mpo_create_ipq_t)(struct mbuf *fragment,
288 		    struct label *fragmentlabel, struct ipq *ipq,
289 		    struct label *ipqlabel);
290 typedef void	(*mpo_create_datagram_from_ipq)
291 		    (struct ipq *ipq, struct label *ipqlabel,
292 		    struct mbuf *datagram, struct label *datagramlabel);
293 typedef void	(*mpo_create_fragment_t)(struct mbuf *datagram,
294 		    struct label *datagramlabel, struct mbuf *fragment,
295 		    struct label *fragmentlabel);
296 typedef void	(*mpo_create_mbuf_from_inpcb_t)(struct inpcb *inp,
297 		    struct label *inplabel, struct mbuf *m,
298 		    struct label *mlabel);
299 typedef void	(*mpo_create_mbuf_linklayer_t)(struct ifnet *ifnet,
300 		    struct label *ifnetlabel, struct mbuf *mbuf,
301 		    struct label *mbuflabel);
302 typedef void	(*mpo_create_mbuf_from_bpfdesc_t)(struct bpf_d *bpf_d,
303 		    struct label *bpflabel, struct mbuf *mbuf,
304 		    struct label *mbuflabel);
305 typedef void	(*mpo_create_mbuf_from_ifnet_t)(struct ifnet *ifnet,
306 		    struct label *ifnetlabel, struct mbuf *mbuf,
307 		    struct label *mbuflabel);
308 typedef void	(*mpo_create_mbuf_multicast_encap_t)(struct mbuf *oldmbuf,
309 		    struct label *oldmbuflabel, struct ifnet *ifnet,
310 		    struct label *ifnetlabel, struct mbuf *newmbuf,
311 		    struct label *newmbuflabel);
312 typedef void	(*mpo_create_mbuf_netlayer_t)(struct mbuf *oldmbuf,
313 		    struct label *oldmbuflabel, struct mbuf *newmbuf,
314 		    struct label *newmbuflabel);
315 typedef int	(*mpo_fragment_match_t)(struct mbuf *fragment,
316 		    struct label *fragmentlabel, struct ipq *ipq,
317 		    struct label *ipqlabel);
318 typedef void	(*mpo_reflect_mbuf_icmp_t)(struct mbuf *m,
319 		    struct label *mlabel);
320 typedef void	(*mpo_reflect_mbuf_tcp_t)(struct mbuf *m,
321 		    struct label *mlabel);
322 typedef void	(*mpo_relabel_ifnet_t)(struct ucred *cred,
323 		    struct ifnet *ifnet, struct label *ifnetlabel,
324 		    struct label *newlabel);
325 typedef void	(*mpo_update_ipq_t)(struct mbuf *fragment,
326 		    struct label *fragmentlabel, struct ipq *ipq,
327 		    struct label *ipqlabel);
328 typedef void	(*mpo_inpcb_sosetlabel_t)(struct socket *so,
329 		    struct label *label, struct inpcb *inp,
330 		    struct label *inplabel);
331 
332 typedef	void	(*mpo_create_mbuf_from_firewall_t)(struct mbuf *m,
333 		    struct label *label);
334 typedef void	(*mpo_destroy_syncache_label_t)(struct label *label);
335 typedef int	(*mpo_init_syncache_label_t)(struct label *label, int flag);
336 typedef void	(*mpo_init_syncache_from_inpcb_t)(struct label *label,
337 		    struct inpcb *inp);
338 typedef void	(*mpo_create_mbuf_from_syncache_t)(struct label *sc_label,
339 		    struct mbuf *m, struct label *mbuf_label);
340 /*
341  * Labeling event operations: processes.
342  */
343 typedef void	(*mpo_execve_transition_t)(struct ucred *old,
344 		    struct ucred *new, struct vnode *vp,
345 		    struct label *vnodelabel, struct label *interpvnodelabel,
346 		    struct image_params *imgp, struct label *execlabel);
347 typedef int	(*mpo_execve_will_transition_t)(struct ucred *old,
348 		    struct vnode *vp, struct label *vnodelabel,
349 		    struct label *interpvnodelabel,
350 		    struct image_params *imgp, struct label *execlabel);
351 typedef void	(*mpo_create_proc0_t)(struct ucred *cred);
352 typedef void	(*mpo_create_proc1_t)(struct ucred *cred);
353 typedef void	(*mpo_relabel_cred_t)(struct ucred *cred,
354 		    struct label *newlabel);
355 typedef void	(*mpo_thread_userret_t)(struct thread *thread);
356 
357 /*
358  * Access control checks.
359  */
360 typedef	int	(*mpo_check_bpfdesc_receive_t)(struct bpf_d *bpf_d,
361 		    struct label *bpflabel, struct ifnet *ifnet,
362 		    struct label *ifnetlabel);
363 typedef int	(*mpo_check_cred_relabel_t)(struct ucred *cred,
364 		    struct label *newlabel);
365 typedef int	(*mpo_check_cred_visible_t)(struct ucred *u1,
366 		    struct ucred *u2);
367 typedef int	(*mpo_check_ifnet_relabel_t)(struct ucred *cred,
368 		    struct ifnet *ifnet, struct label *ifnetlabel,
369 		    struct label *newlabel);
370 typedef int	(*mpo_check_ifnet_transmit_t)(struct ifnet *ifnet,
371 		    struct label *ifnetlabel, struct mbuf *m,
372 		    struct label *mbuflabel);
373 typedef int	(*mpo_check_inpcb_deliver_t)(struct inpcb *inp,
374 		    struct label *inplabel, struct mbuf *m,
375 		    struct label *mlabel);
376 typedef int	(*mpo_check_sysv_msgmsq_t)(struct ucred *cred,
377 		    struct msg *msgptr, struct label *msglabel,
378 		    struct msqid_kernel *msqkptr, struct label *msqklabel);
379 typedef int	(*mpo_check_sysv_msgrcv_t)(struct ucred *cred,
380 		    struct msg *msgptr, struct label *msglabel);
381 typedef int	(*mpo_check_sysv_msgrmid_t)(struct ucred *cred,
382 		    struct msg *msgptr, struct label *msglabel);
383 typedef int	(*mpo_check_sysv_msqget_t)(struct ucred *cred,
384 		    struct msqid_kernel *msqkptr, struct label *msqklabel);
385 typedef int	(*mpo_check_sysv_msqsnd_t)(struct ucred *cred,
386 		    struct msqid_kernel *msqkptr, struct label *msqklabel);
387 typedef int	(*mpo_check_sysv_msqrcv_t)(struct ucred *cred,
388 		    struct msqid_kernel *msqkptr, struct label *msqklabel);
389 typedef int	(*mpo_check_sysv_msqctl_t)(struct ucred *cred,
390 		    struct msqid_kernel *msqkptr, struct label *msqklabel,
391 		    int cmd);
392 typedef int	(*mpo_check_sysv_semctl_t)(struct ucred *cred,
393 		    struct semid_kernel *semakptr, struct label *semaklabel,
394 		    int cmd);
395 typedef int	(*mpo_check_sysv_semget_t)(struct ucred *cred,
396 		    struct semid_kernel *semakptr, struct label *semaklabel);
397 typedef int	(*mpo_check_sysv_semop_t)(struct ucred *cred,
398 		    struct semid_kernel *semakptr, struct label *semaklabel,
399 		    size_t accesstype);
400 typedef int	(*mpo_check_sysv_shmat_t)(struct ucred *cred,
401 		    struct shmid_kernel *shmsegptr,
402 		    struct label *shmseglabel, int shmflg);
403 typedef int	(*mpo_check_sysv_shmctl_t)(struct ucred *cred,
404 		    struct shmid_kernel *shmsegptr,
405 		    struct label *shmseglabel, int cmd);
406 typedef int	(*mpo_check_sysv_shmdt_t)(struct ucred *cred,
407 		    struct shmid_kernel *shmsegptr,
408 		    struct label *shmseglabel);
409 typedef int	(*mpo_check_sysv_shmget_t)(struct ucred *cred,
410 		    struct shmid_kernel *shmsegptr,
411 		    struct label *shmseglabel, int shmflg);
412 typedef int	(*mpo_check_kenv_dump_t)(struct ucred *cred);
413 typedef int	(*mpo_check_kenv_get_t)(struct ucred *cred, char *name);
414 typedef int	(*mpo_check_kenv_set_t)(struct ucred *cred, char *name,
415 		    char *value);
416 typedef int	(*mpo_check_kenv_unset_t)(struct ucred *cred, char *name);
417 typedef int	(*mpo_check_kld_load_t)(struct ucred *cred, struct vnode *vp,
418 		    struct label *vlabel);
419 typedef int	(*mpo_check_kld_stat_t)(struct ucred *cred);
420 typedef int	(*mpo_check_kld_unload_t)(struct ucred *cred);
421 typedef int	(*mpo_mpo_placeholder19_t)(void);
422 typedef int	(*mpo_mpo_placeholder20_t)(void);
423 typedef int	(*mpo_check_mount_stat_t)(struct ucred *cred,
424 		    struct mount *mp, struct label *mntlabel);
425 typedef int	(*mpo_mpo_placeholder21_t)(void);
426 typedef int	(*mpo_check_pipe_ioctl_t)(struct ucred *cred,
427 		    struct pipepair *pp, struct label *pipelabel,
428 		    unsigned long cmd, void *data);
429 typedef int	(*mpo_check_pipe_poll_t)(struct ucred *cred,
430 		    struct pipepair *pp, struct label *pipelabel);
431 typedef int	(*mpo_check_pipe_read_t)(struct ucred *cred,
432 		    struct pipepair *pp, struct label *pipelabel);
433 typedef int	(*mpo_check_pipe_relabel_t)(struct ucred *cred,
434 		    struct pipepair *pp, struct label *pipelabel,
435 		    struct label *newlabel);
436 typedef int	(*mpo_check_pipe_stat_t)(struct ucred *cred,
437 		    struct pipepair *pp, struct label *pipelabel);
438 typedef int	(*mpo_check_pipe_write_t)(struct ucred *cred,
439 		    struct pipepair *pp, struct label *pipelabel);
440 typedef int	(*mpo_check_posix_sem_destroy_t)(struct ucred *cred,
441 		    struct ksem *ksemptr, struct label *ks_label);
442 typedef int	(*mpo_check_posix_sem_getvalue_t)(struct ucred *cred,
443 		    struct ksem *ksemptr, struct label *ks_label);
444 typedef int	(*mpo_check_posix_sem_open_t)(struct ucred *cred,
445 		    struct ksem *ksemptr, struct label *ks_label);
446 typedef int	(*mpo_check_posix_sem_post_t)(struct ucred *cred,
447 		    struct ksem *ksemptr, struct label *ks_label);
448 typedef int	(*mpo_check_posix_sem_unlink_t)(struct ucred *cred,
449 		    struct ksem *ksemptr, struct label *ks_label);
450 typedef int	(*mpo_check_posix_sem_wait_t)(struct ucred *cred,
451 		    struct ksem *ksemptr, struct label *ks_label);
452 typedef int	(*mpo_check_proc_debug_t)(struct ucred *cred,
453 		    struct proc *proc);
454 typedef int	(*mpo_check_proc_sched_t)(struct ucred *cred,
455 		    struct proc *proc);
456 typedef int	(*mpo_check_proc_setuid_t)(struct ucred *cred, uid_t uid);
457 typedef int	(*mpo_check_proc_seteuid_t)(struct ucred *cred, uid_t euid);
458 typedef int	(*mpo_check_proc_setgid_t)(struct ucred *cred, gid_t gid);
459 typedef int	(*mpo_check_proc_setegid_t)(struct ucred *cred, gid_t egid);
460 typedef int	(*mpo_check_proc_setgroups_t)(struct ucred *cred, int ngroups,
461 		    gid_t *gidset);
462 typedef int	(*mpo_check_proc_setreuid_t)(struct ucred *cred, uid_t ruid,
463 		    uid_t euid);
464 typedef int	(*mpo_check_proc_setregid_t)(struct ucred *cred, gid_t rgid,
465 		    gid_t egid);
466 typedef int	(*mpo_check_proc_setresuid_t)(struct ucred *cred, uid_t ruid,
467 		    uid_t euid, uid_t suid);
468 typedef int	(*mpo_check_proc_setresgid_t)(struct ucred *cred, gid_t rgid,
469 		    gid_t egid, gid_t sgid);
470 typedef int	(*mpo_check_proc_signal_t)(struct ucred *cred,
471 		    struct proc *proc, int signum);
472 typedef int	(*mpo_check_proc_wait_t)(struct ucred *cred,
473 		    struct proc *proc);
474 typedef int	(*mpo_check_socket_accept_t)(struct ucred *cred,
475 		    struct socket *so, struct label *socketlabel);
476 typedef int	(*mpo_check_socket_bind_t)(struct ucred *cred,
477 		    struct socket *so, struct label *socketlabel,
478 		    struct sockaddr *sockaddr);
479 typedef int	(*mpo_check_socket_connect_t)(struct ucred *cred,
480 		    struct socket *so, struct label *socketlabel,
481 		    struct sockaddr *sockaddr);
482 typedef int	(*mpo_check_socket_create_t)(struct ucred *cred, int domain,
483 		    int type, int protocol);
484 typedef int	(*mpo_check_socket_deliver_t)(struct socket *so,
485 		    struct label *socketlabel, struct mbuf *m,
486 		    struct label *mbuflabel);
487 typedef int	(*mpo_check_socket_listen_t)(struct ucred *cred,
488 		    struct socket *so, struct label *socketlabel);
489 typedef int	(*mpo_check_socket_poll_t)(struct ucred *cred,
490 		    struct socket *so, struct label *socketlabel);
491 typedef int	(*mpo_check_socket_receive_t)(struct ucred *cred,
492 		    struct socket *so, struct label *socketlabel);
493 typedef int	(*mpo_check_socket_relabel_t)(struct ucred *cred,
494 		    struct socket *so, struct label *socketlabel,
495 		    struct label *newlabel);
496 typedef int	(*mpo_check_socket_send_t)(struct ucred *cred,
497 		    struct socket *so, struct label *socketlabel);
498 typedef int	(*mpo_check_socket_stat_t)(struct ucred *cred,
499 		    struct socket *so, struct label *socketlabel);
500 typedef int	(*mpo_check_socket_visible_t)(struct ucred *cred,
501 		    struct socket *so, struct label *socketlabel);
502 typedef int	(*mpo_check_sysarch_ioperm_t)(struct ucred *cred);
503 typedef int	(*mpo_check_system_acct_t)(struct ucred *cred,
504 		    struct vnode *vp, struct label *vlabel);
505 typedef int	(*mpo_check_system_nfsd_t)(struct ucred *cred);
506 typedef int	(*mpo_check_system_reboot_t)(struct ucred *cred, int howto);
507 typedef int	(*mpo_check_system_settime_t)(struct ucred *cred);
508 typedef int	(*mpo_check_system_swapon_t)(struct ucred *cred,
509 		    struct vnode *vp, struct label *label);
510 typedef int	(*mpo_check_system_swapoff_t)(struct ucred *cred,
511 		    struct vnode *vp, struct label *label);
512 typedef int	(*mpo_check_system_sysctl_t)(struct ucred *cred,
513 		    struct sysctl_oid *oidp, void *arg1, int arg2,
514 		    struct sysctl_req *req);
515 typedef int	(*mpo_check_vnode_access_t)(struct ucred *cred,
516 		    struct vnode *vp, struct label *label, int acc_mode);
517 typedef int	(*mpo_check_vnode_chdir_t)(struct ucred *cred,
518 		    struct vnode *dvp, struct label *dlabel);
519 typedef int	(*mpo_check_vnode_chroot_t)(struct ucred *cred,
520 		    struct vnode *dvp, struct label *dlabel);
521 typedef int	(*mpo_check_vnode_create_t)(struct ucred *cred,
522 		    struct vnode *dvp, struct label *dlabel,
523 		    struct componentname *cnp, struct vattr *vap);
524 typedef int	(*mpo_check_vnode_delete_t)(struct ucred *cred,
525 		    struct vnode *dvp, struct label *dlabel,
526 		    struct vnode *vp, struct label *label,
527 		    struct componentname *cnp);
528 typedef int	(*mpo_check_vnode_deleteacl_t)(struct ucred *cred,
529 		    struct vnode *vp, struct label *label, acl_type_t type);
530 typedef int	(*mpo_check_vnode_deleteextattr_t)(struct ucred *cred,
531 		    struct vnode *vp, struct label *label, int attrnamespace,
532 		    const char *name);
533 typedef int	(*mpo_check_vnode_exec_t)(struct ucred *cred,
534 		    struct vnode *vp, struct label *label,
535 		    struct image_params *imgp, struct label *execlabel);
536 typedef int	(*mpo_check_vnode_getacl_t)(struct ucred *cred,
537 		    struct vnode *vp, struct label *label, acl_type_t type);
538 typedef int	(*mpo_check_vnode_getextattr_t)(struct ucred *cred,
539 		    struct vnode *vp, struct label *label, int attrnamespace,
540 		    const char *name, struct uio *uio);
541 typedef int	(*mpo_check_vnode_link_t)(struct ucred *cred,
542 		    struct vnode *dvp, struct label *dlabel, struct vnode *vp,
543 		    struct label *label, struct componentname *cnp);
544 typedef int	(*mpo_check_vnode_listextattr_t)(struct ucred *cred,
545 		    struct vnode *vp, struct label *label,
546 		    int attrnamespace);
547 typedef int	(*mpo_check_vnode_lookup_t)(struct ucred *cred,
548 		    struct vnode *dvp, struct label *dlabel,
549 		    struct componentname *cnp);
550 typedef int	(*mpo_check_vnode_mmap_t)(struct ucred *cred,
551 		    struct vnode *vp, struct label *label, int prot,
552 		    int flags);
553 typedef void	(*mpo_check_vnode_mmap_downgrade_t)(struct ucred *cred,
554 		    struct vnode *vp, struct label *label, int *prot);
555 typedef int	(*mpo_check_vnode_mprotect_t)(struct ucred *cred,
556 		    struct vnode *vp, struct label *label, int prot);
557 typedef int	(*mpo_check_vnode_open_t)(struct ucred *cred,
558 		    struct vnode *vp, struct label *label, int acc_mode);
559 typedef int	(*mpo_check_vnode_poll_t)(struct ucred *active_cred,
560 		    struct ucred *file_cred, struct vnode *vp,
561 		    struct label *label);
562 typedef int	(*mpo_check_vnode_read_t)(struct ucred *active_cred,
563 		    struct ucred *file_cred, struct vnode *vp,
564 		    struct label *label);
565 typedef int	(*mpo_check_vnode_readdir_t)(struct ucred *cred,
566 		    struct vnode *dvp, struct label *dlabel);
567 typedef int	(*mpo_check_vnode_readlink_t)(struct ucred *cred,
568 		    struct vnode *vp, struct label *label);
569 typedef int	(*mpo_check_vnode_relabel_t)(struct ucred *cred,
570 		    struct vnode *vp, struct label *vnodelabel,
571 		    struct label *newlabel);
572 typedef int	(*mpo_check_vnode_rename_from_t)(struct ucred *cred,
573 		    struct vnode *dvp, struct label *dlabel,
574 		    struct vnode *vp, struct label *label,
575 		    struct componentname *cnp);
576 typedef int	(*mpo_check_vnode_rename_to_t)(struct ucred *cred,
577 		    struct vnode *dvp, struct label *dlabel,
578 		    struct vnode *vp, struct label *label, int samedir,
579 		    struct componentname *cnp);
580 typedef int	(*mpo_check_vnode_revoke_t)(struct ucred *cred,
581 		    struct vnode *vp, struct label *label);
582 typedef int	(*mpo_check_vnode_setacl_t)(struct ucred *cred,
583 		    struct vnode *vp, struct label *label, acl_type_t type,
584 		    struct acl *acl);
585 typedef int	(*mpo_check_vnode_setextattr_t)(struct ucred *cred,
586 		    struct vnode *vp, struct label *label, int attrnamespace,
587 		    const char *name, struct uio *uio);
588 typedef int	(*mpo_check_vnode_setflags_t)(struct ucred *cred,
589 		    struct vnode *vp, struct label *label, u_long flags);
590 typedef int	(*mpo_check_vnode_setmode_t)(struct ucred *cred,
591 		    struct vnode *vp, struct label *label, mode_t mode);
592 typedef int	(*mpo_check_vnode_setowner_t)(struct ucred *cred,
593 		    struct vnode *vp, struct label *label, uid_t uid,
594 		    gid_t gid);
595 typedef int	(*mpo_check_vnode_setutimes_t)(struct ucred *cred,
596 		    struct vnode *vp, struct label *label,
597 		    struct timespec atime, struct timespec mtime);
598 typedef int	(*mpo_check_vnode_stat_t)(struct ucred *active_cred,
599 		    struct ucred *file_cred, struct vnode *vp,
600 		    struct label *label);
601 typedef int	(*mpo_check_vnode_write_t)(struct ucred *active_cred,
602 		    struct ucred *file_cred, struct vnode *vp,
603 		    struct label *label);
604 typedef void	(*mpo_associate_nfsd_label_t)(struct ucred *cred);
605 typedef int	(*mpo_priv_check_t)(struct ucred *cred, int priv);
606 typedef int	(*mpo_priv_grant_t)(struct ucred *cred, int priv);
607 
608 struct mac_policy_ops {
609 	/*
610 	 * Policy module operations.
611 	 */
612 	mpo_destroy_t				mpo_destroy;
613 	mpo_init_t				mpo_init;
614 
615 	/*
616 	 * General policy-directed security system call so that policies may
617 	 * implement new services without reserving explicit system call
618 	 * numbers.
619 	 */
620 	mpo_syscall_t				mpo_syscall;
621 
622 	/*
623 	 * Label operations.  Initialize label storage, destroy label
624 	 * storage, recycle for re-use without init/destroy, copy a label to
625 	 * initialized storage, and externalize/internalize from/to
626 	 * initialized storage.
627 	 */
628 	mpo_init_bpfdesc_label_t		mpo_init_bpfdesc_label;
629 	mpo_init_cred_label_t			mpo_init_cred_label;
630 	mpo_init_devfsdirent_label_t		mpo_init_devfsdirent_label;
631 	mpo_placeholder_t			_mpo_placeholder0;
632 	mpo_init_ifnet_label_t			mpo_init_ifnet_label;
633 	mpo_init_inpcb_label_t			mpo_init_inpcb_label;
634 	mpo_init_sysv_msgmsg_label_t		mpo_init_sysv_msgmsg_label;
635 	mpo_init_sysv_msgqueue_label_t		mpo_init_sysv_msgqueue_label;
636 	mpo_init_sysv_sem_label_t		mpo_init_sysv_sem_label;
637 	mpo_init_sysv_shm_label_t		mpo_init_sysv_shm_label;
638 	mpo_init_ipq_label_t			mpo_init_ipq_label;
639 	mpo_init_mbuf_label_t			mpo_init_mbuf_label;
640 	mpo_init_mount_label_t			mpo_init_mount_label;
641 	mpo_init_mount_fs_label_t		mpo_init_mount_fs_label;
642 	mpo_init_socket_label_t			mpo_init_socket_label;
643 	mpo_init_socket_peer_label_t		mpo_init_socket_peer_label;
644 	mpo_init_pipe_label_t			mpo_init_pipe_label;
645 	mpo_init_posix_sem_label_t		mpo_init_posix_sem_label;
646 	mpo_init_proc_label_t			mpo_init_proc_label;
647 	mpo_init_vnode_label_t			mpo_init_vnode_label;
648 	mpo_destroy_bpfdesc_label_t		mpo_destroy_bpfdesc_label;
649 	mpo_destroy_cred_label_t		mpo_destroy_cred_label;
650 	mpo_destroy_devfsdirent_label_t		mpo_destroy_devfsdirent_label;
651 	mpo_placeholder_t			_mpo_placeholder1;
652 	mpo_destroy_ifnet_label_t		mpo_destroy_ifnet_label;
653 	mpo_destroy_inpcb_label_t		mpo_destroy_inpcb_label;
654 	mpo_destroy_sysv_msgmsg_label_t		mpo_destroy_sysv_msgmsg_label;
655 	mpo_destroy_sysv_msgqueue_label_t	mpo_destroy_sysv_msgqueue_label;
656 	mpo_destroy_sysv_sem_label_t		mpo_destroy_sysv_sem_label;
657 	mpo_destroy_sysv_shm_label_t		mpo_destroy_sysv_shm_label;
658 	mpo_destroy_ipq_label_t			mpo_destroy_ipq_label;
659 	mpo_destroy_mbuf_label_t		mpo_destroy_mbuf_label;
660 	mpo_destroy_mount_label_t		mpo_destroy_mount_label;
661 	mpo_destroy_mount_fs_label_t		mpo_destroy_mount_fs_label;
662 	mpo_destroy_socket_label_t		mpo_destroy_socket_label;
663 	mpo_destroy_socket_peer_label_t		mpo_destroy_socket_peer_label;
664 	mpo_destroy_pipe_label_t		mpo_destroy_pipe_label;
665 	mpo_destroy_posix_sem_label_t		mpo_destroy_posix_sem_label;
666 	mpo_destroy_proc_label_t		mpo_destroy_proc_label;
667 	mpo_destroy_vnode_label_t		mpo_destroy_vnode_label;
668 	mpo_cleanup_sysv_msgmsg_t		mpo_cleanup_sysv_msgmsg;
669 	mpo_cleanup_sysv_msgqueue_t		mpo_cleanup_sysv_msgqueue;
670 	mpo_cleanup_sysv_sem_t			mpo_cleanup_sysv_sem;
671 	mpo_cleanup_sysv_shm_t			mpo_cleanup_sysv_shm;
672 	mpo_copy_cred_label_t			mpo_copy_cred_label;
673 	mpo_copy_ifnet_label_t			mpo_copy_ifnet_label;
674 	mpo_copy_mbuf_label_t			mpo_copy_mbuf_label;
675 	mpo_placeholder_t			_mpo_placeholder2;
676 	mpo_copy_pipe_label_t			mpo_copy_pipe_label;
677 	mpo_copy_socket_label_t			mpo_copy_socket_label;
678 	mpo_copy_vnode_label_t			mpo_copy_vnode_label;
679 	mpo_externalize_cred_label_t		mpo_externalize_cred_label;
680 	mpo_externalize_ifnet_label_t		mpo_externalize_ifnet_label;
681 	mpo_placeholder_t			_mpo_placeholder3;
682 	mpo_externalize_pipe_label_t		mpo_externalize_pipe_label;
683 	mpo_externalize_socket_label_t		mpo_externalize_socket_label;
684 	mpo_externalize_socket_peer_label_t	mpo_externalize_socket_peer_label;
685 	mpo_externalize_vnode_label_t		mpo_externalize_vnode_label;
686 	mpo_internalize_cred_label_t		mpo_internalize_cred_label;
687 	mpo_internalize_ifnet_label_t		mpo_internalize_ifnet_label;
688 	mpo_placeholder_t			_mpo_placeholder4;
689 	mpo_internalize_pipe_label_t		mpo_internalize_pipe_label;
690 	mpo_internalize_socket_label_t		mpo_internalize_socket_label;
691 	mpo_internalize_vnode_label_t		mpo_internalize_vnode_label;
692 
693 	/*
694 	 * Labeling event operations: file system objects, and things that
695 	 * look a lot like file system objects.
696 	 */
697 	mpo_associate_vnode_devfs_t		mpo_associate_vnode_devfs;
698 	mpo_associate_vnode_extattr_t		mpo_associate_vnode_extattr;
699 	mpo_associate_vnode_singlelabel_t	mpo_associate_vnode_singlelabel;
700 	mpo_create_devfs_device_t		mpo_create_devfs_device;
701 	mpo_create_devfs_directory_t		mpo_create_devfs_directory;
702 	mpo_create_devfs_symlink_t		mpo_create_devfs_symlink;
703 	mpo_placeholder_t			_mpo_placeholder5;
704 	mpo_create_vnode_extattr_t		mpo_create_vnode_extattr;
705 	mpo_create_mount_t			mpo_create_mount;
706 	mpo_relabel_vnode_t			mpo_relabel_vnode;
707 	mpo_setlabel_vnode_extattr_t		mpo_setlabel_vnode_extattr;
708 	mpo_update_devfsdirent_t		mpo_update_devfsdirent;
709 
710 	/*
711 	 * Labeling event operations: IPC objects.
712 	 */
713 	mpo_create_mbuf_from_socket_t		mpo_create_mbuf_from_socket;
714 	mpo_create_socket_t			mpo_create_socket;
715 	mpo_create_socket_from_socket_t		mpo_create_socket_from_socket;
716 	mpo_relabel_socket_t			mpo_relabel_socket;
717 	mpo_relabel_pipe_t			mpo_relabel_pipe;
718 	mpo_set_socket_peer_from_mbuf_t		mpo_set_socket_peer_from_mbuf;
719 	mpo_set_socket_peer_from_socket_t	mpo_set_socket_peer_from_socket;
720 	mpo_create_pipe_t			mpo_create_pipe;
721 
722 	/*
723 	 * Labeling event operations: System V IPC primitives.
724 	 */
725 	mpo_create_sysv_msgmsg_t		mpo_create_sysv_msgmsg;
726 	mpo_create_sysv_msgqueue_t		mpo_create_sysv_msgqueue;
727 	mpo_create_sysv_sem_t			mpo_create_sysv_sem;
728 	mpo_create_sysv_shm_t			mpo_create_sysv_shm;
729 
730 	/*
731 	 * Labeling event operations: POSIX (global/inter-process) semaphores.
732 	 */
733 	mpo_create_posix_sem_t			mpo_create_posix_sem;
734 
735 	/*
736 	 * Labeling event operations: network objects.
737 	 */
738 	mpo_create_bpfdesc_t			mpo_create_bpfdesc;
739 	mpo_create_ifnet_t			mpo_create_ifnet;
740 	mpo_create_inpcb_from_socket_t		mpo_create_inpcb_from_socket;
741 	mpo_create_ipq_t			mpo_create_ipq;
742 	mpo_create_datagram_from_ipq		mpo_create_datagram_from_ipq;
743 	mpo_create_fragment_t			mpo_create_fragment;
744 	mpo_create_mbuf_from_inpcb_t		mpo_create_mbuf_from_inpcb;
745 	mpo_create_mbuf_linklayer_t		mpo_create_mbuf_linklayer;
746 	mpo_create_mbuf_from_bpfdesc_t		mpo_create_mbuf_from_bpfdesc;
747 	mpo_create_mbuf_from_ifnet_t		mpo_create_mbuf_from_ifnet;
748 	mpo_create_mbuf_multicast_encap_t	mpo_create_mbuf_multicast_encap;
749 	mpo_create_mbuf_netlayer_t		mpo_create_mbuf_netlayer;
750 	mpo_fragment_match_t			mpo_fragment_match;
751 	mpo_reflect_mbuf_icmp_t			mpo_reflect_mbuf_icmp;
752 	mpo_reflect_mbuf_tcp_t			mpo_reflect_mbuf_tcp;
753 	mpo_relabel_ifnet_t			mpo_relabel_ifnet;
754 	mpo_update_ipq_t			mpo_update_ipq;
755 	mpo_inpcb_sosetlabel_t			mpo_inpcb_sosetlabel;
756 
757 	/*
758 	 * Labeling event operations: processes.
759 	 */
760 	mpo_execve_transition_t			mpo_execve_transition;
761 	mpo_execve_will_transition_t		mpo_execve_will_transition;
762 	mpo_create_proc0_t			mpo_create_proc0;
763 	mpo_create_proc1_t			mpo_create_proc1;
764 	mpo_relabel_cred_t			mpo_relabel_cred;
765 	mpo_placeholder_t			_mpo_placeholder6;
766 	mpo_thread_userret_t			mpo_thread_userret;
767 
768 	/*
769 	 * Access control checks.
770 	 */
771 	mpo_check_bpfdesc_receive_t		mpo_check_bpfdesc_receive;
772 	mpo_placeholder_t			_mpo_placeholder7;
773 	mpo_check_cred_relabel_t		mpo_check_cred_relabel;
774 	mpo_check_cred_visible_t		mpo_check_cred_visible;
775 	mpo_placeholder_t			_mpo_placeholder8;
776 	mpo_placeholder_t			_mpo_placeholder9;
777 	mpo_placeholder_t			_mpo_placeholder10;
778 	mpo_placeholder_t			_mpo_placeholder11;
779 	mpo_placeholder_t			_mpo_placeholder12;
780 	mpo_placeholder_t			_mpo_placeholder13;
781 	mpo_placeholder_t			_mpo_placeholder14;
782 	mpo_placeholder_t			_mpo_placeholder15;
783 	mpo_placeholder_t			_mpo_placeholder16;
784 	mpo_placeholder_t			_mpo_placeholder17;
785 	mpo_placeholder_t			_mpo_placeholder18;
786 	mpo_check_ifnet_relabel_t		mpo_check_ifnet_relabel;
787 	mpo_check_ifnet_transmit_t		mpo_check_ifnet_transmit;
788 	mpo_check_inpcb_deliver_t		mpo_check_inpcb_deliver;
789 	mpo_check_sysv_msgmsq_t			mpo_check_sysv_msgmsq;
790 	mpo_check_sysv_msgrcv_t			mpo_check_sysv_msgrcv;
791 	mpo_check_sysv_msgrmid_t		mpo_check_sysv_msgrmid;
792 	mpo_check_sysv_msqget_t			mpo_check_sysv_msqget;
793 	mpo_check_sysv_msqsnd_t			mpo_check_sysv_msqsnd;
794 	mpo_check_sysv_msqrcv_t			mpo_check_sysv_msqrcv;
795 	mpo_check_sysv_msqctl_t			mpo_check_sysv_msqctl;
796 	mpo_check_sysv_semctl_t			mpo_check_sysv_semctl;
797 	mpo_check_sysv_semget_t			mpo_check_sysv_semget;
798 	mpo_check_sysv_semop_t			mpo_check_sysv_semop;
799 	mpo_check_sysv_shmat_t			mpo_check_sysv_shmat;
800 	mpo_check_sysv_shmctl_t			mpo_check_sysv_shmctl;
801 	mpo_check_sysv_shmdt_t			mpo_check_sysv_shmdt;
802 	mpo_check_sysv_shmget_t			mpo_check_sysv_shmget;
803 	mpo_check_kenv_dump_t			mpo_check_kenv_dump;
804 	mpo_check_kenv_get_t			mpo_check_kenv_get;
805 	mpo_check_kenv_set_t			mpo_check_kenv_set;
806 	mpo_check_kenv_unset_t			mpo_check_kenv_unset;
807 	mpo_check_kld_load_t			mpo_check_kld_load;
808 	mpo_check_kld_stat_t			mpo_check_kld_stat;
809 	mpo_check_kld_unload_t			mpo_check_kld_unload;
810 	mpo_placeholder_t			_mpo_placeholder19;
811 	mpo_placeholder_t			_mpo_placeholder20;
812 	mpo_check_mount_stat_t			mpo_check_mount_stat;
813 	mpo_placeholder_t			_mpo_placeholder_21;
814 	mpo_check_pipe_ioctl_t			mpo_check_pipe_ioctl;
815 	mpo_check_pipe_poll_t			mpo_check_pipe_poll;
816 	mpo_check_pipe_read_t			mpo_check_pipe_read;
817 	mpo_check_pipe_relabel_t		mpo_check_pipe_relabel;
818 	mpo_check_pipe_stat_t			mpo_check_pipe_stat;
819 	mpo_check_pipe_write_t			mpo_check_pipe_write;
820 	mpo_check_posix_sem_destroy_t		mpo_check_posix_sem_destroy;
821 	mpo_check_posix_sem_getvalue_t		mpo_check_posix_sem_getvalue;
822 	mpo_check_posix_sem_open_t		mpo_check_posix_sem_open;
823 	mpo_check_posix_sem_post_t		mpo_check_posix_sem_post;
824 	mpo_check_posix_sem_unlink_t		mpo_check_posix_sem_unlink;
825 	mpo_check_posix_sem_wait_t		mpo_check_posix_sem_wait;
826 	mpo_check_proc_debug_t			mpo_check_proc_debug;
827 	mpo_check_proc_sched_t			mpo_check_proc_sched;
828 	mpo_check_proc_setuid_t			mpo_check_proc_setuid;
829 	mpo_check_proc_seteuid_t		mpo_check_proc_seteuid;
830 	mpo_check_proc_setgid_t			mpo_check_proc_setgid;
831 	mpo_check_proc_setegid_t		mpo_check_proc_setegid;
832 	mpo_check_proc_setgroups_t		mpo_check_proc_setgroups;
833 	mpo_check_proc_setreuid_t		mpo_check_proc_setreuid;
834 	mpo_check_proc_setregid_t		mpo_check_proc_setregid;
835 	mpo_check_proc_setresuid_t		mpo_check_proc_setresuid;
836 	mpo_check_proc_setresgid_t		mpo_check_proc_setresgid;
837 	mpo_check_proc_signal_t			mpo_check_proc_signal;
838 	mpo_check_proc_wait_t			mpo_check_proc_wait;
839 	mpo_check_socket_accept_t		mpo_check_socket_accept;
840 	mpo_check_socket_bind_t			mpo_check_socket_bind;
841 	mpo_check_socket_connect_t		mpo_check_socket_connect;
842 	mpo_check_socket_create_t		mpo_check_socket_create;
843 	mpo_check_socket_deliver_t		mpo_check_socket_deliver;
844 	mpo_placeholder_t			_mpo_placeholder22;
845 	mpo_check_socket_listen_t		mpo_check_socket_listen;
846 	mpo_check_socket_poll_t			mpo_check_socket_poll;
847 	mpo_check_socket_receive_t		mpo_check_socket_receive;
848 	mpo_check_socket_relabel_t		mpo_check_socket_relabel;
849 	mpo_check_socket_send_t			mpo_check_socket_send;
850 	mpo_check_socket_stat_t			mpo_check_socket_stat;
851 	mpo_check_socket_visible_t		mpo_check_socket_visible;
852 	mpo_check_sysarch_ioperm_t		mpo_check_sysarch_ioperm;
853 	mpo_check_system_acct_t			mpo_check_system_acct;
854 	mpo_check_system_nfsd_t			mpo_check_system_nfsd;
855 	mpo_check_system_reboot_t		mpo_check_system_reboot;
856 	mpo_check_system_settime_t		mpo_check_system_settime;
857 	mpo_check_system_swapon_t		mpo_check_system_swapon;
858 	mpo_check_system_swapoff_t		mpo_check_system_swapoff;
859 	mpo_check_system_sysctl_t		mpo_check_system_sysctl;
860 	mpo_placeholder_t			_mpo_placeholder23;
861 	mpo_check_vnode_access_t		mpo_check_vnode_access;
862 	mpo_check_vnode_chdir_t			mpo_check_vnode_chdir;
863 	mpo_check_vnode_chroot_t		mpo_check_vnode_chroot;
864 	mpo_check_vnode_create_t		mpo_check_vnode_create;
865 	mpo_check_vnode_delete_t		mpo_check_vnode_delete;
866 	mpo_check_vnode_deleteacl_t		mpo_check_vnode_deleteacl;
867 	mpo_check_vnode_deleteextattr_t		mpo_check_vnode_deleteextattr;
868 	mpo_check_vnode_exec_t			mpo_check_vnode_exec;
869 	mpo_check_vnode_getacl_t		mpo_check_vnode_getacl;
870 	mpo_check_vnode_getextattr_t		mpo_check_vnode_getextattr;
871 	mpo_placeholder_t			_mpo_placeholder24;
872 	mpo_check_vnode_link_t			mpo_check_vnode_link;
873 	mpo_check_vnode_listextattr_t		mpo_check_vnode_listextattr;
874 	mpo_check_vnode_lookup_t		mpo_check_vnode_lookup;
875 	mpo_check_vnode_mmap_t			mpo_check_vnode_mmap;
876 	mpo_check_vnode_mmap_downgrade_t	mpo_check_vnode_mmap_downgrade;
877 	mpo_check_vnode_mprotect_t		mpo_check_vnode_mprotect;
878 	mpo_check_vnode_open_t			mpo_check_vnode_open;
879 	mpo_check_vnode_poll_t			mpo_check_vnode_poll;
880 	mpo_check_vnode_read_t			mpo_check_vnode_read;
881 	mpo_check_vnode_readdir_t		mpo_check_vnode_readdir;
882 	mpo_check_vnode_readlink_t		mpo_check_vnode_readlink;
883 	mpo_check_vnode_relabel_t		mpo_check_vnode_relabel;
884 	mpo_check_vnode_rename_from_t		mpo_check_vnode_rename_from;
885 	mpo_check_vnode_rename_to_t		mpo_check_vnode_rename_to;
886 	mpo_check_vnode_revoke_t		mpo_check_vnode_revoke;
887 	mpo_check_vnode_setacl_t		mpo_check_vnode_setacl;
888 	mpo_check_vnode_setextattr_t		mpo_check_vnode_setextattr;
889 	mpo_check_vnode_setflags_t		mpo_check_vnode_setflags;
890 	mpo_check_vnode_setmode_t		mpo_check_vnode_setmode;
891 	mpo_check_vnode_setowner_t		mpo_check_vnode_setowner;
892 	mpo_check_vnode_setutimes_t		mpo_check_vnode_setutimes;
893 	mpo_check_vnode_stat_t			mpo_check_vnode_stat;
894 	mpo_check_vnode_write_t			mpo_check_vnode_write;
895 	mpo_associate_nfsd_label_t		mpo_associate_nfsd_label;
896 	mpo_create_mbuf_from_firewall_t		mpo_create_mbuf_from_firewall;
897 	mpo_init_syncache_label_t		mpo_init_syncache_label;
898 	mpo_destroy_syncache_label_t		mpo_destroy_syncache_label;
899 	mpo_init_syncache_from_inpcb_t		mpo_init_syncache_from_inpcb;
900 	mpo_create_mbuf_from_syncache_t		mpo_create_mbuf_from_syncache;
901 	mpo_priv_check_t			mpo_priv_check;
902 	mpo_priv_grant_t			mpo_priv_grant;
903 };
904 
905 /*
906  * struct mac_policy_conf is the registration structure for policies, and is
907  * provided to the MAC Framework using MAC_POLICY_SET() to invoke a SYSINIT
908  * to register the policy.  In general, the fields are immutable, with the
909  * exception of the "security field", run-time flags, and policy list entry,
910  * which are managed by the MAC Framework.  Be careful when modifying this
911  * structure, as its layout is statically compiled into all policies.
912  */
913 struct mac_policy_conf {
914 	char				*mpc_name;	/* policy name */
915 	char				*mpc_fullname;	/* policy full name */
916 	struct mac_policy_ops		*mpc_ops;	/* policy operations */
917 	int				 mpc_loadtime_flags;	/* flags */
918 	int				*mpc_field_off; /* security field */
919 	int				 mpc_runtime_flags; /* flags */
920 	LIST_ENTRY(mac_policy_conf)	 mpc_list;	/* global list */
921 };
922 
923 /* Flags for the mpc_loadtime_flags field. */
924 #define	MPC_LOADTIME_FLAG_NOTLATE	0x00000001
925 #define	MPC_LOADTIME_FLAG_UNLOADOK	0x00000002
926 #define	MPC_LOADTIME_FLAG_LABELMBUFS	0x00000004
927 
928 /* Flags for the mpc_runtime_flags field. */
929 #define	MPC_RUNTIME_FLAG_REGISTERED	0x00000001
930 
931 #define	MAC_POLICY_SET(mpops, mpname, mpfullname, mpflags, privdata_wanted) \
932 	static struct mac_policy_conf mpname##_mac_policy_conf = {	\
933 		#mpname,						\
934 		mpfullname,						\
935 		mpops,							\
936 		mpflags,						\
937 		privdata_wanted,					\
938 		0,							\
939 	};								\
940 	static moduledata_t mpname##_mod = {				\
941 		#mpname,						\
942 		mac_policy_modevent,					\
943 		&mpname##_mac_policy_conf				\
944 	};								\
945 	MODULE_DEPEND(mpname, kernel_mac_support, 3, 3, 3);		\
946 	DECLARE_MODULE(mpname, mpname##_mod, SI_SUB_MAC_POLICY,		\
947 	    SI_ORDER_MIDDLE)
948 
949 int	mac_policy_modevent(module_t mod, int type, void *data);
950 
951 /*
952  * Policy interface to map a struct label pointer to per-policy data.
953  * Typically, policies wrap this in their own accessor macro that casts a
954  * void pointer to a policy-specific data type.
955  *
956  * XXXRW: It might be preferable to provide get/set methods via functions to
957  * avoid encoding the struct label layout in compiled modules.
958  */
959 #define	LABEL_TO_SLOT(l, s)	(l)->l_perpolicy[s]
960 
961 #endif /* !_SYS_MAC_POLICY_H_ */
962