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