xref: /freebsd/sys/security/mac/mac_policy.h (revision 77b7cdf1999ee965ad494fddd184b18f532ac91a)
1 /*-
2  * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3  * Copyright (c) 2001, 2002, 2003 Networks Associates Technology, Inc.
4  * All rights reserved.
5  *
6  * This software was developed by Robert Watson for the TrustedBSD Project.
7  *
8  * This software was developed for the FreeBSD Project in part by Network
9  * Associates Laboratories, the Security Research Division of Network
10  * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
11  * as part of the DARPA CHATS research program.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $FreeBSD$
35  */
36 /*
37  * Kernel interface for MAC policy modules.
38  */
39 #ifndef _SYS_MAC_POLICY_H
40 #define _SYS_MAC_POLICY_H
41 
42 /*-
43  * Pluggable access control policy definition structure.
44  *
45  * List of operations that are performed as part of the implementation
46  * of a MAC policy.  Policy implementors declare operations with a
47  * mac_policy_ops structure, and using the MAC_POLICY_SET() macro.
48  * If an entry point is not declared, then then the policy will be ignored
49  * during evaluation of that event or check.
50  *
51  * Operations are sorted first by general class of operation, then
52  * alphabetically.
53  */
54 struct mac_policy_conf;
55 struct mac_policy_ops {
56 	/*
57 	 * Policy module operations.
58 	 */
59 	void	(*mpo_destroy)(struct mac_policy_conf *mpc);
60 	void	(*mpo_init)(struct mac_policy_conf *mpc);
61 
62 	/*
63 	 * General policy-directed security system call so that policies
64 	 * may implement new services without reserving explicit
65 	 * system call numbers.
66 	 */
67 	int	(*mpo_syscall)(struct thread *td, int call, void *arg);
68 
69 	/*
70 	 * Label operations.
71 	 */
72 	void	(*mpo_init_bpfdesc_label)(struct label *label);
73 	void	(*mpo_init_cred_label)(struct label *label);
74 	void	(*mpo_init_devfsdirent_label)(struct label *label);
75 	void	(*mpo_init_ifnet_label)(struct label *label);
76 	int	(*mpo_init_ipq_label)(struct label *label, int flag);
77 	int	(*mpo_init_mbuf_label)(struct label *label, int flag);
78 	void	(*mpo_init_mount_label)(struct label *label);
79 	void	(*mpo_init_mount_fs_label)(struct label *label);
80 	int	(*mpo_init_socket_label)(struct label *label, int flag);
81 	int	(*mpo_init_socket_peer_label)(struct label *label, int flag);
82 	void	(*mpo_init_pipe_label)(struct label *label);
83 	void	(*mpo_init_proc_label)(struct label *label);
84 	void	(*mpo_init_vnode_label)(struct label *label);
85 	void	(*mpo_destroy_bpfdesc_label)(struct label *label);
86 	void	(*mpo_destroy_cred_label)(struct label *label);
87 	void	(*mpo_destroy_devfsdirent_label)(struct label *label);
88 	void	(*mpo_destroy_ifnet_label)(struct label *label);
89 	void	(*mpo_destroy_ipq_label)(struct label *label);
90 	void	(*mpo_destroy_mbuf_label)(struct label *label);
91 	void	(*mpo_destroy_mount_label)(struct label *label);
92 	void	(*mpo_destroy_mount_fs_label)(struct label *label);
93 	void	(*mpo_destroy_socket_label)(struct label *label);
94 	void	(*mpo_destroy_socket_peer_label)(struct label *label);
95 	void	(*mpo_destroy_pipe_label)(struct label *label);
96 	void	(*mpo_destroy_proc_label)(struct label *label);
97 	void	(*mpo_destroy_vnode_label)(struct label *label);
98 	void	(*mpo_copy_mbuf_label)(struct label *src,
99 		    struct label *dest);
100 	void	(*mpo_copy_pipe_label)(struct label *src,
101 		    struct label *dest);
102 	void	(*mpo_copy_vnode_label)(struct label *src,
103 		    struct label *dest);
104 	int	(*mpo_externalize_cred_label)(struct label *label,
105 		    char *element_name, char *buffer, size_t buflen,
106 		    size_t *len, int *claimed);
107 	int	(*mpo_externalize_ifnet_label)(struct label *label,
108 		    char *element_name, char *buffer, size_t buflen,
109 		    size_t *len, int *claimed);
110 	int	(*mpo_externalize_pipe_label)(struct label *label,
111 		    char *element_name, char *buffer, size_t buflen,
112 		    size_t *len, int *claimed);
113 	int	(*mpo_externalize_socket_label)(struct label *label,
114 		    char *element_name, char *buffer, size_t buflen,
115 		    size_t *len, int *claimed);
116 	int	(*mpo_externalize_socket_peer_label)(struct label *label,
117 		    char *element_name, char *buffer, size_t buflen,
118 		    size_t *len, int *claimed);
119 	int	(*mpo_externalize_vnode_label)(struct label *label,
120 		    char *element_name, char *buffer, size_t buflen,
121 		    size_t *len, int *claimed);
122 	int	(*mpo_internalize_cred_label)(struct label *label,
123 		    char *element_name, char *element_data, int *claimed);
124 	int	(*mpo_internalize_ifnet_label)(struct label *label,
125 		    char *element_name, char *element_data, int *claimed);
126 	int	(*mpo_internalize_pipe_label)(struct label *label,
127 		    char *element_name, char *element_data, int *claimed);
128 	int	(*mpo_internalize_socket_label)(struct label *label,
129 		    char *element_name, char *element_data, int *claimed);
130 	int	(*mpo_internalize_vnode_label)(struct label *label,
131 		    char *element_name, char *element_data, int *claimed);
132 
133 	/*
134 	 * Labeling event operations: file system objects, and things that
135 	 * look a lot like file system objects.
136 	 */
137 	void	(*mpo_associate_vnode_devfs)(struct mount *mp,
138 		    struct label *fslabel, struct devfs_dirent *de,
139 		    struct label *delabel, struct vnode *vp,
140 		    struct label *vlabel);
141 	int	(*mpo_associate_vnode_extattr)(struct mount *mp,
142 		    struct label *fslabel, struct vnode *vp,
143 		    struct label *vlabel);
144 	void	(*mpo_associate_vnode_singlelabel)(struct mount *mp,
145 		    struct label *fslabel, struct vnode *vp,
146 		    struct label *vlabel);
147 	void	(*mpo_create_devfs_device)(struct mount *mp, dev_t dev,
148 		    struct devfs_dirent *de, struct label *label);
149 	void	(*mpo_create_devfs_directory)(struct mount *mp, char *dirname,
150 		    int dirnamelen, struct devfs_dirent *de,
151 		    struct label *label);
152 	void	(*mpo_create_devfs_symlink)(struct ucred *cred,
153 		    struct mount *mp, struct devfs_dirent *dd,
154 		    struct label *ddlabel, struct devfs_dirent *de,
155 		    struct label *delabel);
156 	int	(*mpo_create_vnode_extattr)(struct ucred *cred,
157 		    struct mount *mp, struct label *fslabel,
158 		    struct vnode *dvp, struct label *dlabel,
159 		    struct vnode *vp, struct label *vlabel,
160 		    struct componentname *cnp);
161 	void	(*mpo_create_mount)(struct ucred *cred, struct mount *mp,
162 		    struct label *mntlabel, struct label *fslabel);
163 	void	(*mpo_create_root_mount)(struct ucred *cred, struct mount *mp,
164 		    struct label *mountlabel, struct label *fslabel);
165 	void	(*mpo_relabel_vnode)(struct ucred *cred, struct vnode *vp,
166 		    struct label *vnodelabel, struct label *label);
167 	int	(*mpo_setlabel_vnode_extattr)(struct ucred *cred,
168 		    struct vnode *vp, struct label *vlabel,
169 		    struct label *intlabel);
170 	void	(*mpo_update_devfsdirent)(struct mount *mp,
171 		    struct devfs_dirent *devfs_dirent,
172 		    struct label *direntlabel, struct vnode *vp,
173 		    struct label *vnodelabel);
174 
175 	/*
176 	 * Labeling event operations: IPC objects.
177 	 */
178 	void	(*mpo_create_mbuf_from_socket)(struct socket *so,
179 		    struct label *socketlabel, struct mbuf *m,
180 		    struct label *mbuflabel);
181 	void	(*mpo_create_socket)(struct ucred *cred, struct socket *so,
182 		    struct label *socketlabel);
183 	void	(*mpo_create_socket_from_socket)(struct socket *oldsocket,
184 		    struct label *oldsocketlabel, struct socket *newsocket,
185 		    struct label *newsocketlabel);
186 	void	(*mpo_relabel_socket)(struct ucred *cred, struct socket *so,
187 		    struct label *oldlabel, struct label *newlabel);
188 	void	(*mpo_relabel_pipe)(struct ucred *cred, struct pipe *pipe,
189 		    struct label *oldlabel, struct label *newlabel);
190 	void	(*mpo_set_socket_peer_from_mbuf)(struct mbuf *mbuf,
191 		    struct label *mbuflabel, struct socket *so,
192 		    struct label *socketpeerlabel);
193 	void	(*mpo_set_socket_peer_from_socket)(struct socket *oldsocket,
194 		    struct label *oldsocketlabel, struct socket *newsocket,
195 		    struct label *newsocketpeerlabel);
196 	void	(*mpo_create_pipe)(struct ucred *cred, struct pipe *pipe,
197 		    struct label *pipelabel);
198 
199 	/*
200 	 * Labeling event operations: network objects.
201 	 */
202 	void	(*mpo_create_bpfdesc)(struct ucred *cred, struct bpf_d *bpf_d,
203 		    struct label *bpflabel);
204 	void	(*mpo_create_ifnet)(struct ifnet *ifnet,
205 		    struct label *ifnetlabel);
206 	void	(*mpo_create_ipq)(struct mbuf *fragment,
207 		    struct label *fragmentlabel, struct ipq *ipq,
208 		    struct label *ipqlabel);
209 	void	(*mpo_create_datagram_from_ipq)
210 		    (struct ipq *ipq, struct label *ipqlabel,
211 		    struct mbuf *datagram, struct label *datagramlabel);
212 	void	(*mpo_create_fragment)(struct mbuf *datagram,
213 		    struct label *datagramlabel, struct mbuf *fragment,
214 		    struct label *fragmentlabel);
215 	void	(*mpo_create_mbuf_from_mbuf)(struct mbuf *oldmbuf,
216 		    struct label *oldlabel, struct mbuf *newmbuf,
217 		    struct label *newlabel);
218 	void	(*mpo_create_mbuf_linklayer)(struct ifnet *ifnet,
219 		    struct label *ifnetlabel, struct mbuf *mbuf,
220 		    struct label *mbuflabel);
221 	void	(*mpo_create_mbuf_from_bpfdesc)(struct bpf_d *bpf_d,
222 		    struct label *bpflabel, struct mbuf *mbuf,
223 		    struct label *mbuflabel);
224 	void	(*mpo_create_mbuf_from_ifnet)(struct ifnet *ifnet,
225 		    struct label *ifnetlabel, struct mbuf *mbuf,
226 		    struct label *mbuflabel);
227 	void	(*mpo_create_mbuf_multicast_encap)(struct mbuf *oldmbuf,
228 		    struct label *oldmbuflabel, struct ifnet *ifnet,
229 		    struct label *ifnetlabel, struct mbuf *newmbuf,
230 		    struct label *newmbuflabel);
231 	void	(*mpo_create_mbuf_netlayer)(struct mbuf *oldmbuf,
232 		    struct label *oldmbuflabel, struct mbuf *newmbuf,
233 		    struct label *newmbuflabel);
234 	int	(*mpo_fragment_match)(struct mbuf *fragment,
235 		    struct label *fragmentlabel, struct ipq *ipq,
236 		    struct label *ipqlabel);
237 	void	(*mpo_relabel_ifnet)(struct ucred *cred, struct ifnet *ifnet,
238 		    struct label *ifnetlabel, struct label *newlabel);
239 	void	(*mpo_update_ipq)(struct mbuf *fragment,
240 		    struct label *fragmentlabel, struct ipq *ipq,
241 		    struct label *ipqlabel);
242 
243 	/*
244 	 * Labeling event operations: processes.
245 	 */
246 	void	(*mpo_create_cred)(struct ucred *parent_cred,
247 		    struct ucred *child_cred);
248 	void	(*mpo_execve_transition)(struct ucred *old, struct ucred *new,
249 		    struct vnode *vp, struct label *vnodelabel,
250 		    struct label *interpvnodelabel,
251 		    struct image_params *imgp, struct label *execlabel);
252 	int	(*mpo_execve_will_transition)(struct ucred *old,
253 		    struct vnode *vp, struct label *vnodelabel,
254 		    struct label *interpvnodelabel,
255 		    struct image_params *imgp, struct label *execlabel);
256 	void	(*mpo_create_proc0)(struct ucred *cred);
257 	void	(*mpo_create_proc1)(struct ucred *cred);
258 	void	(*mpo_relabel_cred)(struct ucred *cred,
259 		    struct label *newlabel);
260 	void	(*mpo_thread_userret)(struct thread *thread);
261 
262 	/*
263 	 * Access control checks.
264 	 */
265 	int	(*mpo_check_bpfdesc_receive)(struct bpf_d *bpf_d,
266 		    struct label *bpflabel, struct ifnet *ifnet,
267 		    struct label *ifnetlabel);
268 	int	(*mpo_check_cred_relabel)(struct ucred *cred,
269 		    struct label *newlabel);
270 	int	(*mpo_check_cred_visible)(struct ucred *u1, struct ucred *u2);
271 	int	(*mpo_check_ifnet_relabel)(struct ucred *cred,
272 		    struct ifnet *ifnet, struct label *ifnetlabel,
273 		    struct label *newlabel);
274 	int	(*mpo_check_ifnet_transmit)(struct ifnet *ifnet,
275 		    struct label *ifnetlabel, struct mbuf *m,
276 		    struct label *mbuflabel);
277 	int	(*mpo_check_kenv_dump)(struct ucred *cred);
278 	int	(*mpo_check_kenv_get)(struct ucred *cred, char *name);
279 	int	(*mpo_check_kenv_set)(struct ucred *cred, char *name,
280 		    char *value);
281 	int	(*mpo_check_kenv_unset)(struct ucred *cred, char *name);
282 	int	(*mpo_check_kld_load)(struct ucred *cred, struct vnode *vp,
283 		    struct label *vlabel);
284 	int	(*mpo_check_kld_stat)(struct ucred *cred);
285 	int	(*mpo_check_kld_unload)(struct ucred *cred);
286 	int	(*mpo_check_mount_stat)(struct ucred *cred, struct mount *mp,
287 		    struct label *mntlabel);
288 	int	(*mpo_check_pipe_ioctl)(struct ucred *cred, struct pipe *pipe,
289 		    struct label *pipelabel, unsigned long cmd, void *data);
290 	int	(*mpo_check_pipe_poll)(struct ucred *cred, struct pipe *pipe,
291 		    struct label *pipelabel);
292 	int	(*mpo_check_pipe_read)(struct ucred *cred, struct pipe *pipe,
293 		    struct label *pipelabel);
294 	int	(*mpo_check_pipe_relabel)(struct ucred *cred,
295 		    struct pipe *pipe, struct label *pipelabel,
296 		    struct label *newlabel);
297 	int	(*mpo_check_pipe_stat)(struct ucred *cred, struct pipe *pipe,
298 		    struct label *pipelabel);
299 	int	(*mpo_check_pipe_write)(struct ucred *cred, struct pipe *pipe,
300 		    struct label *pipelabel);
301 	int	(*mpo_check_proc_debug)(struct ucred *cred,
302 		    struct proc *proc);
303 	int	(*mpo_check_proc_sched)(struct ucred *cred,
304 		    struct proc *proc);
305 	int	(*mpo_check_proc_signal)(struct ucred *cred,
306 		    struct proc *proc, int signum);
307 	int	(*mpo_check_socket_bind)(struct ucred *cred,
308 		    struct socket *so, struct label *socketlabel,
309 		    struct sockaddr *sockaddr);
310 	int	(*mpo_check_socket_connect)(struct ucred *cred,
311 		    struct socket *so, struct label *socketlabel,
312 		    struct sockaddr *sockaddr);
313 	int	(*mpo_check_socket_deliver)(struct socket *so,
314 		    struct label *socketlabel, struct mbuf *m,
315 		    struct label *mbuflabel);
316 	int	(*mpo_check_socket_listen)(struct ucred *cred,
317 		    struct socket *so, struct label *socketlabel);
318 	int	(*mpo_check_socket_receive)(struct ucred *cred,
319 		    struct socket *so, struct label *socketlabel);
320 	int	(*mpo_check_socket_relabel)(struct ucred *cred,
321 		    struct socket *so, struct label *socketlabel,
322 		    struct label *newlabel);
323 	int	(*mpo_check_socket_send)(struct ucred *cred,
324 		    struct socket *so, struct label *socketlabel);
325 	int	(*mpo_check_socket_visible)(struct ucred *cred,
326 		    struct socket *so, struct label *socketlabel);
327 	int	(*mpo_check_sysarch_ioperm)(struct ucred *cred);
328 	int	(*mpo_check_system_acct)(struct ucred *cred,
329 		    struct vnode *vp, struct label *vlabel);
330 	int	(*mpo_check_system_nfsd)(struct ucred *cred);
331 	int	(*mpo_check_system_reboot)(struct ucred *cred, int howto);
332 	int	(*mpo_check_system_settime)(struct ucred *cred);
333 	int	(*mpo_check_system_swapon)(struct ucred *cred,
334 		    struct vnode *vp, struct label *label);
335 	int	(*mpo_check_system_swapoff)(struct ucred *cred,
336 		    struct vnode *vp, struct label *label);
337 	int	(*mpo_check_system_sysctl)(struct ucred *cred, int *name,
338 		    u_int namelen, void *old, size_t *oldlenp, int inkernel,
339 		    void *new, size_t newlen);
340 	int	(*mpo_check_vnode_access)(struct ucred *cred,
341 		    struct vnode *vp, struct label *label, int acc_mode);
342 	int	(*mpo_check_vnode_chdir)(struct ucred *cred,
343 		    struct vnode *dvp, struct label *dlabel);
344 	int	(*mpo_check_vnode_chroot)(struct ucred *cred,
345 		    struct vnode *dvp, struct label *dlabel);
346 	int	(*mpo_check_vnode_create)(struct ucred *cred,
347 		    struct vnode *dvp, struct label *dlabel,
348 		    struct componentname *cnp, struct vattr *vap);
349 	int	(*mpo_check_vnode_delete)(struct ucred *cred,
350 		    struct vnode *dvp, struct label *dlabel,
351 		    struct vnode *vp, struct label *label,
352 		    struct componentname *cnp);
353 	int	(*mpo_check_vnode_deleteacl)(struct ucred *cred,
354 		    struct vnode *vp, struct label *label, acl_type_t type);
355 	int	(*mpo_check_vnode_exec)(struct ucred *cred, struct vnode *vp,
356 		    struct label *label, struct image_params *imgp,
357 		    struct label *execlabel);
358 	int	(*mpo_check_vnode_getacl)(struct ucred *cred,
359 		    struct vnode *vp, struct label *label, acl_type_t type);
360 	int	(*mpo_check_vnode_getextattr)(struct ucred *cred,
361 		    struct vnode *vp, struct label *label, int attrnamespace,
362 		    const char *name, struct uio *uio);
363 	int	(*mpo_check_vnode_link)(struct ucred *cred, struct vnode *dvp,
364 		    struct label *dlabel, struct vnode *vp,
365 		    struct label *label, struct componentname *cnp);
366 	int	(*mpo_check_vnode_lookup)(struct ucred *cred,
367 		    struct vnode *dvp, struct label *dlabel,
368 		    struct componentname *cnp);
369 	int	(*mpo_check_vnode_mmap)(struct ucred *cred, struct vnode *vp,
370 		    struct label *label, int prot);
371 	void	(*mpo_check_vnode_mmap_downgrade)(struct ucred *cred,
372 		    struct vnode *vp, struct label *label, int *prot);
373 	int	(*mpo_check_vnode_mprotect)(struct ucred *cred,
374 		    struct vnode *vp, struct label *label, int prot);
375 	int	(*mpo_check_vnode_open)(struct ucred *cred, struct vnode *vp,
376 		    struct label *label, int acc_mode);
377 	int	(*mpo_check_vnode_poll)(struct ucred *active_cred,
378 		    struct ucred *file_cred, struct vnode *vp,
379 		    struct label *label);
380 	int	(*mpo_check_vnode_read)(struct ucred *active_cred,
381 		    struct ucred *file_cred, struct vnode *vp,
382 		    struct label *label);
383 	int	(*mpo_check_vnode_readdir)(struct ucred *cred,
384 		    struct vnode *dvp, struct label *dlabel);
385 	int	(*mpo_check_vnode_readlink)(struct ucred *cred,
386 		    struct vnode *vp, struct label *label);
387 	int	(*mpo_check_vnode_relabel)(struct ucred *cred,
388 		    struct vnode *vp, struct label *vnodelabel,
389 		    struct label *newlabel);
390 	int	(*mpo_check_vnode_rename_from)(struct ucred *cred,
391 		    struct vnode *dvp, struct label *dlabel, struct vnode *vp,
392 		    struct label *label, struct componentname *cnp);
393 	int	(*mpo_check_vnode_rename_to)(struct ucred *cred,
394 		    struct vnode *dvp, struct label *dlabel, struct vnode *vp,
395 		    struct label *label, int samedir,
396 		    struct componentname *cnp);
397 	int	(*mpo_check_vnode_revoke)(struct ucred *cred,
398 		    struct vnode *vp, struct label *label);
399 	int	(*mpo_check_vnode_setacl)(struct ucred *cred,
400 		    struct vnode *vp, struct label *label, acl_type_t type,
401 		    struct acl *acl);
402 	int	(*mpo_check_vnode_setextattr)(struct ucred *cred,
403 		    struct vnode *vp, struct label *label, int attrnamespace,
404 		    const char *name, struct uio *uio);
405 	int	(*mpo_check_vnode_setflags)(struct ucred *cred,
406 		    struct vnode *vp, struct label *label, u_long flags);
407 	int	(*mpo_check_vnode_setmode)(struct ucred *cred,
408 		    struct vnode *vp, struct label *label, mode_t mode);
409 	int	(*mpo_check_vnode_setowner)(struct ucred *cred,
410 		    struct vnode *vp, struct label *label, uid_t uid,
411 		    gid_t gid);
412 	int	(*mpo_check_vnode_setutimes)(struct ucred *cred,
413 		    struct vnode *vp, struct label *label,
414 		    struct timespec atime, struct timespec mtime);
415 	int	(*mpo_check_vnode_stat)(struct ucred *active_cred,
416 		    struct ucred *file_cred, struct vnode *vp,
417 		    struct label *label);
418 	int	(*mpo_check_vnode_write)(struct ucred *active_cred,
419 		    struct ucred *file_cred, struct vnode *vp,
420 		    struct label *label);
421 };
422 
423 struct mac_policy_conf {
424 	char				*mpc_name;	/* policy name */
425 	char				*mpc_fullname;	/* policy full name */
426 	struct mac_policy_ops		*mpc_ops;	/* policy operations */
427 	int				 mpc_loadtime_flags;	/* flags */
428 	int				*mpc_field_off; /* security field */
429 	int				 mpc_runtime_flags; /* flags */
430 	LIST_ENTRY(mac_policy_conf)	 mpc_list;	/* global list */
431 };
432 
433 /* Flags for the mpc_loadtime_flags field. */
434 #define	MPC_LOADTIME_FLAG_NOTLATE	0x00000001
435 #define	MPC_LOADTIME_FLAG_UNLOADOK	0x00000002
436 #define	MPC_LOADTIME_FLAG_LABELMBUFS	0x00000004
437 
438 /* Flags for the mpc_runtime_flags field. */
439 #define	MPC_RUNTIME_FLAG_REGISTERED	0x00000001
440 
441 #define	MAC_POLICY_SET(mpops, mpname, mpfullname, mpflags, privdata_wanted) \
442 	static struct mac_policy_conf mpname##_mac_policy_conf = {	\
443 		#mpname,						\
444 		mpfullname,						\
445 		mpops,							\
446 		mpflags,						\
447 		privdata_wanted,					\
448 		0,							\
449 	};								\
450 	static moduledata_t mpname##_mod = {				\
451 		#mpname,						\
452 		mac_policy_modevent,					\
453 		&mpname##_mac_policy_conf				\
454 	};								\
455 	MODULE_DEPEND(mpname, kernel_mac_support, 1, 1, 1);		\
456 	DECLARE_MODULE(mpname, mpname##_mod, SI_SUB_MAC_POLICY,		\
457 	    SI_ORDER_MIDDLE)
458 
459 int	mac_policy_modevent(module_t mod, int type, void *data);
460 
461 #define	LABEL_TO_SLOT(l, s)	(l)->l_perpolicy[s]
462 
463 #endif /* !_SYS_MAC_POLICY_H */
464