mac_policy.h revision 111939
1/*-
2 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3 * Copyright (c) 2001, 2002 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: head/sys/security/mac/mac_policy.h 111939 2003-03-06 04:47:47Z rwatson $
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 */
54struct mac_policy_conf;
55struct 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	void	(*mpo_init_ipq_label)(struct label *label);
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_pipe_label)(struct label *src,
99		    struct label *dest);
100	void	(*mpo_copy_vnode_label)(struct label *src,
101		    struct label *dest);
102	int	(*mpo_externalize_cred_label)(struct label *label,
103		    char *element_name, char *buffer, size_t buflen,
104		    size_t *len, int *claimed);
105	int	(*mpo_externalize_ifnet_label)(struct label *label,
106		    char *element_name, char *buffer, size_t buflen,
107		    size_t *len, int *claimed);
108	int	(*mpo_externalize_pipe_label)(struct label *label,
109		    char *element_name, char *buffer, size_t buflen,
110		    size_t *len, int *claimed);
111	int	(*mpo_externalize_socket_label)(struct label *label,
112		    char *element_name, char *buffer, size_t buflen,
113		    size_t *len, int *claimed);
114	int	(*mpo_externalize_socket_peer_label)(struct label *label,
115		    char *element_name, char *buffer, size_t buflen,
116		    size_t *len, int *claimed);
117	int	(*mpo_externalize_vnode_label)(struct label *label,
118		    char *element_name, char *buffer, size_t buflen,
119		    size_t *len, int *claimed);
120	int	(*mpo_internalize_cred_label)(struct label *label,
121		    char *element_name, char *element_data, int *claimed);
122	int	(*mpo_internalize_ifnet_label)(struct label *label,
123		    char *element_name, char *element_data, int *claimed);
124	int	(*mpo_internalize_pipe_label)(struct label *label,
125		    char *element_name, char *element_data, int *claimed);
126	int	(*mpo_internalize_socket_label)(struct label *label,
127		    char *element_name, char *element_data, int *claimed);
128	int	(*mpo_internalize_vnode_label)(struct label *label,
129		    char *element_name, char *element_data, int *claimed);
130
131	/*
132	 * Labeling event operations: file system objects, and things that
133	 * look a lot like file system objects.
134	 */
135	void	(*mpo_associate_vnode_devfs)(struct mount *mp,
136		    struct label *fslabel, struct devfs_dirent *de,
137		    struct label *delabel, struct vnode *vp,
138		    struct label *vlabel);
139	int	(*mpo_associate_vnode_extattr)(struct mount *mp,
140		    struct label *fslabel, struct vnode *vp,
141		    struct label *vlabel);
142	void	(*mpo_associate_vnode_singlelabel)(struct mount *mp,
143		    struct label *fslabel, struct vnode *vp,
144		    struct label *vlabel);
145	void	(*mpo_create_devfs_device)(struct mount *mp, dev_t dev,
146		    struct devfs_dirent *de, struct label *label);
147	void	(*mpo_create_devfs_directory)(struct mount *mp, char *dirname,
148		    int dirnamelen, struct devfs_dirent *de,
149		    struct label *label);
150	void	(*mpo_create_devfs_symlink)(struct ucred *cred,
151		    struct mount *mp, struct devfs_dirent *dd,
152		    struct label *ddlabel, struct devfs_dirent *de,
153		    struct label *delabel);
154	int	(*mpo_create_vnode_extattr)(struct ucred *cred,
155		    struct mount *mp, struct label *fslabel,
156		    struct vnode *dvp, struct label *dlabel,
157		    struct vnode *vp, struct label *vlabel,
158		    struct componentname *cnp);
159	void	(*mpo_create_mount)(struct ucred *cred, struct mount *mp,
160		    struct label *mntlabel, struct label *fslabel);
161	void	(*mpo_create_root_mount)(struct ucred *cred, struct mount *mp,
162		    struct label *mountlabel, struct label *fslabel);
163	void	(*mpo_relabel_vnode)(struct ucred *cred, struct vnode *vp,
164		    struct label *vnodelabel, struct label *label);
165	int	(*mpo_setlabel_vnode_extattr)(struct ucred *cred,
166		    struct vnode *vp, struct label *vlabel,
167		    struct label *intlabel);
168	void	(*mpo_update_devfsdirent)(struct mount *mp,
169		    struct devfs_dirent *devfs_dirent,
170		    struct label *direntlabel, struct vnode *vp,
171		    struct label *vnodelabel);
172
173	/*
174	 * Labeling event operations: IPC objects.
175	 */
176	void	(*mpo_create_mbuf_from_socket)(struct socket *so,
177		    struct label *socketlabel, struct mbuf *m,
178		    struct label *mbuflabel);
179	void	(*mpo_create_socket)(struct ucred *cred, struct socket *so,
180		    struct label *socketlabel);
181	void	(*mpo_create_socket_from_socket)(struct socket *oldsocket,
182		    struct label *oldsocketlabel, struct socket *newsocket,
183		    struct label *newsocketlabel);
184	void	(*mpo_relabel_socket)(struct ucred *cred, struct socket *so,
185		    struct label *oldlabel, struct label *newlabel);
186	void	(*mpo_relabel_pipe)(struct ucred *cred, struct pipe *pipe,
187		    struct label *oldlabel, struct label *newlabel);
188	void	(*mpo_set_socket_peer_from_mbuf)(struct mbuf *mbuf,
189		    struct label *mbuflabel, struct socket *so,
190		    struct label *socketpeerlabel);
191	void	(*mpo_set_socket_peer_from_socket)(struct socket *oldsocket,
192		    struct label *oldsocketlabel, struct socket *newsocket,
193		    struct label *newsocketpeerlabel);
194	void	(*mpo_create_pipe)(struct ucred *cred, struct pipe *pipe,
195		    struct label *pipelabel);
196
197	/*
198	 * Labeling event operations: network objects.
199	 */
200	void	(*mpo_create_bpfdesc)(struct ucred *cred, struct bpf_d *bpf_d,
201		    struct label *bpflabel);
202	void	(*mpo_create_ifnet)(struct ifnet *ifnet,
203		    struct label *ifnetlabel);
204	void	(*mpo_create_ipq)(struct mbuf *fragment,
205		    struct label *fragmentlabel, struct ipq *ipq,
206		    struct label *ipqlabel);
207	void	(*mpo_create_datagram_from_ipq)
208		    (struct ipq *ipq, struct label *ipqlabel,
209		    struct mbuf *datagram, struct label *datagramlabel);
210	void	(*mpo_create_fragment)(struct mbuf *datagram,
211		    struct label *datagramlabel, struct mbuf *fragment,
212		    struct label *fragmentlabel);
213	void	(*mpo_create_mbuf_from_mbuf)(struct mbuf *oldmbuf,
214		    struct label *oldlabel, struct mbuf *newmbuf,
215		    struct label *newlabel);
216	void	(*mpo_create_mbuf_linklayer)(struct ifnet *ifnet,
217		    struct label *ifnetlabel, struct mbuf *mbuf,
218		    struct label *mbuflabel);
219	void	(*mpo_create_mbuf_from_bpfdesc)(struct bpf_d *bpf_d,
220		    struct label *bpflabel, struct mbuf *mbuf,
221		    struct label *mbuflabel);
222	void	(*mpo_create_mbuf_from_ifnet)(struct ifnet *ifnet,
223		    struct label *ifnetlabel, struct mbuf *mbuf,
224		    struct label *mbuflabel);
225	void	(*mpo_create_mbuf_multicast_encap)(struct mbuf *oldmbuf,
226		    struct label *oldmbuflabel, struct ifnet *ifnet,
227		    struct label *ifnetlabel, struct mbuf *newmbuf,
228		    struct label *newmbuflabel);
229	void	(*mpo_create_mbuf_netlayer)(struct mbuf *oldmbuf,
230		    struct label *oldmbuflabel, struct mbuf *newmbuf,
231		    struct label *newmbuflabel);
232	int	(*mpo_fragment_match)(struct mbuf *fragment,
233		    struct label *fragmentlabel, struct ipq *ipq,
234		    struct label *ipqlabel);
235	void	(*mpo_relabel_ifnet)(struct ucred *cred, struct ifnet *ifnet,
236		    struct label *ifnetlabel, struct label *newlabel);
237	void	(*mpo_update_ipq)(struct mbuf *fragment,
238		    struct label *fragmentlabel, struct ipq *ipq,
239		    struct label *ipqlabel);
240
241	/*
242	 * Labeling event operations: processes.
243	 */
244	void	(*mpo_create_cred)(struct ucred *parent_cred,
245		    struct ucred *child_cred);
246	void	(*mpo_execve_transition)(struct ucred *old, struct ucred *new,
247		    struct vnode *vp, struct label *vnodelabel,
248		    struct label *interpvnodelabel,
249		    struct image_params *imgp, struct label *execlabel);
250	int	(*mpo_execve_will_transition)(struct ucred *old,
251		    struct vnode *vp, struct label *vnodelabel,
252		    struct label *interpvnodelabel,
253		    struct image_params *imgp, struct label *execlabel);
254	void	(*mpo_create_proc0)(struct ucred *cred);
255	void	(*mpo_create_proc1)(struct ucred *cred);
256	void	(*mpo_relabel_cred)(struct ucred *cred,
257		    struct label *newlabel);
258	void	(*mpo_thread_userret)(struct thread *thread);
259
260	/*
261	 * Access control checks.
262	 */
263	int	(*mpo_check_bpfdesc_receive)(struct bpf_d *bpf_d,
264		    struct label *bpflabel, struct ifnet *ifnet,
265		    struct label *ifnetlabel);
266	int	(*mpo_check_cred_relabel)(struct ucred *cred,
267		    struct label *newlabel);
268	int	(*mpo_check_cred_visible)(struct ucred *u1, struct ucred *u2);
269	int	(*mpo_check_ifnet_relabel)(struct ucred *cred,
270		    struct ifnet *ifnet, struct label *ifnetlabel,
271		    struct label *newlabel);
272	int	(*mpo_check_ifnet_transmit)(struct ifnet *ifnet,
273		    struct label *ifnetlabel, struct mbuf *m,
274		    struct label *mbuflabel);
275	int	(*mpo_check_kenv_dump)(struct ucred *cred);
276	int	(*mpo_check_kenv_get)(struct ucred *cred, char *name);
277	int	(*mpo_check_kenv_set)(struct ucred *cred, char *name,
278		    char *value);
279	int	(*mpo_check_kenv_unset)(struct ucred *cred, char *name);
280	int	(*mpo_check_kld_load)(struct ucred *cred, struct vnode *vp,
281		    struct label *vlabel);
282	int	(*mpo_check_kld_stat)(struct ucred *cred);
283	int	(*mpo_check_kld_unload)(struct ucred *cred);
284	int	(*mpo_check_mount_stat)(struct ucred *cred, struct mount *mp,
285		    struct label *mntlabel);
286	int	(*mpo_check_pipe_ioctl)(struct ucred *cred, struct pipe *pipe,
287		    struct label *pipelabel, unsigned long cmd, void *data);
288	int	(*mpo_check_pipe_poll)(struct ucred *cred, struct pipe *pipe,
289		    struct label *pipelabel);
290	int	(*mpo_check_pipe_read)(struct ucred *cred, struct pipe *pipe,
291		    struct label *pipelabel);
292	int	(*mpo_check_pipe_relabel)(struct ucred *cred,
293		    struct pipe *pipe, struct label *pipelabel,
294		    struct label *newlabel);
295	int	(*mpo_check_pipe_stat)(struct ucred *cred, struct pipe *pipe,
296		    struct label *pipelabel);
297	int	(*mpo_check_pipe_write)(struct ucred *cred, struct pipe *pipe,
298		    struct label *pipelabel);
299	int	(*mpo_check_proc_debug)(struct ucred *cred,
300		    struct proc *proc);
301	int	(*mpo_check_proc_sched)(struct ucred *cred,
302		    struct proc *proc);
303	int	(*mpo_check_proc_signal)(struct ucred *cred,
304		    struct proc *proc, int signum);
305	int	(*mpo_check_socket_bind)(struct ucred *cred,
306		    struct socket *so, struct label *socketlabel,
307		    struct sockaddr *sockaddr);
308	int	(*mpo_check_socket_connect)(struct ucred *cred,
309		    struct socket *so, struct label *socketlabel,
310		    struct sockaddr *sockaddr);
311	int	(*mpo_check_socket_deliver)(struct socket *so,
312		    struct label *socketlabel, struct mbuf *m,
313		    struct label *mbuflabel);
314	int	(*mpo_check_socket_listen)(struct ucred *cred,
315		    struct socket *so, struct label *socketlabel);
316	int	(*mpo_check_socket_receive)(struct ucred *cred,
317		    struct socket *so, struct label *socketlabel);
318	int	(*mpo_check_socket_relabel)(struct ucred *cred,
319		    struct socket *so, struct label *socketlabel,
320		    struct label *newlabel);
321	int	(*mpo_check_socket_send)(struct ucred *cred,
322		    struct socket *so, struct label *socketlabel);
323	int	(*mpo_check_socket_visible)(struct ucred *cred,
324		    struct socket *so, struct label *socketlabel);
325	int	(*mpo_check_sysarch_ioperm)(struct ucred *cred);
326	int	(*mpo_check_system_acct)(struct ucred *cred,
327		    struct vnode *vp, struct label *vlabel);
328	int	(*mpo_check_system_nfsd)(struct ucred *cred);
329	int	(*mpo_check_system_reboot)(struct ucred *cred, int howto);
330	int	(*mpo_check_system_settime)(struct ucred *cred);
331	int	(*mpo_check_system_swapon)(struct ucred *cred,
332		    struct vnode *vp, struct label *label);
333	int	(*mpo_check_system_swapoff)(struct ucred *cred,
334		    struct vnode *vp, struct label *label);
335	int	(*mpo_check_system_sysctl)(struct ucred *cred, int *name,
336		    u_int namelen, void *old, size_t *oldlenp, int inkernel,
337		    void *new, size_t newlen);
338	int	(*mpo_check_vnode_access)(struct ucred *cred,
339		    struct vnode *vp, struct label *label, int acc_mode);
340	int	(*mpo_check_vnode_chdir)(struct ucred *cred,
341		    struct vnode *dvp, struct label *dlabel);
342	int	(*mpo_check_vnode_chroot)(struct ucred *cred,
343		    struct vnode *dvp, struct label *dlabel);
344	int	(*mpo_check_vnode_create)(struct ucred *cred,
345		    struct vnode *dvp, struct label *dlabel,
346		    struct componentname *cnp, struct vattr *vap);
347	int	(*mpo_check_vnode_delete)(struct ucred *cred,
348		    struct vnode *dvp, struct label *dlabel,
349		    struct vnode *vp, struct label *label,
350		    struct componentname *cnp);
351	int	(*mpo_check_vnode_deleteacl)(struct ucred *cred,
352		    struct vnode *vp, struct label *label, acl_type_t type);
353	int	(*mpo_check_vnode_exec)(struct ucred *cred, struct vnode *vp,
354		    struct label *label, struct image_params *imgp,
355		    struct label *execlabel);
356	int	(*mpo_check_vnode_getacl)(struct ucred *cred,
357		    struct vnode *vp, struct label *label, acl_type_t type);
358	int	(*mpo_check_vnode_getextattr)(struct ucred *cred,
359		    struct vnode *vp, struct label *label, int attrnamespace,
360		    const char *name, struct uio *uio);
361	int	(*mpo_check_vnode_link)(struct ucred *cred, struct vnode *dvp,
362		    struct label *dlabel, struct vnode *vp,
363		    struct label *label, struct componentname *cnp);
364	int	(*mpo_check_vnode_lookup)(struct ucred *cred,
365		    struct vnode *dvp, struct label *dlabel,
366		    struct componentname *cnp);
367	int	(*mpo_check_vnode_mmap)(struct ucred *cred, struct vnode *vp,
368		    struct label *label, int prot);
369	void	(*mpo_check_vnode_mmap_downgrade)(struct ucred *cred,
370		    struct vnode *vp, struct label *label, int *prot);
371	int	(*mpo_check_vnode_mprotect)(struct ucred *cred,
372		    struct vnode *vp, struct label *label, int prot);
373	int	(*mpo_check_vnode_open)(struct ucred *cred, struct vnode *vp,
374		    struct label *label, int acc_mode);
375	int	(*mpo_check_vnode_poll)(struct ucred *active_cred,
376		    struct ucred *file_cred, struct vnode *vp,
377		    struct label *label);
378	int	(*mpo_check_vnode_read)(struct ucred *active_cred,
379		    struct ucred *file_cred, struct vnode *vp,
380		    struct label *label);
381	int	(*mpo_check_vnode_readdir)(struct ucred *cred,
382		    struct vnode *dvp, struct label *dlabel);
383	int	(*mpo_check_vnode_readlink)(struct ucred *cred,
384		    struct vnode *vp, struct label *label);
385	int	(*mpo_check_vnode_relabel)(struct ucred *cred,
386		    struct vnode *vp, struct label *vnodelabel,
387		    struct label *newlabel);
388	int	(*mpo_check_vnode_rename_from)(struct ucred *cred,
389		    struct vnode *dvp, struct label *dlabel, struct vnode *vp,
390		    struct label *label, struct componentname *cnp);
391	int	(*mpo_check_vnode_rename_to)(struct ucred *cred,
392		    struct vnode *dvp, struct label *dlabel, struct vnode *vp,
393		    struct label *label, int samedir,
394		    struct componentname *cnp);
395	int	(*mpo_check_vnode_revoke)(struct ucred *cred,
396		    struct vnode *vp, struct label *label);
397	int	(*mpo_check_vnode_setacl)(struct ucred *cred,
398		    struct vnode *vp, struct label *label, acl_type_t type,
399		    struct acl *acl);
400	int	(*mpo_check_vnode_setextattr)(struct ucred *cred,
401		    struct vnode *vp, struct label *label, int attrnamespace,
402		    const char *name, struct uio *uio);
403	int	(*mpo_check_vnode_setflags)(struct ucred *cred,
404		    struct vnode *vp, struct label *label, u_long flags);
405	int	(*mpo_check_vnode_setmode)(struct ucred *cred,
406		    struct vnode *vp, struct label *label, mode_t mode);
407	int	(*mpo_check_vnode_setowner)(struct ucred *cred,
408		    struct vnode *vp, struct label *label, uid_t uid,
409		    gid_t gid);
410	int	(*mpo_check_vnode_setutimes)(struct ucred *cred,
411		    struct vnode *vp, struct label *label,
412		    struct timespec atime, struct timespec mtime);
413	int	(*mpo_check_vnode_stat)(struct ucred *active_cred,
414		    struct ucred *file_cred, struct vnode *vp,
415		    struct label *label);
416	int	(*mpo_check_vnode_write)(struct ucred *active_cred,
417		    struct ucred *file_cred, struct vnode *vp,
418		    struct label *label);
419};
420
421struct mac_policy_conf {
422	char				*mpc_name;	/* policy name */
423	char				*mpc_fullname;	/* policy full name */
424	struct mac_policy_ops		*mpc_ops;	/* policy operations */
425	int				 mpc_loadtime_flags;	/* flags */
426	int				*mpc_field_off; /* security field */
427	int				 mpc_runtime_flags; /* flags */
428	LIST_ENTRY(mac_policy_conf)	 mpc_list;	/* global list */
429};
430
431/* Flags for the mpc_loadtime_flags field. */
432#define	MPC_LOADTIME_FLAG_NOTLATE	0x00000001
433#define	MPC_LOADTIME_FLAG_UNLOADOK	0x00000002
434
435/* Flags for the mpc_runtime_flags field. */
436#define	MPC_RUNTIME_FLAG_REGISTERED	0x00000001
437
438#define	MAC_POLICY_SET(mpops, mpname, mpfullname, mpflags, privdata_wanted) \
439	static struct mac_policy_conf mpname##_mac_policy_conf = {	\
440		#mpname,						\
441		mpfullname,						\
442		mpops,							\
443		mpflags,						\
444		privdata_wanted,					\
445		0,							\
446	};								\
447	static moduledata_t mpname##_mod = {				\
448		#mpname,						\
449		mac_policy_modevent,					\
450		&mpname##_mac_policy_conf				\
451	};								\
452	MODULE_DEPEND(mpname, kernel_mac_support, 1, 1, 1);		\
453	DECLARE_MODULE(mpname, mpname##_mod, SI_SUB_MAC_POLICY,		\
454	    SI_ORDER_MIDDLE)
455
456int	mac_policy_modevent(module_t mod, int type, void *data);
457
458#define	LABEL_TO_SLOT(l, s)	(l)->l_perpolicy[s]
459
460#endif /* !_SYS_MAC_POLICY_H */
461