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