Deleted Added
full compact
mac_policy.h (122820) mac_policy.h (122875)
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 *
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: head/sys/security/mac/mac_policy.h 122820 2003-11-16 23:31:45Z rwatson $
34 * $FreeBSD: head/sys/security/mac/mac_policy.h 122875 2003-11-18 00:39:07Z 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 acl;
55struct componentname;
56struct devfs_dirent;
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 acl;
55struct componentname;
56struct devfs_dirent;
57struct inpcb;
57struct ipq;
58struct label;
59struct mac_policy_conf;
60struct mbuf;
61struct mount;
62struct pipe;
63struct sbuf;
64struct socket;
65struct ucred;
66struct uio;
67struct vnode;
68struct mac_policy_ops {
69 /*
70 * Policy module operations.
71 */
72 void (*mpo_destroy)(struct mac_policy_conf *mpc);
73 void (*mpo_init)(struct mac_policy_conf *mpc);
74
75 /*
76 * General policy-directed security system call so that policies
77 * may implement new services without reserving explicit
78 * system call numbers.
79 */
80 int (*mpo_syscall)(struct thread *td, int call, void *arg);
81
82 /*
83 * Label operations.
84 */
85 void (*mpo_init_bpfdesc_label)(struct label *label);
86 void (*mpo_init_cred_label)(struct label *label);
87 void (*mpo_init_devfsdirent_label)(struct label *label);
88 void (*mpo_init_ifnet_label)(struct label *label);
58struct ipq;
59struct label;
60struct mac_policy_conf;
61struct mbuf;
62struct mount;
63struct pipe;
64struct sbuf;
65struct socket;
66struct ucred;
67struct uio;
68struct vnode;
69struct mac_policy_ops {
70 /*
71 * Policy module operations.
72 */
73 void (*mpo_destroy)(struct mac_policy_conf *mpc);
74 void (*mpo_init)(struct mac_policy_conf *mpc);
75
76 /*
77 * General policy-directed security system call so that policies
78 * may implement new services without reserving explicit
79 * system call numbers.
80 */
81 int (*mpo_syscall)(struct thread *td, int call, void *arg);
82
83 /*
84 * Label operations.
85 */
86 void (*mpo_init_bpfdesc_label)(struct label *label);
87 void (*mpo_init_cred_label)(struct label *label);
88 void (*mpo_init_devfsdirent_label)(struct label *label);
89 void (*mpo_init_ifnet_label)(struct label *label);
90 int (*mpo_init_inpcb_label)(struct label *label, int flag);
89 int (*mpo_init_ipq_label)(struct label *label, int flag);
90 int (*mpo_init_mbuf_label)(struct label *label, int flag);
91 void (*mpo_init_mount_label)(struct label *label);
92 void (*mpo_init_mount_fs_label)(struct label *label);
93 int (*mpo_init_socket_label)(struct label *label, int flag);
94 int (*mpo_init_socket_peer_label)(struct label *label, int flag);
95 void (*mpo_init_pipe_label)(struct label *label);
96 void (*mpo_init_proc_label)(struct label *label);
97 void (*mpo_init_vnode_label)(struct label *label);
98 void (*mpo_destroy_bpfdesc_label)(struct label *label);
99 void (*mpo_destroy_cred_label)(struct label *label);
100 void (*mpo_destroy_devfsdirent_label)(struct label *label);
101 void (*mpo_destroy_ifnet_label)(struct label *label);
91 int (*mpo_init_ipq_label)(struct label *label, int flag);
92 int (*mpo_init_mbuf_label)(struct label *label, int flag);
93 void (*mpo_init_mount_label)(struct label *label);
94 void (*mpo_init_mount_fs_label)(struct label *label);
95 int (*mpo_init_socket_label)(struct label *label, int flag);
96 int (*mpo_init_socket_peer_label)(struct label *label, int flag);
97 void (*mpo_init_pipe_label)(struct label *label);
98 void (*mpo_init_proc_label)(struct label *label);
99 void (*mpo_init_vnode_label)(struct label *label);
100 void (*mpo_destroy_bpfdesc_label)(struct label *label);
101 void (*mpo_destroy_cred_label)(struct label *label);
102 void (*mpo_destroy_devfsdirent_label)(struct label *label);
103 void (*mpo_destroy_ifnet_label)(struct label *label);
104 void (*mpo_destroy_inpcb_label)(struct label *label);
102 void (*mpo_destroy_ipq_label)(struct label *label);
103 void (*mpo_destroy_mbuf_label)(struct label *label);
104 void (*mpo_destroy_mount_label)(struct label *label);
105 void (*mpo_destroy_mount_fs_label)(struct label *label);
106 void (*mpo_destroy_socket_label)(struct label *label);
107 void (*mpo_destroy_socket_peer_label)(struct label *label);
108 void (*mpo_destroy_pipe_label)(struct label *label);
109 void (*mpo_destroy_proc_label)(struct label *label);
110 void (*mpo_destroy_vnode_label)(struct label *label);
111 void (*mpo_copy_mbuf_label)(struct label *src,
112 struct label *dest);
113 void (*mpo_copy_pipe_label)(struct label *src,
114 struct label *dest);
115 void (*mpo_copy_socket_label)(struct label *src,
116 struct label *dest);
117 void (*mpo_copy_vnode_label)(struct label *src,
118 struct label *dest);
119 int (*mpo_externalize_cred_label)(struct label *label,
120 char *element_name, struct sbuf *sb, int *claimed);
121 int (*mpo_externalize_ifnet_label)(struct label *label,
122 char *element_name, struct sbuf *sb, int *claimed);
123 int (*mpo_externalize_pipe_label)(struct label *label,
124 char *element_name, struct sbuf *sb, int *claimed);
125 int (*mpo_externalize_socket_label)(struct label *label,
126 char *element_name, struct sbuf *sb, int *claimed);
127 int (*mpo_externalize_socket_peer_label)(struct label *label,
128 char *element_name, struct sbuf *sb, int *claimed);
129 int (*mpo_externalize_vnode_label)(struct label *label,
130 char *element_name, struct sbuf *sb, int *claimed);
131 int (*mpo_internalize_cred_label)(struct label *label,
132 char *element_name, char *element_data, int *claimed);
133 int (*mpo_internalize_ifnet_label)(struct label *label,
134 char *element_name, char *element_data, int *claimed);
135 int (*mpo_internalize_pipe_label)(struct label *label,
136 char *element_name, char *element_data, int *claimed);
137 int (*mpo_internalize_socket_label)(struct label *label,
138 char *element_name, char *element_data, int *claimed);
139 int (*mpo_internalize_vnode_label)(struct label *label,
140 char *element_name, char *element_data, int *claimed);
141
142 /*
143 * Labeling event operations: file system objects, and things that
144 * look a lot like file system objects.
145 */
146 void (*mpo_associate_vnode_devfs)(struct mount *mp,
147 struct label *fslabel, struct devfs_dirent *de,
148 struct label *delabel, struct vnode *vp,
149 struct label *vlabel);
150 int (*mpo_associate_vnode_extattr)(struct mount *mp,
151 struct label *fslabel, struct vnode *vp,
152 struct label *vlabel);
153 void (*mpo_associate_vnode_singlelabel)(struct mount *mp,
154 struct label *fslabel, struct vnode *vp,
155 struct label *vlabel);
156 void (*mpo_create_devfs_device)(struct mount *mp, dev_t dev,
157 struct devfs_dirent *de, struct label *label);
158 void (*mpo_create_devfs_directory)(struct mount *mp, char *dirname,
159 int dirnamelen, struct devfs_dirent *de,
160 struct label *label);
161 void (*mpo_create_devfs_symlink)(struct ucred *cred,
162 struct mount *mp, struct devfs_dirent *dd,
163 struct label *ddlabel, struct devfs_dirent *de,
164 struct label *delabel);
165 int (*mpo_create_vnode_extattr)(struct ucred *cred,
166 struct mount *mp, struct label *fslabel,
167 struct vnode *dvp, struct label *dlabel,
168 struct vnode *vp, struct label *vlabel,
169 struct componentname *cnp);
170 void (*mpo_create_mount)(struct ucred *cred, struct mount *mp,
171 struct label *mntlabel, struct label *fslabel);
172 void (*mpo_create_root_mount)(struct ucred *cred, struct mount *mp,
173 struct label *mountlabel, struct label *fslabel);
174 void (*mpo_relabel_vnode)(struct ucred *cred, struct vnode *vp,
175 struct label *vnodelabel, struct label *label);
176 int (*mpo_setlabel_vnode_extattr)(struct ucred *cred,
177 struct vnode *vp, struct label *vlabel,
178 struct label *intlabel);
179 void (*mpo_update_devfsdirent)(struct mount *mp,
180 struct devfs_dirent *devfs_dirent,
181 struct label *direntlabel, struct vnode *vp,
182 struct label *vnodelabel);
183
184 /*
185 * Labeling event operations: IPC objects.
186 */
187 void (*mpo_create_mbuf_from_socket)(struct socket *so,
188 struct label *socketlabel, struct mbuf *m,
189 struct label *mbuflabel);
190 void (*mpo_create_socket)(struct ucred *cred, struct socket *so,
191 struct label *socketlabel);
192 void (*mpo_create_socket_from_socket)(struct socket *oldsocket,
193 struct label *oldsocketlabel, struct socket *newsocket,
194 struct label *newsocketlabel);
195 void (*mpo_relabel_socket)(struct ucred *cred, struct socket *so,
196 struct label *oldlabel, struct label *newlabel);
197 void (*mpo_relabel_pipe)(struct ucred *cred, struct pipe *pipe,
198 struct label *oldlabel, struct label *newlabel);
199 void (*mpo_set_socket_peer_from_mbuf)(struct mbuf *mbuf,
200 struct label *mbuflabel, struct socket *so,
201 struct label *socketpeerlabel);
202 void (*mpo_set_socket_peer_from_socket)(struct socket *oldsocket,
203 struct label *oldsocketlabel, struct socket *newsocket,
204 struct label *newsocketpeerlabel);
205 void (*mpo_create_pipe)(struct ucred *cred, struct pipe *pipe,
206 struct label *pipelabel);
207
208 /*
209 * Labeling event operations: network objects.
210 */
211 void (*mpo_create_bpfdesc)(struct ucred *cred, struct bpf_d *bpf_d,
212 struct label *bpflabel);
213 void (*mpo_create_ifnet)(struct ifnet *ifnet,
214 struct label *ifnetlabel);
105 void (*mpo_destroy_ipq_label)(struct label *label);
106 void (*mpo_destroy_mbuf_label)(struct label *label);
107 void (*mpo_destroy_mount_label)(struct label *label);
108 void (*mpo_destroy_mount_fs_label)(struct label *label);
109 void (*mpo_destroy_socket_label)(struct label *label);
110 void (*mpo_destroy_socket_peer_label)(struct label *label);
111 void (*mpo_destroy_pipe_label)(struct label *label);
112 void (*mpo_destroy_proc_label)(struct label *label);
113 void (*mpo_destroy_vnode_label)(struct label *label);
114 void (*mpo_copy_mbuf_label)(struct label *src,
115 struct label *dest);
116 void (*mpo_copy_pipe_label)(struct label *src,
117 struct label *dest);
118 void (*mpo_copy_socket_label)(struct label *src,
119 struct label *dest);
120 void (*mpo_copy_vnode_label)(struct label *src,
121 struct label *dest);
122 int (*mpo_externalize_cred_label)(struct label *label,
123 char *element_name, struct sbuf *sb, int *claimed);
124 int (*mpo_externalize_ifnet_label)(struct label *label,
125 char *element_name, struct sbuf *sb, int *claimed);
126 int (*mpo_externalize_pipe_label)(struct label *label,
127 char *element_name, struct sbuf *sb, int *claimed);
128 int (*mpo_externalize_socket_label)(struct label *label,
129 char *element_name, struct sbuf *sb, int *claimed);
130 int (*mpo_externalize_socket_peer_label)(struct label *label,
131 char *element_name, struct sbuf *sb, int *claimed);
132 int (*mpo_externalize_vnode_label)(struct label *label,
133 char *element_name, struct sbuf *sb, int *claimed);
134 int (*mpo_internalize_cred_label)(struct label *label,
135 char *element_name, char *element_data, int *claimed);
136 int (*mpo_internalize_ifnet_label)(struct label *label,
137 char *element_name, char *element_data, int *claimed);
138 int (*mpo_internalize_pipe_label)(struct label *label,
139 char *element_name, char *element_data, int *claimed);
140 int (*mpo_internalize_socket_label)(struct label *label,
141 char *element_name, char *element_data, int *claimed);
142 int (*mpo_internalize_vnode_label)(struct label *label,
143 char *element_name, char *element_data, int *claimed);
144
145 /*
146 * Labeling event operations: file system objects, and things that
147 * look a lot like file system objects.
148 */
149 void (*mpo_associate_vnode_devfs)(struct mount *mp,
150 struct label *fslabel, struct devfs_dirent *de,
151 struct label *delabel, struct vnode *vp,
152 struct label *vlabel);
153 int (*mpo_associate_vnode_extattr)(struct mount *mp,
154 struct label *fslabel, struct vnode *vp,
155 struct label *vlabel);
156 void (*mpo_associate_vnode_singlelabel)(struct mount *mp,
157 struct label *fslabel, struct vnode *vp,
158 struct label *vlabel);
159 void (*mpo_create_devfs_device)(struct mount *mp, dev_t dev,
160 struct devfs_dirent *de, struct label *label);
161 void (*mpo_create_devfs_directory)(struct mount *mp, char *dirname,
162 int dirnamelen, struct devfs_dirent *de,
163 struct label *label);
164 void (*mpo_create_devfs_symlink)(struct ucred *cred,
165 struct mount *mp, struct devfs_dirent *dd,
166 struct label *ddlabel, struct devfs_dirent *de,
167 struct label *delabel);
168 int (*mpo_create_vnode_extattr)(struct ucred *cred,
169 struct mount *mp, struct label *fslabel,
170 struct vnode *dvp, struct label *dlabel,
171 struct vnode *vp, struct label *vlabel,
172 struct componentname *cnp);
173 void (*mpo_create_mount)(struct ucred *cred, struct mount *mp,
174 struct label *mntlabel, struct label *fslabel);
175 void (*mpo_create_root_mount)(struct ucred *cred, struct mount *mp,
176 struct label *mountlabel, struct label *fslabel);
177 void (*mpo_relabel_vnode)(struct ucred *cred, struct vnode *vp,
178 struct label *vnodelabel, struct label *label);
179 int (*mpo_setlabel_vnode_extattr)(struct ucred *cred,
180 struct vnode *vp, struct label *vlabel,
181 struct label *intlabel);
182 void (*mpo_update_devfsdirent)(struct mount *mp,
183 struct devfs_dirent *devfs_dirent,
184 struct label *direntlabel, struct vnode *vp,
185 struct label *vnodelabel);
186
187 /*
188 * Labeling event operations: IPC objects.
189 */
190 void (*mpo_create_mbuf_from_socket)(struct socket *so,
191 struct label *socketlabel, struct mbuf *m,
192 struct label *mbuflabel);
193 void (*mpo_create_socket)(struct ucred *cred, struct socket *so,
194 struct label *socketlabel);
195 void (*mpo_create_socket_from_socket)(struct socket *oldsocket,
196 struct label *oldsocketlabel, struct socket *newsocket,
197 struct label *newsocketlabel);
198 void (*mpo_relabel_socket)(struct ucred *cred, struct socket *so,
199 struct label *oldlabel, struct label *newlabel);
200 void (*mpo_relabel_pipe)(struct ucred *cred, struct pipe *pipe,
201 struct label *oldlabel, struct label *newlabel);
202 void (*mpo_set_socket_peer_from_mbuf)(struct mbuf *mbuf,
203 struct label *mbuflabel, struct socket *so,
204 struct label *socketpeerlabel);
205 void (*mpo_set_socket_peer_from_socket)(struct socket *oldsocket,
206 struct label *oldsocketlabel, struct socket *newsocket,
207 struct label *newsocketpeerlabel);
208 void (*mpo_create_pipe)(struct ucred *cred, struct pipe *pipe,
209 struct label *pipelabel);
210
211 /*
212 * Labeling event operations: network objects.
213 */
214 void (*mpo_create_bpfdesc)(struct ucred *cred, struct bpf_d *bpf_d,
215 struct label *bpflabel);
216 void (*mpo_create_ifnet)(struct ifnet *ifnet,
217 struct label *ifnetlabel);
218 void (*mpo_create_inpcb_from_socket)(struct socket *so,
219 struct label *solabel, struct inpcb *inp,
220 struct label *inplabel);
215 void (*mpo_create_ipq)(struct mbuf *fragment,
216 struct label *fragmentlabel, struct ipq *ipq,
217 struct label *ipqlabel);
218 void (*mpo_create_datagram_from_ipq)
219 (struct ipq *ipq, struct label *ipqlabel,
220 struct mbuf *datagram, struct label *datagramlabel);
221 void (*mpo_create_fragment)(struct mbuf *datagram,
222 struct label *datagramlabel, struct mbuf *fragment,
223 struct label *fragmentlabel);
224 void (*mpo_create_mbuf_from_mbuf)(struct mbuf *oldmbuf,
225 struct label *oldlabel, struct mbuf *newmbuf,
226 struct label *newlabel);
227 void (*mpo_create_mbuf_linklayer)(struct ifnet *ifnet,
228 struct label *ifnetlabel, struct mbuf *mbuf,
229 struct label *mbuflabel);
230 void (*mpo_create_mbuf_from_bpfdesc)(struct bpf_d *bpf_d,
231 struct label *bpflabel, struct mbuf *mbuf,
232 struct label *mbuflabel);
233 void (*mpo_create_mbuf_from_ifnet)(struct ifnet *ifnet,
234 struct label *ifnetlabel, struct mbuf *mbuf,
235 struct label *mbuflabel);
236 void (*mpo_create_mbuf_multicast_encap)(struct mbuf *oldmbuf,
237 struct label *oldmbuflabel, struct ifnet *ifnet,
238 struct label *ifnetlabel, struct mbuf *newmbuf,
239 struct label *newmbuflabel);
240 void (*mpo_create_mbuf_netlayer)(struct mbuf *oldmbuf,
241 struct label *oldmbuflabel, struct mbuf *newmbuf,
242 struct label *newmbuflabel);
243 int (*mpo_fragment_match)(struct mbuf *fragment,
244 struct label *fragmentlabel, struct ipq *ipq,
245 struct label *ipqlabel);
246 void (*mpo_reflect_mbuf_icmp)(struct mbuf *m,
247 struct label *mlabel);
248 void (*mpo_reflect_mbuf_tcp)(struct mbuf *m, struct label *mlabel);
249 void (*mpo_relabel_ifnet)(struct ucred *cred, struct ifnet *ifnet,
250 struct label *ifnetlabel, struct label *newlabel);
251 void (*mpo_update_ipq)(struct mbuf *fragment,
252 struct label *fragmentlabel, struct ipq *ipq,
253 struct label *ipqlabel);
221 void (*mpo_create_ipq)(struct mbuf *fragment,
222 struct label *fragmentlabel, struct ipq *ipq,
223 struct label *ipqlabel);
224 void (*mpo_create_datagram_from_ipq)
225 (struct ipq *ipq, struct label *ipqlabel,
226 struct mbuf *datagram, struct label *datagramlabel);
227 void (*mpo_create_fragment)(struct mbuf *datagram,
228 struct label *datagramlabel, struct mbuf *fragment,
229 struct label *fragmentlabel);
230 void (*mpo_create_mbuf_from_mbuf)(struct mbuf *oldmbuf,
231 struct label *oldlabel, struct mbuf *newmbuf,
232 struct label *newlabel);
233 void (*mpo_create_mbuf_linklayer)(struct ifnet *ifnet,
234 struct label *ifnetlabel, struct mbuf *mbuf,
235 struct label *mbuflabel);
236 void (*mpo_create_mbuf_from_bpfdesc)(struct bpf_d *bpf_d,
237 struct label *bpflabel, struct mbuf *mbuf,
238 struct label *mbuflabel);
239 void (*mpo_create_mbuf_from_ifnet)(struct ifnet *ifnet,
240 struct label *ifnetlabel, struct mbuf *mbuf,
241 struct label *mbuflabel);
242 void (*mpo_create_mbuf_multicast_encap)(struct mbuf *oldmbuf,
243 struct label *oldmbuflabel, struct ifnet *ifnet,
244 struct label *ifnetlabel, struct mbuf *newmbuf,
245 struct label *newmbuflabel);
246 void (*mpo_create_mbuf_netlayer)(struct mbuf *oldmbuf,
247 struct label *oldmbuflabel, struct mbuf *newmbuf,
248 struct label *newmbuflabel);
249 int (*mpo_fragment_match)(struct mbuf *fragment,
250 struct label *fragmentlabel, struct ipq *ipq,
251 struct label *ipqlabel);
252 void (*mpo_reflect_mbuf_icmp)(struct mbuf *m,
253 struct label *mlabel);
254 void (*mpo_reflect_mbuf_tcp)(struct mbuf *m, struct label *mlabel);
255 void (*mpo_relabel_ifnet)(struct ucred *cred, struct ifnet *ifnet,
256 struct label *ifnetlabel, struct label *newlabel);
257 void (*mpo_update_ipq)(struct mbuf *fragment,
258 struct label *fragmentlabel, struct ipq *ipq,
259 struct label *ipqlabel);
260 void (*mpo_inpcb_sosetlabel)(struct socket *so,
261 struct label *label, struct inpcb *inp,
262 struct label *inplabel);
254
255 /*
256 * Labeling event operations: processes.
257 */
258 void (*mpo_create_cred)(struct ucred *parent_cred,
259 struct ucred *child_cred);
260 void (*mpo_execve_transition)(struct ucred *old, struct ucred *new,
261 struct vnode *vp, struct label *vnodelabel,
262 struct label *interpvnodelabel,
263 struct image_params *imgp, struct label *execlabel);
264 int (*mpo_execve_will_transition)(struct ucred *old,
265 struct vnode *vp, struct label *vnodelabel,
266 struct label *interpvnodelabel,
267 struct image_params *imgp, struct label *execlabel);
268 void (*mpo_create_proc0)(struct ucred *cred);
269 void (*mpo_create_proc1)(struct ucred *cred);
270 void (*mpo_relabel_cred)(struct ucred *cred,
271 struct label *newlabel);
272 void (*mpo_thread_userret)(struct thread *thread);
273
274 /*
275 * Access control checks.
276 */
277 int (*mpo_check_bpfdesc_receive)(struct bpf_d *bpf_d,
278 struct label *bpflabel, struct ifnet *ifnet,
279 struct label *ifnetlabel);
280 int (*mpo_check_cred_relabel)(struct ucred *cred,
281 struct label *newlabel);
282 int (*mpo_check_cred_visible)(struct ucred *u1, struct ucred *u2);
283 int (*mpo_check_ifnet_relabel)(struct ucred *cred,
284 struct ifnet *ifnet, struct label *ifnetlabel,
285 struct label *newlabel);
286 int (*mpo_check_ifnet_transmit)(struct ifnet *ifnet,
287 struct label *ifnetlabel, struct mbuf *m,
288 struct label *mbuflabel);
263
264 /*
265 * Labeling event operations: processes.
266 */
267 void (*mpo_create_cred)(struct ucred *parent_cred,
268 struct ucred *child_cred);
269 void (*mpo_execve_transition)(struct ucred *old, struct ucred *new,
270 struct vnode *vp, struct label *vnodelabel,
271 struct label *interpvnodelabel,
272 struct image_params *imgp, struct label *execlabel);
273 int (*mpo_execve_will_transition)(struct ucred *old,
274 struct vnode *vp, struct label *vnodelabel,
275 struct label *interpvnodelabel,
276 struct image_params *imgp, struct label *execlabel);
277 void (*mpo_create_proc0)(struct ucred *cred);
278 void (*mpo_create_proc1)(struct ucred *cred);
279 void (*mpo_relabel_cred)(struct ucred *cred,
280 struct label *newlabel);
281 void (*mpo_thread_userret)(struct thread *thread);
282
283 /*
284 * Access control checks.
285 */
286 int (*mpo_check_bpfdesc_receive)(struct bpf_d *bpf_d,
287 struct label *bpflabel, struct ifnet *ifnet,
288 struct label *ifnetlabel);
289 int (*mpo_check_cred_relabel)(struct ucred *cred,
290 struct label *newlabel);
291 int (*mpo_check_cred_visible)(struct ucred *u1, struct ucred *u2);
292 int (*mpo_check_ifnet_relabel)(struct ucred *cred,
293 struct ifnet *ifnet, struct label *ifnetlabel,
294 struct label *newlabel);
295 int (*mpo_check_ifnet_transmit)(struct ifnet *ifnet,
296 struct label *ifnetlabel, struct mbuf *m,
297 struct label *mbuflabel);
298 int (*mpo_check_inpcb_deliver)(struct inpcb *inp,
299 struct label *inplabel, struct mbuf *m,
300 struct label *mlabel);
289 int (*mpo_check_kenv_dump)(struct ucred *cred);
290 int (*mpo_check_kenv_get)(struct ucred *cred, char *name);
291 int (*mpo_check_kenv_set)(struct ucred *cred, char *name,
292 char *value);
293 int (*mpo_check_kenv_unset)(struct ucred *cred, char *name);
294 int (*mpo_check_kld_load)(struct ucred *cred, struct vnode *vp,
295 struct label *vlabel);
296 int (*mpo_check_kld_stat)(struct ucred *cred);
297 int (*mpo_check_kld_unload)(struct ucred *cred);
298 int (*mpo_check_mount_stat)(struct ucred *cred, struct mount *mp,
299 struct label *mntlabel);
300 int (*mpo_check_pipe_ioctl)(struct ucred *cred, struct pipe *pipe,
301 struct label *pipelabel, unsigned long cmd, void *data);
302 int (*mpo_check_pipe_poll)(struct ucred *cred, struct pipe *pipe,
303 struct label *pipelabel);
304 int (*mpo_check_pipe_read)(struct ucred *cred, struct pipe *pipe,
305 struct label *pipelabel);
306 int (*mpo_check_pipe_relabel)(struct ucred *cred,
307 struct pipe *pipe, struct label *pipelabel,
308 struct label *newlabel);
309 int (*mpo_check_pipe_stat)(struct ucred *cred, struct pipe *pipe,
310 struct label *pipelabel);
311 int (*mpo_check_pipe_write)(struct ucred *cred, struct pipe *pipe,
312 struct label *pipelabel);
313 int (*mpo_check_proc_debug)(struct ucred *cred,
314 struct proc *proc);
315 int (*mpo_check_proc_sched)(struct ucred *cred,
316 struct proc *proc);
317 int (*mpo_check_proc_signal)(struct ucred *cred,
318 struct proc *proc, int signum);
319 int (*mpo_check_socket_bind)(struct ucred *cred,
320 struct socket *so, struct label *socketlabel,
321 struct sockaddr *sockaddr);
322 int (*mpo_check_socket_connect)(struct ucred *cred,
323 struct socket *so, struct label *socketlabel,
324 struct sockaddr *sockaddr);
325 int (*mpo_check_socket_deliver)(struct socket *so,
326 struct label *socketlabel, struct mbuf *m,
327 struct label *mbuflabel);
328 int (*mpo_check_socket_listen)(struct ucred *cred,
329 struct socket *so, struct label *socketlabel);
330 int (*mpo_check_socket_receive)(struct ucred *cred,
331 struct socket *so, struct label *socketlabel);
332 int (*mpo_check_socket_relabel)(struct ucred *cred,
333 struct socket *so, struct label *socketlabel,
334 struct label *newlabel);
335 int (*mpo_check_socket_send)(struct ucred *cred,
336 struct socket *so, struct label *socketlabel);
337 int (*mpo_check_socket_visible)(struct ucred *cred,
338 struct socket *so, struct label *socketlabel);
339 int (*mpo_check_sysarch_ioperm)(struct ucred *cred);
340 int (*mpo_check_system_acct)(struct ucred *cred,
341 struct vnode *vp, struct label *vlabel);
342 int (*mpo_check_system_nfsd)(struct ucred *cred);
343 int (*mpo_check_system_reboot)(struct ucred *cred, int howto);
344 int (*mpo_check_system_settime)(struct ucred *cred);
345 int (*mpo_check_system_swapon)(struct ucred *cred,
346 struct vnode *vp, struct label *label);
347 int (*mpo_check_system_swapoff)(struct ucred *cred,
348 struct vnode *vp, struct label *label);
349 int (*mpo_check_system_sysctl)(struct ucred *cred, int *name,
350 u_int namelen, void *old, size_t *oldlenp, int inkernel,
351 void *new, size_t newlen);
352 int (*mpo_check_vnode_access)(struct ucred *cred,
353 struct vnode *vp, struct label *label, int acc_mode);
354 int (*mpo_check_vnode_chdir)(struct ucred *cred,
355 struct vnode *dvp, struct label *dlabel);
356 int (*mpo_check_vnode_chroot)(struct ucred *cred,
357 struct vnode *dvp, struct label *dlabel);
358 int (*mpo_check_vnode_create)(struct ucred *cred,
359 struct vnode *dvp, struct label *dlabel,
360 struct componentname *cnp, struct vattr *vap);
361 int (*mpo_check_vnode_delete)(struct ucred *cred,
362 struct vnode *dvp, struct label *dlabel,
363 struct vnode *vp, struct label *label,
364 struct componentname *cnp);
365 int (*mpo_check_vnode_deleteacl)(struct ucred *cred,
366 struct vnode *vp, struct label *label, acl_type_t type);
367 int (*mpo_check_vnode_deleteextattr)(struct ucred *cred,
368 struct vnode *vp, struct label *label, int attrnamespace,
369 const char *name);
370 int (*mpo_check_vnode_exec)(struct ucred *cred, struct vnode *vp,
371 struct label *label, struct image_params *imgp,
372 struct label *execlabel);
373 int (*mpo_check_vnode_getacl)(struct ucred *cred,
374 struct vnode *vp, struct label *label, acl_type_t type);
375 int (*mpo_check_vnode_getextattr)(struct ucred *cred,
376 struct vnode *vp, struct label *label, int attrnamespace,
377 const char *name, struct uio *uio);
378 int (*mpo_check_vnode_link)(struct ucred *cred, struct vnode *dvp,
379 struct label *dlabel, struct vnode *vp,
380 struct label *label, struct componentname *cnp);
381 int (*mpo_check_vnode_listextattr)(struct ucred *cred,
382 struct vnode *vp, struct label *label, int attrnamespace);
383 int (*mpo_check_vnode_lookup)(struct ucred *cred,
384 struct vnode *dvp, struct label *dlabel,
385 struct componentname *cnp);
386 int (*mpo_check_vnode_mmap)(struct ucred *cred, struct vnode *vp,
387 struct label *label, int prot);
388 void (*mpo_check_vnode_mmap_downgrade)(struct ucred *cred,
389 struct vnode *vp, struct label *label, int *prot);
390 int (*mpo_check_vnode_mprotect)(struct ucred *cred,
391 struct vnode *vp, struct label *label, int prot);
392 int (*mpo_check_vnode_open)(struct ucred *cred, struct vnode *vp,
393 struct label *label, int acc_mode);
394 int (*mpo_check_vnode_poll)(struct ucred *active_cred,
395 struct ucred *file_cred, struct vnode *vp,
396 struct label *label);
397 int (*mpo_check_vnode_read)(struct ucred *active_cred,
398 struct ucred *file_cred, struct vnode *vp,
399 struct label *label);
400 int (*mpo_check_vnode_readdir)(struct ucred *cred,
401 struct vnode *dvp, struct label *dlabel);
402 int (*mpo_check_vnode_readlink)(struct ucred *cred,
403 struct vnode *vp, struct label *label);
404 int (*mpo_check_vnode_relabel)(struct ucred *cred,
405 struct vnode *vp, struct label *vnodelabel,
406 struct label *newlabel);
407 int (*mpo_check_vnode_rename_from)(struct ucred *cred,
408 struct vnode *dvp, struct label *dlabel, struct vnode *vp,
409 struct label *label, struct componentname *cnp);
410 int (*mpo_check_vnode_rename_to)(struct ucred *cred,
411 struct vnode *dvp, struct label *dlabel, struct vnode *vp,
412 struct label *label, int samedir,
413 struct componentname *cnp);
414 int (*mpo_check_vnode_revoke)(struct ucred *cred,
415 struct vnode *vp, struct label *label);
416 int (*mpo_check_vnode_setacl)(struct ucred *cred,
417 struct vnode *vp, struct label *label, acl_type_t type,
418 struct acl *acl);
419 int (*mpo_check_vnode_setextattr)(struct ucred *cred,
420 struct vnode *vp, struct label *label, int attrnamespace,
421 const char *name, struct uio *uio);
422 int (*mpo_check_vnode_setflags)(struct ucred *cred,
423 struct vnode *vp, struct label *label, u_long flags);
424 int (*mpo_check_vnode_setmode)(struct ucred *cred,
425 struct vnode *vp, struct label *label, mode_t mode);
426 int (*mpo_check_vnode_setowner)(struct ucred *cred,
427 struct vnode *vp, struct label *label, uid_t uid,
428 gid_t gid);
429 int (*mpo_check_vnode_setutimes)(struct ucred *cred,
430 struct vnode *vp, struct label *label,
431 struct timespec atime, struct timespec mtime);
432 int (*mpo_check_vnode_stat)(struct ucred *active_cred,
433 struct ucred *file_cred, struct vnode *vp,
434 struct label *label);
435 int (*mpo_check_vnode_write)(struct ucred *active_cred,
436 struct ucred *file_cred, struct vnode *vp,
437 struct label *label);
438};
439
440struct mac_policy_conf {
441 char *mpc_name; /* policy name */
442 char *mpc_fullname; /* policy full name */
443 struct mac_policy_ops *mpc_ops; /* policy operations */
444 int mpc_loadtime_flags; /* flags */
445 int *mpc_field_off; /* security field */
446 int mpc_runtime_flags; /* flags */
447 LIST_ENTRY(mac_policy_conf) mpc_list; /* global list */
448};
449
450/* Flags for the mpc_loadtime_flags field. */
451#define MPC_LOADTIME_FLAG_NOTLATE 0x00000001
452#define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002
453#define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004
454
455/* Flags for the mpc_runtime_flags field. */
456#define MPC_RUNTIME_FLAG_REGISTERED 0x00000001
457
458#define MAC_POLICY_SET(mpops, mpname, mpfullname, mpflags, privdata_wanted) \
459 static struct mac_policy_conf mpname##_mac_policy_conf = { \
460 #mpname, \
461 mpfullname, \
462 mpops, \
463 mpflags, \
464 privdata_wanted, \
465 0, \
466 }; \
467 static moduledata_t mpname##_mod = { \
468 #mpname, \
469 mac_policy_modevent, \
470 &mpname##_mac_policy_conf \
471 }; \
472 MODULE_DEPEND(mpname, kernel_mac_support, 1, 1, 1); \
473 DECLARE_MODULE(mpname, mpname##_mod, SI_SUB_MAC_POLICY, \
474 SI_ORDER_MIDDLE)
475
476int mac_policy_modevent(module_t mod, int type, void *data);
477
478#define LABEL_TO_SLOT(l, s) (l)->l_perpolicy[s]
479
480#endif /* !_SYS_MAC_POLICY_H */
301 int (*mpo_check_kenv_dump)(struct ucred *cred);
302 int (*mpo_check_kenv_get)(struct ucred *cred, char *name);
303 int (*mpo_check_kenv_set)(struct ucred *cred, char *name,
304 char *value);
305 int (*mpo_check_kenv_unset)(struct ucred *cred, char *name);
306 int (*mpo_check_kld_load)(struct ucred *cred, struct vnode *vp,
307 struct label *vlabel);
308 int (*mpo_check_kld_stat)(struct ucred *cred);
309 int (*mpo_check_kld_unload)(struct ucred *cred);
310 int (*mpo_check_mount_stat)(struct ucred *cred, struct mount *mp,
311 struct label *mntlabel);
312 int (*mpo_check_pipe_ioctl)(struct ucred *cred, struct pipe *pipe,
313 struct label *pipelabel, unsigned long cmd, void *data);
314 int (*mpo_check_pipe_poll)(struct ucred *cred, struct pipe *pipe,
315 struct label *pipelabel);
316 int (*mpo_check_pipe_read)(struct ucred *cred, struct pipe *pipe,
317 struct label *pipelabel);
318 int (*mpo_check_pipe_relabel)(struct ucred *cred,
319 struct pipe *pipe, struct label *pipelabel,
320 struct label *newlabel);
321 int (*mpo_check_pipe_stat)(struct ucred *cred, struct pipe *pipe,
322 struct label *pipelabel);
323 int (*mpo_check_pipe_write)(struct ucred *cred, struct pipe *pipe,
324 struct label *pipelabel);
325 int (*mpo_check_proc_debug)(struct ucred *cred,
326 struct proc *proc);
327 int (*mpo_check_proc_sched)(struct ucred *cred,
328 struct proc *proc);
329 int (*mpo_check_proc_signal)(struct ucred *cred,
330 struct proc *proc, int signum);
331 int (*mpo_check_socket_bind)(struct ucred *cred,
332 struct socket *so, struct label *socketlabel,
333 struct sockaddr *sockaddr);
334 int (*mpo_check_socket_connect)(struct ucred *cred,
335 struct socket *so, struct label *socketlabel,
336 struct sockaddr *sockaddr);
337 int (*mpo_check_socket_deliver)(struct socket *so,
338 struct label *socketlabel, struct mbuf *m,
339 struct label *mbuflabel);
340 int (*mpo_check_socket_listen)(struct ucred *cred,
341 struct socket *so, struct label *socketlabel);
342 int (*mpo_check_socket_receive)(struct ucred *cred,
343 struct socket *so, struct label *socketlabel);
344 int (*mpo_check_socket_relabel)(struct ucred *cred,
345 struct socket *so, struct label *socketlabel,
346 struct label *newlabel);
347 int (*mpo_check_socket_send)(struct ucred *cred,
348 struct socket *so, struct label *socketlabel);
349 int (*mpo_check_socket_visible)(struct ucred *cred,
350 struct socket *so, struct label *socketlabel);
351 int (*mpo_check_sysarch_ioperm)(struct ucred *cred);
352 int (*mpo_check_system_acct)(struct ucred *cred,
353 struct vnode *vp, struct label *vlabel);
354 int (*mpo_check_system_nfsd)(struct ucred *cred);
355 int (*mpo_check_system_reboot)(struct ucred *cred, int howto);
356 int (*mpo_check_system_settime)(struct ucred *cred);
357 int (*mpo_check_system_swapon)(struct ucred *cred,
358 struct vnode *vp, struct label *label);
359 int (*mpo_check_system_swapoff)(struct ucred *cred,
360 struct vnode *vp, struct label *label);
361 int (*mpo_check_system_sysctl)(struct ucred *cred, int *name,
362 u_int namelen, void *old, size_t *oldlenp, int inkernel,
363 void *new, size_t newlen);
364 int (*mpo_check_vnode_access)(struct ucred *cred,
365 struct vnode *vp, struct label *label, int acc_mode);
366 int (*mpo_check_vnode_chdir)(struct ucred *cred,
367 struct vnode *dvp, struct label *dlabel);
368 int (*mpo_check_vnode_chroot)(struct ucred *cred,
369 struct vnode *dvp, struct label *dlabel);
370 int (*mpo_check_vnode_create)(struct ucred *cred,
371 struct vnode *dvp, struct label *dlabel,
372 struct componentname *cnp, struct vattr *vap);
373 int (*mpo_check_vnode_delete)(struct ucred *cred,
374 struct vnode *dvp, struct label *dlabel,
375 struct vnode *vp, struct label *label,
376 struct componentname *cnp);
377 int (*mpo_check_vnode_deleteacl)(struct ucred *cred,
378 struct vnode *vp, struct label *label, acl_type_t type);
379 int (*mpo_check_vnode_deleteextattr)(struct ucred *cred,
380 struct vnode *vp, struct label *label, int attrnamespace,
381 const char *name);
382 int (*mpo_check_vnode_exec)(struct ucred *cred, struct vnode *vp,
383 struct label *label, struct image_params *imgp,
384 struct label *execlabel);
385 int (*mpo_check_vnode_getacl)(struct ucred *cred,
386 struct vnode *vp, struct label *label, acl_type_t type);
387 int (*mpo_check_vnode_getextattr)(struct ucred *cred,
388 struct vnode *vp, struct label *label, int attrnamespace,
389 const char *name, struct uio *uio);
390 int (*mpo_check_vnode_link)(struct ucred *cred, struct vnode *dvp,
391 struct label *dlabel, struct vnode *vp,
392 struct label *label, struct componentname *cnp);
393 int (*mpo_check_vnode_listextattr)(struct ucred *cred,
394 struct vnode *vp, struct label *label, int attrnamespace);
395 int (*mpo_check_vnode_lookup)(struct ucred *cred,
396 struct vnode *dvp, struct label *dlabel,
397 struct componentname *cnp);
398 int (*mpo_check_vnode_mmap)(struct ucred *cred, struct vnode *vp,
399 struct label *label, int prot);
400 void (*mpo_check_vnode_mmap_downgrade)(struct ucred *cred,
401 struct vnode *vp, struct label *label, int *prot);
402 int (*mpo_check_vnode_mprotect)(struct ucred *cred,
403 struct vnode *vp, struct label *label, int prot);
404 int (*mpo_check_vnode_open)(struct ucred *cred, struct vnode *vp,
405 struct label *label, int acc_mode);
406 int (*mpo_check_vnode_poll)(struct ucred *active_cred,
407 struct ucred *file_cred, struct vnode *vp,
408 struct label *label);
409 int (*mpo_check_vnode_read)(struct ucred *active_cred,
410 struct ucred *file_cred, struct vnode *vp,
411 struct label *label);
412 int (*mpo_check_vnode_readdir)(struct ucred *cred,
413 struct vnode *dvp, struct label *dlabel);
414 int (*mpo_check_vnode_readlink)(struct ucred *cred,
415 struct vnode *vp, struct label *label);
416 int (*mpo_check_vnode_relabel)(struct ucred *cred,
417 struct vnode *vp, struct label *vnodelabel,
418 struct label *newlabel);
419 int (*mpo_check_vnode_rename_from)(struct ucred *cred,
420 struct vnode *dvp, struct label *dlabel, struct vnode *vp,
421 struct label *label, struct componentname *cnp);
422 int (*mpo_check_vnode_rename_to)(struct ucred *cred,
423 struct vnode *dvp, struct label *dlabel, struct vnode *vp,
424 struct label *label, int samedir,
425 struct componentname *cnp);
426 int (*mpo_check_vnode_revoke)(struct ucred *cred,
427 struct vnode *vp, struct label *label);
428 int (*mpo_check_vnode_setacl)(struct ucred *cred,
429 struct vnode *vp, struct label *label, acl_type_t type,
430 struct acl *acl);
431 int (*mpo_check_vnode_setextattr)(struct ucred *cred,
432 struct vnode *vp, struct label *label, int attrnamespace,
433 const char *name, struct uio *uio);
434 int (*mpo_check_vnode_setflags)(struct ucred *cred,
435 struct vnode *vp, struct label *label, u_long flags);
436 int (*mpo_check_vnode_setmode)(struct ucred *cred,
437 struct vnode *vp, struct label *label, mode_t mode);
438 int (*mpo_check_vnode_setowner)(struct ucred *cred,
439 struct vnode *vp, struct label *label, uid_t uid,
440 gid_t gid);
441 int (*mpo_check_vnode_setutimes)(struct ucred *cred,
442 struct vnode *vp, struct label *label,
443 struct timespec atime, struct timespec mtime);
444 int (*mpo_check_vnode_stat)(struct ucred *active_cred,
445 struct ucred *file_cred, struct vnode *vp,
446 struct label *label);
447 int (*mpo_check_vnode_write)(struct ucred *active_cred,
448 struct ucred *file_cred, struct vnode *vp,
449 struct label *label);
450};
451
452struct mac_policy_conf {
453 char *mpc_name; /* policy name */
454 char *mpc_fullname; /* policy full name */
455 struct mac_policy_ops *mpc_ops; /* policy operations */
456 int mpc_loadtime_flags; /* flags */
457 int *mpc_field_off; /* security field */
458 int mpc_runtime_flags; /* flags */
459 LIST_ENTRY(mac_policy_conf) mpc_list; /* global list */
460};
461
462/* Flags for the mpc_loadtime_flags field. */
463#define MPC_LOADTIME_FLAG_NOTLATE 0x00000001
464#define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002
465#define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004
466
467/* Flags for the mpc_runtime_flags field. */
468#define MPC_RUNTIME_FLAG_REGISTERED 0x00000001
469
470#define MAC_POLICY_SET(mpops, mpname, mpfullname, mpflags, privdata_wanted) \
471 static struct mac_policy_conf mpname##_mac_policy_conf = { \
472 #mpname, \
473 mpfullname, \
474 mpops, \
475 mpflags, \
476 privdata_wanted, \
477 0, \
478 }; \
479 static moduledata_t mpname##_mod = { \
480 #mpname, \
481 mac_policy_modevent, \
482 &mpname##_mac_policy_conf \
483 }; \
484 MODULE_DEPEND(mpname, kernel_mac_support, 1, 1, 1); \
485 DECLARE_MODULE(mpname, mpname##_mod, SI_SUB_MAC_POLICY, \
486 SI_ORDER_MIDDLE)
487
488int mac_policy_modevent(module_t mod, int type, void *data);
489
490#define LABEL_TO_SLOT(l, s) (l)->l_perpolicy[s]
491
492#endif /* !_SYS_MAC_POLICY_H */