39 */ 40 41/* 42 * Kernel interface for Mandatory Access Control -- how kernel services 43 * interact with the TrustedBSD MAC Framework. 44 */ 45 46#ifndef _SYS_SECURITY_MAC_MAC_FRAMEWORK_H_ 47#define _SYS_SECURITY_MAC_MAC_FRAMEWORK_H_ 48 49#ifndef _KERNEL 50#error "no user-serviceable parts inside" 51#endif 52 53struct auditinfo; 54struct auditinfo_addr; 55struct bpf_d; 56struct cdev; 57struct componentname; 58struct devfs_dirent; 59struct ifnet; 60struct ifreq; 61struct image_params; 62struct inpcb; 63struct ipq; 64struct ksem; 65struct label; 66struct m_tag; 67struct mac; 68struct mbuf; 69struct mount; 70struct msg; 71struct msqid_kernel; 72struct proc; 73struct semid_kernel; 74struct shmid_kernel; 75struct sockaddr; 76struct socket; 77struct sysctl_oid; 78struct sysctl_req; 79struct pipepair; 80struct thread; 81struct timespec; 82struct ucred; 83struct uio; 84struct vattr; 85struct vnode; 86struct vop_setlabel_args; 87 88#include <sys/acl.h> /* XXX acl_type_t */ 89 90/* 91 * Kernel functions to manage and evaluate labels. 92 */ 93void mac_bpfdesc_init(struct bpf_d *); 94void mac_cred_init(struct ucred *); 95void mac_devfs_init(struct devfs_dirent *); 96void mac_ifnet_init(struct ifnet *); 97int mac_inpcb_init(struct inpcb *, int); 98void mac_sysvmsg_init(struct msg *); 99void mac_sysvmsq_init(struct msqid_kernel *); 100void mac_sysvsem_init(struct semid_kernel *); 101void mac_sysvshm_init(struct shmid_kernel *); 102int mac_ipq_init(struct ipq *, int); 103int mac_socket_init(struct socket *, int); 104void mac_pipe_init(struct pipepair *); 105void mac_posixsem_init(struct ksem *); 106int mac_mbuf_init(struct mbuf *, int); 107int mac_mbuf_tag_init(struct m_tag *, int); 108void mac_mount_init(struct mount *); 109void mac_proc_init(struct proc *); 110void mac_vnode_init(struct vnode *); 111void mac_mbuf_copy(struct mbuf *, struct mbuf *); 112void mac_mbuf_tag_copy(struct m_tag *, struct m_tag *); 113void mac_vnode_copy_label(struct label *, struct label *); 114void mac_bpfdesc_destroy(struct bpf_d *); 115void mac_cred_destroy(struct ucred *); 116void mac_devfs_destroy(struct devfs_dirent *); 117void mac_ifnet_destroy(struct ifnet *); 118void mac_inpcb_destroy(struct inpcb *); 119void mac_sysvmsg_destroy(struct msg *); 120void mac_sysvmsq_destroy(struct msqid_kernel *); 121void mac_sysvsem_destroy(struct semid_kernel *); 122void mac_sysvshm_destroy(struct shmid_kernel *); 123void mac_ipq_destroy(struct ipq *); 124void mac_socket_destroy(struct socket *); 125void mac_pipe_destroy(struct pipepair *); 126void mac_posixsem_destroy(struct ksem *); 127void mac_proc_destroy(struct proc *); 128void mac_mbuf_tag_destroy(struct m_tag *); 129void mac_mount_destroy(struct mount *); 130void mac_vnode_destroy(struct vnode *); 131 132struct label *mac_cred_label_alloc(void); 133void mac_cred_label_free(struct label *); 134struct label *mac_vnode_label_alloc(void); 135void mac_vnode_label_free(struct label *); 136 137/* 138 * Labeling event operations: file system objects, and things that look a lot 139 * like file system objects. 140 */ 141void mac_devfs_vnode_associate(struct mount *mp, struct devfs_dirent *de, 142 struct vnode *vp); 143int mac_vnode_associate_extattr(struct mount *mp, struct vnode *vp); 144void mac_vnode_associate_singlelabel(struct mount *mp, struct vnode *vp); 145void mac_devfs_create_device(struct ucred *cred, struct mount *mp, 146 struct cdev *dev, struct devfs_dirent *de); 147void mac_devfs_create_directory(struct mount *mp, char *dirname, 148 int dirnamelen, struct devfs_dirent *de); 149void mac_devfs_create_symlink(struct ucred *cred, struct mount *mp, 150 struct devfs_dirent *dd, struct devfs_dirent *de); 151int mac_vnode_create_extattr(struct ucred *cred, struct mount *mp, 152 struct vnode *dvp, struct vnode *vp, struct componentname *cnp); 153void mac_mount_create(struct ucred *cred, struct mount *mp); 154void mac_vnode_relabel(struct ucred *cred, struct vnode *vp, 155 struct label *newlabel); 156void mac_devfs_update(struct mount *mp, struct devfs_dirent *de, 157 struct vnode *vp); 158 159/* 160 * Labeling event operations: IPC objects. 161 */ 162void mac_socket_create_mbuf(struct socket *so, struct mbuf *m); 163void mac_socket_create(struct ucred *cred, struct socket *so); 164void mac_socket_newconn(struct socket *oldso, struct socket *newso); 165void mac_socketpeer_set_from_mbuf(struct mbuf *m, struct socket *so); 166void mac_socketpeer_set_from_socket(struct socket *oldso, 167 struct socket *newso); 168void mac_pipe_create(struct ucred *cred, struct pipepair *pp); 169 170/* 171 * Labeling event operations: System V IPC primitives 172 */ 173void mac_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, 174 struct msg *msgptr); 175void mac_sysvmsq_create(struct ucred *cred, struct msqid_kernel *msqkptr); 176void mac_sysvsem_create(struct ucred *cred, 177 struct semid_kernel *semakptr); 178void mac_sysvshm_create(struct ucred *cred, 179 struct shmid_kernel *shmsegptr); 180 181/* 182 * Labeling event operations: POSIX (global/inter-process) semaphores. 183 */ 184void mac_posixsem_create(struct ucred *cred, struct ksem *ks); 185 186/* 187 * Labeling event operations: network objects. 188 */ 189void mac_bpfdesc_create(struct ucred *cred, struct bpf_d *d); 190void mac_ifnet_create(struct ifnet *ifp); 191void mac_inpcb_create(struct socket *so, struct inpcb *inp); 192void mac_ipq_create(struct mbuf *m, struct ipq *ipq); 193void mac_ipq_reassemble(struct ipq *ipq, struct mbuf *m); 194void mac_netinet_fragment(struct mbuf *m, struct mbuf *frag); 195void mac_inpcb_create_mbuf(struct inpcb *inp, struct mbuf *m); 196void mac_create_mbuf_linklayer(struct ifnet *ifp, struct mbuf *m); 197void mac_bpfdesc_create_mbuf(struct bpf_d *d, struct mbuf *m); 198void mac_ifnet_create_mbuf(struct ifnet *ifp, struct mbuf *m); 199void mac_mbuf_create_multicast_encap(struct mbuf *m, struct ifnet *ifp, 200 struct mbuf *mnew); 201void mac_mbuf_create_netlayer(struct mbuf *m, struct mbuf *mnew); 202int mac_ipq_match(struct mbuf *m, struct ipq *ipq); 203void mac_netinet_icmp_reply(struct mbuf *m); 204void mac_netinet_tcp_reply(struct mbuf *m); 205void mac_ipq_update(struct mbuf *m, struct ipq *ipq); 206void mac_inpcb_sosetlabel(struct socket *so, struct inpcb *inp); 207void mac_mbuf_create_from_firewall(struct mbuf *m); 208void mac_destroy_syncache(struct label **l); 209int mac_init_syncache(struct label **l); 210void mac_init_syncache_from_inpcb(struct label *l, struct inpcb *inp); 211void mac_create_mbuf_from_syncache(struct label *l, struct mbuf *m); 212 213/* 214 * Labeling event operations: processes. 215 */ 216void mac_cred_copy(struct ucred *cr1, struct ucred *cr2); 217int mac_execve_enter(struct image_params *imgp, struct mac *mac_p); 218void mac_execve_exit(struct image_params *imgp); 219void mac_vnode_execve_transition(struct ucred *oldcred, 220 struct ucred *newcred, struct vnode *vp, 221 struct label *interpvplabel, struct image_params *imgp); 222int mac_vnode_execve_will_transition(struct ucred *cred, 223 struct vnode *vp, struct label *interpvplabel, 224 struct image_params *imgp); 225void mac_proc_create_swapper(struct ucred *cred); 226void mac_proc_create_init(struct ucred *cred);
|
228void mac_thread_userret(struct thread *td); 229 230/* 231 * Label cleanup operation: This is the inverse complement for the mac_create 232 * and associate type of hooks. This hook lets the policy module(s) perform a 233 * cleanup/flushing operation on the label associated with the objects, 234 * without freeing up the space allocated. This hook is useful in cases 235 * where it is desirable to remove any labeling reference when recycling any 236 * object to a pool. This hook does not replace the mac_destroy hooks. 237 * 238 * XXXRW: These object methods are inconsistent with the life cycles of other 239 * objects, and likely should be revised to be more consistent. 240 */ 241void mac_sysvmsg_cleanup(struct msg *msgptr); 242void mac_sysvmsq_cleanup(struct msqid_kernel *msqkptr); 243void mac_sysvsem_cleanup(struct semid_kernel *semakptr); 244void mac_sysvshm_cleanup(struct shmid_kernel *shmsegptr); 245 246/* 247 * Access control checks. 248 */ 249int mac_bpfdesc_check_receive(struct bpf_d *d, struct ifnet *ifp); 250int mac_cred_check_visible(struct ucred *cr1, struct ucred *cr2); 251int mac_ifnet_check_transmit(struct ifnet *ifp, struct mbuf *m); 252int mac_inpcb_check_deliver(struct inpcb *inp, struct mbuf *m); 253int mac_sysvmsq_check_msgmsq(struct ucred *cred, struct msg *msgptr, 254 struct msqid_kernel *msqkptr); 255int mac_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr); 256int mac_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr); 257int mac_sysvmsq_check_msqget(struct ucred *cred, 258 struct msqid_kernel *msqkptr); 259int mac_sysvmsq_check_msqsnd(struct ucred *cred, 260 struct msqid_kernel *msqkptr); 261int mac_sysvmsq_check_msqrcv(struct ucred *cred, 262 struct msqid_kernel *msqkptr); 263int mac_sysvmsq_check_msqctl(struct ucred *cred, 264 struct msqid_kernel *msqkptr, int cmd); 265int mac_sysvsem_check_semctl(struct ucred *cred, 266 struct semid_kernel *semakptr, int cmd); 267int mac_sysvsem_check_semget(struct ucred *cred, 268 struct semid_kernel *semakptr); 269int mac_sysvsem_check_semop(struct ucred *cred, 270 struct semid_kernel *semakptr, size_t accesstype); 271int mac_sysvshm_check_shmat(struct ucred *cred, 272 struct shmid_kernel *shmsegptr, int shmflg); 273int mac_sysvshm_check_shmctl(struct ucred *cred, 274 struct shmid_kernel *shmsegptr, int cmd); 275int mac_sysvshm_check_shmdt(struct ucred *cred, 276 struct shmid_kernel *shmsegptr); 277int mac_sysvshm_check_shmget(struct ucred *cred, 278 struct shmid_kernel *shmsegptr, int shmflg); 279int mac_kenv_check_dump(struct ucred *cred); 280int mac_kenv_check_get(struct ucred *cred, char *name); 281int mac_kenv_check_set(struct ucred *cred, char *name, char *value); 282int mac_kenv_check_unset(struct ucred *cred, char *name); 283int mac_kld_check_load(struct ucred *cred, struct vnode *vp); 284int mac_kld_check_stat(struct ucred *cred); 285int mac_mount_check_stat(struct ucred *cred, struct mount *mp); 286int mac_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, 287 unsigned long cmd, void *data); 288int mac_pipe_check_poll(struct ucred *cred, struct pipepair *pp); 289int mac_pipe_check_read(struct ucred *cred, struct pipepair *pp); 290int mac_pipe_check_stat(struct ucred *cred, struct pipepair *pp); 291int mac_pipe_check_write(struct ucred *cred, struct pipepair *pp); 292int mac_posixsem_check_destroy(struct ucred *cred, struct ksem *ks); 293int mac_posixsem_check_getvalue(struct ucred *cred,struct ksem *ks); 294int mac_posixsem_check_open(struct ucred *cred, struct ksem *ks); 295int mac_posixsem_check_post(struct ucred *cred, struct ksem *ks); 296int mac_posixsem_check_unlink(struct ucred *cred, struct ksem *ks); 297int mac_posixsem_check_wait(struct ucred *cred, struct ksem *ks); 298int mac_proc_check_debug(struct ucred *cred, struct proc *p); 299int mac_proc_check_sched(struct ucred *cred, struct proc *p); 300int mac_proc_check_setaudit(struct ucred *cred, struct auditinfo *ai); 301int mac_proc_check_setaudit_addr(struct ucred *cred, 302 struct auditinfo_addr *aia); 303int mac_proc_check_setauid(struct ucred *cred, uid_t auid); 304int mac_proc_check_setuid(struct proc *p, struct ucred *cred, 305 uid_t uid); 306int mac_proc_check_seteuid(struct proc *p, struct ucred *cred, 307 uid_t euid); 308int mac_proc_check_setgid(struct proc *p, struct ucred *cred, 309 gid_t gid); 310int mac_proc_check_setegid(struct proc *p, struct ucred *cred, 311 gid_t egid); 312int mac_proc_check_setgroups(struct proc *p, struct ucred *cred, 313 int ngroups, gid_t *gidset); 314int mac_proc_check_setreuid(struct proc *p, struct ucred *cred, 315 uid_t ruid, uid_t euid); 316int mac_proc_check_setregid(struct proc *p, struct ucred *cred, 317 gid_t rgid, gid_t egid); 318int mac_proc_check_setresuid(struct proc *p, struct ucred *cred, 319 uid_t ruid, uid_t euid, uid_t suid); 320int mac_proc_check_setresgid(struct proc *p, struct ucred *cred, 321 gid_t rgid, gid_t egid, gid_t sgid); 322int mac_proc_check_signal(struct ucred *cred, struct proc *p, 323 int signum); 324int mac_proc_check_wait(struct ucred *cred, struct proc *p); 325int mac_socket_check_accept(struct ucred *cred, struct socket *so); 326int mac_socket_check_bind(struct ucred *cred, struct socket *so, 327 struct sockaddr *sa); 328int mac_socket_check_connect(struct ucred *cred, struct socket *so, 329 struct sockaddr *sa); 330int mac_socket_check_create(struct ucred *cred, int domain, int type, 331 int proto); 332int mac_socket_check_deliver(struct socket *so, struct mbuf *m); 333int mac_socket_check_listen(struct ucred *cred, struct socket *so); 334int mac_socket_check_poll(struct ucred *cred, struct socket *so); 335int mac_socket_check_receive(struct ucred *cred, struct socket *so); 336int mac_socket_check_send(struct ucred *cred, struct socket *so); 337int mac_socket_check_stat(struct ucred *cred, struct socket *so); 338int mac_socket_check_visible(struct ucred *cred, struct socket *so); 339int mac_system_check_acct(struct ucred *cred, struct vnode *vp); 340int mac_system_check_audit(struct ucred *cred, void *record, int length); 341int mac_system_check_auditctl(struct ucred *cred, struct vnode *vp); 342int mac_system_check_auditon(struct ucred *cred, int cmd); 343int mac_system_check_reboot(struct ucred *cred, int howto); 344int mac_system_check_swapon(struct ucred *cred, struct vnode *vp); 345int mac_system_check_swapoff(struct ucred *cred, struct vnode *vp); 346int mac_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, 347 void *arg1, int arg2, struct sysctl_req *req); 348int mac_vnode_check_access(struct ucred *cred, struct vnode *vp, 349 int acc_mode); 350int mac_vnode_check_chdir(struct ucred *cred, struct vnode *dvp); 351int mac_vnode_check_chroot(struct ucred *cred, struct vnode *dvp); 352int mac_vnode_check_create(struct ucred *cred, struct vnode *dvp, 353 struct componentname *cnp, struct vattr *vap); 354int mac_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, 355 acl_type_t type); 356int mac_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, 357 int attrnamespace, const char *name); 358int mac_vnode_check_exec(struct ucred *cred, struct vnode *vp, 359 struct image_params *imgp); 360int mac_vnode_check_getacl(struct ucred *cred, struct vnode *vp, 361 acl_type_t type); 362int mac_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, 363 int attrnamespace, const char *name, struct uio *uio); 364int mac_vnode_check_link(struct ucred *cred, struct vnode *dvp, 365 struct vnode *vp, struct componentname *cnp); 366int mac_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, 367 int attrnamespace); 368int mac_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, 369 struct componentname *cnp); 370int mac_vnode_check_mmap(struct ucred *cred, struct vnode *vp, int prot, 371 int flags); 372int mac_vnode_check_mprotect(struct ucred *cred, struct vnode *vp, 373 int prot); 374int mac_vnode_check_open(struct ucred *cred, struct vnode *vp, 375 int acc_mode); 376int mac_vnode_check_poll(struct ucred *active_cred, 377 struct ucred *file_cred, struct vnode *vp); 378int mac_vnode_check_read(struct ucred *active_cred, 379 struct ucred *file_cred, struct vnode *vp); 380int mac_vnode_check_readdir(struct ucred *cred, struct vnode *vp); 381int mac_vnode_check_readlink(struct ucred *cred, struct vnode *vp); 382int mac_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, 383 struct vnode *vp, struct componentname *cnp); 384int mac_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, 385 struct vnode *vp, int samedir, struct componentname *cnp); 386int mac_vnode_check_revoke(struct ucred *cred, struct vnode *vp); 387int mac_vnode_check_setacl(struct ucred *cred, struct vnode *vp, 388 acl_type_t type, struct acl *acl); 389int mac_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, 390 int attrnamespace, const char *name, struct uio *uio); 391int mac_vnode_check_setflags(struct ucred *cred, struct vnode *vp, 392 u_long flags); 393int mac_vnode_check_setmode(struct ucred *cred, struct vnode *vp, 394 mode_t mode); 395int mac_vnode_check_setowner(struct ucred *cred, struct vnode *vp, 396 uid_t uid, gid_t gid); 397int mac_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, 398 struct timespec atime, struct timespec mtime); 399int mac_vnode_check_stat(struct ucred *active_cred, 400 struct ucred *file_cred, struct vnode *vp); 401int mac_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, 402 struct vnode *vp, struct componentname *cnp); 403int mac_vnode_check_write(struct ucred *active_cred, 404 struct ucred *file_cred, struct vnode *vp); 405int mac_getsockopt_label(struct ucred *cred, struct socket *so, 406 struct mac *extmac); 407int mac_getsockopt_peerlabel(struct ucred *cred, struct socket *so, 408 struct mac *extmac); 409int mac_ifnet_ioctl_get(struct ucred *cred, struct ifreq *ifr, 410 struct ifnet *ifp); 411int mac_ifnet_ioctl_set(struct ucred *cred, struct ifreq *ifr, 412 struct ifnet *ifp); 413int mac_setsockopt_label(struct ucred *cred, struct socket *so, 414 struct mac *extmac); 415int mac_pipe_label_set(struct ucred *cred, struct pipepair *pp, 416 struct label *label); 417void mac_cred_mmapped_drop_perms(struct thread *td, struct ucred *cred);
|