The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/mac_policy.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999-2002 Robert N. M. Watson
    3  * Copyright (c) 2001-2005 Networks Associates Technology, Inc.
    4  * Copyright (c) 2005 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: releng/6.4/sys/sys/mac_policy.h 162448 2006-09-19 15:45:22Z csjp $
   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 struct mac_policy_ops {
   87         /*
   88          * Policy module operations.
   89          */
   90         void    (*mpo_destroy)(struct mac_policy_conf *mpc);
   91         void    (*mpo_init)(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         int     (*mpo_syscall)(struct thread *td, int call, void *arg);
   99 
  100         /*
  101          * Label operations.  Initialize label storage, destroy label
  102          * storage, recycle for re-use without init/destroy, copy a label to
  103          * initialized storage, and externalize/internalize from/to
  104          * initialized storage.
  105          */
  106         void    (*mpo_init_bpfdesc_label)(struct label *label);
  107         void    (*mpo_init_cred_label)(struct label *label);
  108         void    (*mpo_init_devfsdirent_label)(struct label *label);
  109         void    (*_mpo_placeholder0)(void);
  110         void    (*mpo_init_ifnet_label)(struct label *label);
  111         int     (*mpo_init_inpcb_label)(struct label *label, int flag);
  112         void    (*mpo_init_sysv_msgmsg_label)(struct label *label);
  113         void    (*mpo_init_sysv_msgqueue_label)(struct label *label);
  114         void    (*mpo_init_sysv_sem_label)(struct label *label);
  115         void    (*mpo_init_sysv_shm_label)(struct label *label);
  116         int     (*mpo_init_ipq_label)(struct label *label, int flag);
  117         int     (*mpo_init_mbuf_label)(struct label *label, int flag);
  118         void    (*mpo_init_mount_label)(struct label *label);
  119         void    (*mpo_init_mount_fs_label)(struct label *label);
  120         int     (*mpo_init_socket_label)(struct label *label, int flag);
  121         int     (*mpo_init_socket_peer_label)(struct label *label, int flag);
  122         void    (*mpo_init_pipe_label)(struct label *label);
  123         void    (*mpo_init_posix_sem_label)(struct label *label);
  124         void    (*mpo_init_proc_label)(struct label *label);
  125         void    (*mpo_init_vnode_label)(struct label *label);
  126         void    (*mpo_destroy_bpfdesc_label)(struct label *label);
  127         void    (*mpo_destroy_cred_label)(struct label *label);
  128         void    (*mpo_destroy_devfsdirent_label)(struct label *label);
  129         void    (*_mpo_placeholder1)(void);
  130         void    (*mpo_destroy_ifnet_label)(struct label *label);
  131         void    (*mpo_destroy_inpcb_label)(struct label *label);
  132         void    (*mpo_destroy_sysv_msgmsg_label)(struct label *label);
  133         void    (*mpo_destroy_sysv_msgqueue_label)(struct label *label);
  134         void    (*mpo_destroy_sysv_sem_label)(struct label *label);
  135         void    (*mpo_destroy_sysv_shm_label)(struct label *label);
  136         void    (*mpo_destroy_ipq_label)(struct label *label);
  137         void    (*mpo_destroy_mbuf_label)(struct label *label);
  138         void    (*mpo_destroy_mount_label)(struct label *label);
  139         void    (*mpo_destroy_mount_fs_label)(struct label *label);
  140         void    (*mpo_destroy_socket_label)(struct label *label);
  141         void    (*mpo_destroy_socket_peer_label)(struct label *label);
  142         void    (*mpo_destroy_pipe_label)(struct label *label);
  143         void    (*mpo_destroy_posix_sem_label)(struct label *label);
  144         void    (*mpo_destroy_proc_label)(struct label *label);
  145         void    (*mpo_destroy_vnode_label)(struct label *label);
  146         void    (*mpo_cleanup_sysv_msgmsg)(struct label *msglabel);
  147         void    (*mpo_cleanup_sysv_msgqueue)(struct label *msqlabel);
  148         void    (*mpo_cleanup_sysv_sem)(struct label *semalabel);
  149         void    (*mpo_cleanup_sysv_shm)(struct label *shmlabel);
  150         void    (*mpo_copy_cred_label)(struct label *src,
  151                     struct label *dest);
  152         void    (*mpo_copy_ifnet_label)(struct label *src,
  153                     struct label *dest);
  154         void    (*mpo_copy_mbuf_label)(struct label *src,
  155                     struct label *dest);
  156         void    (*_mpo_placeholder2)(void);
  157         void    (*mpo_copy_pipe_label)(struct label *src,
  158                     struct label *dest);
  159         void    (*mpo_copy_socket_label)(struct label *src,
  160                     struct label *dest);
  161         void    (*mpo_copy_vnode_label)(struct label *src,
  162                     struct label *dest);
  163         int     (*mpo_externalize_cred_label)(struct label *label,
  164                     char *element_name, struct sbuf *sb, int *claimed);
  165         int     (*mpo_externalize_ifnet_label)(struct label *label,
  166                     char *element_name, struct sbuf *sb, int *claimed);
  167         void    (*_mpo_placeholder3)(void);
  168         int     (*mpo_externalize_pipe_label)(struct label *label,
  169                     char *element_name, struct sbuf *sb, int *claimed);
  170         int     (*mpo_externalize_socket_label)(struct label *label,
  171                     char *element_name, struct sbuf *sb, int *claimed);
  172         int     (*mpo_externalize_socket_peer_label)(struct label *label,
  173                     char *element_name, struct sbuf *sb, int *claimed);
  174         int     (*mpo_externalize_vnode_label)(struct label *label,
  175                     char *element_name, struct sbuf *sb, int *claimed);
  176         int     (*mpo_internalize_cred_label)(struct label *label,
  177                     char *element_name, char *element_data, int *claimed);
  178         int     (*mpo_internalize_ifnet_label)(struct label *label,
  179                     char *element_name, char *element_data, int *claimed);
  180         void    (*_mpo_placeholder4)(void);
  181         int     (*mpo_internalize_pipe_label)(struct label *label,
  182                     char *element_name, char *element_data, int *claimed);
  183         int     (*mpo_internalize_socket_label)(struct label *label,
  184                     char *element_name, char *element_data, int *claimed);
  185         int     (*mpo_internalize_vnode_label)(struct label *label,
  186                     char *element_name, char *element_data, int *claimed);
  187 
  188         /*
  189          * Labeling event operations: file system objects, and things that
  190          * look a lot like file system objects.
  191          */
  192         void    (*mpo_associate_vnode_devfs)(struct mount *mp,
  193                     struct label *fslabel, struct devfs_dirent *de,
  194                     struct label *delabel, struct vnode *vp,
  195                     struct label *vlabel);
  196         int     (*mpo_associate_vnode_extattr)(struct mount *mp,
  197                     struct label *fslabel, struct vnode *vp,
  198                     struct label *vlabel);
  199         void    (*mpo_associate_vnode_singlelabel)(struct mount *mp,
  200                     struct label *fslabel, struct vnode *vp,
  201                     struct label *vlabel);
  202         void    (*mpo_create_devfs_device)(struct ucred *cred,
  203                     struct mount *mp, struct cdev *dev,
  204                     struct devfs_dirent *de, struct label *label);
  205         void    (*mpo_create_devfs_directory)(struct mount *mp, char *dirname,
  206                     int dirnamelen, struct devfs_dirent *de,
  207                     struct label *label);
  208         void    (*mpo_create_devfs_symlink)(struct ucred *cred,
  209                     struct mount *mp, struct devfs_dirent *dd,
  210                     struct label *ddlabel, struct devfs_dirent *de,
  211                     struct label *delabel);
  212         void    (*_mpo_placeholder5)(void);
  213         int     (*mpo_create_vnode_extattr)(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         void    (*mpo_create_mount)(struct ucred *cred, struct mount *mp,
  219                     struct label *mntlabel, struct label *fslabel);
  220         void    (*mpo_relabel_vnode)(struct ucred *cred, struct vnode *vp,
  221                     struct label *vnodelabel, struct label *label);
  222         int     (*mpo_setlabel_vnode_extattr)(struct ucred *cred,
  223                     struct vnode *vp, struct label *vlabel,
  224                     struct label *intlabel);
  225         void    (*mpo_update_devfsdirent)(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         void    (*mpo_create_mbuf_from_socket)(struct socket *so,
  234                     struct label *socketlabel, struct mbuf *m,
  235                     struct label *mbuflabel);
  236         void    (*mpo_create_socket)(struct ucred *cred, struct socket *so,
  237                     struct label *socketlabel);
  238         void    (*mpo_create_socket_from_socket)(struct socket *oldsocket,
  239                     struct label *oldsocketlabel, struct socket *newsocket,
  240                     struct label *newsocketlabel);
  241         void    (*mpo_relabel_socket)(struct ucred *cred, struct socket *so,
  242                     struct label *oldlabel, struct label *newlabel);
  243         void    (*mpo_relabel_pipe)(struct ucred *cred, struct pipepair *pp,
  244                     struct label *oldlabel, struct label *newlabel);
  245         void    (*mpo_set_socket_peer_from_mbuf)(struct mbuf *mbuf,
  246                     struct label *mbuflabel, struct socket *so,
  247                     struct label *socketpeerlabel);
  248         void    (*mpo_set_socket_peer_from_socket)(struct socket *oldsocket,
  249                     struct label *oldsocketlabel, struct socket *newsocket,
  250                     struct label *newsocketpeerlabel);
  251         void    (*mpo_create_pipe)(struct ucred *cred, struct pipepair *pp,
  252                     struct label *pipelabel);
  253 
  254         /*
  255          * Labeling event operations: System V IPC primitives.
  256          */
  257         void    (*mpo_create_sysv_msgmsg)(struct ucred *cred,
  258                     struct msqid_kernel *msqkptr, struct label *msqlabel,
  259                     struct msg *msgptr, struct label *msglabel);
  260         void    (*mpo_create_sysv_msgqueue)(struct ucred *cred,
  261                     struct msqid_kernel *msqkptr, struct label *msqlabel);
  262         void    (*mpo_create_sysv_sem)(struct ucred *cred,
  263                     struct semid_kernel *semakptr, struct label *semalabel);
  264         void    (*mpo_create_sysv_shm)(struct ucred *cred,
  265                     struct shmid_kernel *shmsegptr, struct label *shmlabel);
  266 
  267         /*
  268          * Labeling event operations: POSIX (global/inter-process) semaphores.
  269          */
  270         void    (*mpo_create_posix_sem)(struct ucred *cred,
  271                     struct ksem *ksemptr, struct label *ks_label);
  272 
  273         /*
  274          * Labeling event operations: network objects.
  275          */
  276         void    (*mpo_create_bpfdesc)(struct ucred *cred, struct bpf_d *bpf_d,
  277                     struct label *bpflabel);
  278         void    (*mpo_create_ifnet)(struct ifnet *ifnet,
  279                     struct label *ifnetlabel);
  280         void    (*mpo_create_inpcb_from_socket)(struct socket *so,
  281                     struct label *solabel, struct inpcb *inp,
  282                     struct label *inplabel);
  283         void    (*mpo_create_ipq)(struct mbuf *fragment,
  284                     struct label *fragmentlabel, struct ipq *ipq,
  285                     struct label *ipqlabel);
  286         void    (*mpo_create_datagram_from_ipq)
  287                     (struct ipq *ipq, struct label *ipqlabel,
  288                     struct mbuf *datagram, struct label *datagramlabel);
  289         void    (*mpo_create_fragment)(struct mbuf *datagram,
  290                     struct label *datagramlabel, struct mbuf *fragment,
  291                     struct label *fragmentlabel);
  292         void    (*mpo_create_mbuf_from_inpcb)(struct inpcb *inp,
  293                     struct label *inplabel, struct mbuf *m,
  294                     struct label *mlabel);
  295         void    (*mpo_create_mbuf_linklayer)(struct ifnet *ifnet,
  296                     struct label *ifnetlabel, struct mbuf *mbuf,
  297                     struct label *mbuflabel);
  298         void    (*mpo_create_mbuf_from_bpfdesc)(struct bpf_d *bpf_d,
  299                     struct label *bpflabel, struct mbuf *mbuf,
  300                     struct label *mbuflabel);
  301         void    (*mpo_create_mbuf_from_ifnet)(struct ifnet *ifnet,
  302                     struct label *ifnetlabel, struct mbuf *mbuf,
  303                     struct label *mbuflabel);
  304         void    (*mpo_create_mbuf_multicast_encap)(struct mbuf *oldmbuf,
  305                     struct label *oldmbuflabel, struct ifnet *ifnet,
  306                     struct label *ifnetlabel, struct mbuf *newmbuf,
  307                     struct label *newmbuflabel);
  308         void    (*mpo_create_mbuf_netlayer)(struct mbuf *oldmbuf,
  309                     struct label *oldmbuflabel, struct mbuf *newmbuf,
  310                     struct label *newmbuflabel);
  311         int     (*mpo_fragment_match)(struct mbuf *fragment,
  312                     struct label *fragmentlabel, struct ipq *ipq,
  313                     struct label *ipqlabel);
  314         void    (*mpo_reflect_mbuf_icmp)(struct mbuf *m,
  315                     struct label *mlabel);
  316         void    (*mpo_reflect_mbuf_tcp)(struct mbuf *m, struct label *mlabel);
  317         void    (*mpo_relabel_ifnet)(struct ucred *cred, struct ifnet *ifnet,
  318                     struct label *ifnetlabel, struct label *newlabel);
  319         void    (*mpo_update_ipq)(struct mbuf *fragment,
  320                     struct label *fragmentlabel, struct ipq *ipq,
  321                     struct label *ipqlabel);
  322         void    (*mpo_inpcb_sosetlabel)(struct socket *so,
  323                     struct label *label, struct inpcb *inp,
  324                     struct label *inplabel);
  325 
  326         /*
  327          * Labeling event operations: processes.
  328          */
  329         void    (*mpo_execve_transition)(struct ucred *old, struct ucred *new,
  330                     struct vnode *vp, struct label *vnodelabel,
  331                     struct label *interpvnodelabel,
  332                     struct image_params *imgp, struct label *execlabel);
  333         int     (*mpo_execve_will_transition)(struct ucred *old,
  334                     struct vnode *vp, struct label *vnodelabel,
  335                     struct label *interpvnodelabel,
  336                     struct image_params *imgp, struct label *execlabel);
  337         void    (*mpo_create_proc0)(struct ucred *cred);
  338         void    (*mpo_create_proc1)(struct ucred *cred);
  339         void    (*mpo_relabel_cred)(struct ucred *cred,
  340                     struct label *newlabel);
  341         void    (*_mpo_placeholder6)(void);
  342         void    (*mpo_thread_userret)(struct thread *thread);
  343 
  344         /*
  345          * Access control checks.
  346          */
  347         int     (*mpo_check_bpfdesc_receive)(struct bpf_d *bpf_d,
  348                     struct label *bpflabel, struct ifnet *ifnet,
  349                     struct label *ifnetlabel);
  350         void    (*_mpo_placeholder7)(void);
  351         int     (*mpo_check_cred_relabel)(struct ucred *cred,
  352                     struct label *newlabel);
  353         int     (*mpo_check_cred_visible)(struct ucred *u1, struct ucred *u2);
  354         void    (*mpo_associate_nfsd_label)(struct ucred *cred);
  355         void    (*mpo_create_mbuf_from_firewall)(struct mbuf *m,
  356                     struct label *label);
  357         void    (*_mpo_placeholder10)(void);
  358         void    (*_mpo_placeholder11)(void);
  359         void    (*_mpo_placeholder12)(void);
  360         void    (*_mpo_placeholder13)(void);
  361         void    (*_mpo_placeholder14)(void);
  362         void    (*_mpo_placeholder15)(void);
  363         void    (*_mpo_placeholder16)(void);
  364         void    (*_mpo_placeholder17)(void);
  365         void    (*_mpo_placeholder18)(void);
  366         int     (*mpo_check_ifnet_relabel)(struct ucred *cred,
  367                     struct ifnet *ifnet, struct label *ifnetlabel,
  368                     struct label *newlabel);
  369         int     (*mpo_check_ifnet_transmit)(struct ifnet *ifnet,
  370                     struct label *ifnetlabel, struct mbuf *m,
  371                     struct label *mbuflabel);
  372         int     (*mpo_check_inpcb_deliver)(struct inpcb *inp,
  373                     struct label *inplabel, struct mbuf *m,
  374                     struct label *mlabel);
  375         int     (*mpo_check_sysv_msgmsq)(struct ucred *cred,
  376                     struct msg *msgptr, struct label *msglabel,
  377                     struct msqid_kernel *msqkptr, struct label *msqklabel);
  378         int     (*mpo_check_sysv_msgrcv)(struct ucred *cred,
  379                     struct msg *msgptr, struct label *msglabel);
  380         int     (*mpo_check_sysv_msgrmid)(struct ucred *cred,
  381                     struct msg *msgptr, struct label *msglabel);
  382         int     (*mpo_check_sysv_msqget)(struct ucred *cred,
  383                     struct msqid_kernel *msqkptr, struct label *msqklabel);
  384         int     (*mpo_check_sysv_msqsnd)(struct ucred *cred,
  385                     struct msqid_kernel *msqkptr, struct label *msqklabel);
  386         int     (*mpo_check_sysv_msqrcv)(struct ucred *cred,
  387                     struct msqid_kernel *msqkptr, struct label *msqklabel);
  388         int     (*mpo_check_sysv_msqctl)(struct ucred *cred,
  389                     struct msqid_kernel *msqkptr, struct label *msqklabel,
  390                     int cmd);
  391         int     (*mpo_check_sysv_semctl)(struct ucred *cred,
  392                     struct semid_kernel *semakptr, struct label *semaklabel,
  393                     int cmd);
  394         int     (*mpo_check_sysv_semget)(struct ucred *cred,
  395                     struct semid_kernel *semakptr, struct label *semaklabel);
  396         int     (*mpo_check_sysv_semop)(struct ucred *cred,
  397                     struct semid_kernel *semakptr, struct label *semaklabel,
  398                     size_t accesstype);
  399         int     (*mpo_check_sysv_shmat)(struct ucred *cred,
  400                     struct shmid_kernel *shmsegptr,
  401                     struct label *shmseglabel, int shmflg);
  402         int     (*mpo_check_sysv_shmctl)(struct ucred *cred,
  403                     struct shmid_kernel *shmsegptr,
  404                     struct label *shmseglabel, int cmd);
  405         int     (*mpo_check_sysv_shmdt)(struct ucred *cred,
  406                     struct shmid_kernel *shmsegptr,
  407                     struct label *shmseglabel);
  408         int     (*mpo_check_sysv_shmget)(struct ucred *cred,
  409                     struct shmid_kernel *shmsegptr,
  410                     struct label *shmseglabel, int shmflg);
  411         int     (*mpo_check_kenv_dump)(struct ucred *cred);
  412         int     (*mpo_check_kenv_get)(struct ucred *cred, char *name);
  413         int     (*mpo_check_kenv_set)(struct ucred *cred, char *name,
  414                     char *value);
  415         int     (*mpo_check_kenv_unset)(struct ucred *cred, char *name);
  416         int     (*mpo_check_kld_load)(struct ucred *cred, struct vnode *vp,
  417                     struct label *vlabel);
  418         int     (*mpo_check_kld_stat)(struct ucred *cred);
  419         int     (*mpo_check_kld_unload)(struct ucred *cred);
  420         void    (*_mpo_placeholder19)(void);
  421         void    (*_mpo_placeholder20)(void);
  422         int     (*mpo_check_mount_stat)(struct ucred *cred, struct mount *mp,
  423                     struct label *mntlabel);
  424         void    (*_mpo_placeholder21)(void);
  425         int     (*mpo_check_pipe_ioctl)(struct ucred *cred,
  426                     struct pipepair *pp, struct label *pipelabel,
  427                     unsigned long cmd, void *data);
  428         int     (*mpo_check_pipe_poll)(struct ucred *cred,
  429                     struct pipepair *pp, struct label *pipelabel);
  430         int     (*mpo_check_pipe_read)(struct ucred *cred,
  431                     struct pipepair *pp, struct label *pipelabel);
  432         int     (*mpo_check_pipe_relabel)(struct ucred *cred,
  433                     struct pipepair *pp, struct label *pipelabel,
  434                     struct label *newlabel);
  435         int     (*mpo_check_pipe_stat)(struct ucred *cred,
  436                     struct pipepair *pp, struct label *pipelabel);
  437         int     (*mpo_check_pipe_write)(struct ucred *cred,
  438                     struct pipepair *pp, struct label *pipelabel);
  439         int     (*mpo_check_posix_sem_destroy)(struct ucred *cred,
  440                     struct ksem *ksemptr, struct label *ks_label);
  441         int     (*mpo_check_posix_sem_getvalue)(struct ucred *cred,
  442                     struct ksem *ksemptr, struct label *ks_label);
  443         int     (*mpo_check_posix_sem_open)(struct ucred *cred,
  444                     struct ksem *ksemptr, struct label *ks_label);
  445         int     (*mpo_check_posix_sem_post)(struct ucred *cred,
  446                     struct ksem *ksemptr, struct label *ks_label);
  447         int     (*mpo_check_posix_sem_unlink)(struct ucred *cred,
  448                     struct ksem *ksemptr, struct label *ks_label);
  449         int     (*mpo_check_posix_sem_wait)(struct ucred *cred,
  450                     struct ksem *ksemptr, struct label *ks_label);
  451         int     (*mpo_check_proc_debug)(struct ucred *cred,
  452                     struct proc *proc);
  453         int     (*mpo_check_proc_sched)(struct ucred *cred,
  454                     struct proc *proc);
  455         int     (*mpo_check_proc_setuid)(struct ucred *cred, uid_t uid);
  456         int     (*mpo_check_proc_seteuid)(struct ucred *cred, uid_t euid);
  457         int     (*mpo_check_proc_setgid)(struct ucred *cred, gid_t gid);
  458         int     (*mpo_check_proc_setegid)(struct ucred *cred, gid_t egid);
  459         int     (*mpo_check_proc_setgroups)(struct ucred *cred, int ngroups,
  460                     gid_t *gidset);
  461         int     (*mpo_check_proc_setreuid)(struct ucred *cred, uid_t ruid,
  462                     uid_t euid);
  463         int     (*mpo_check_proc_setregid)(struct ucred *cred, gid_t rgid,
  464                     gid_t egid);
  465         int     (*mpo_check_proc_setresuid)(struct ucred *cred, uid_t ruid,
  466                     uid_t euid, uid_t suid);
  467         int     (*mpo_check_proc_setresgid)(struct ucred *cred, gid_t rgid,
  468                     gid_t egid, gid_t sgid);
  469         int     (*mpo_check_proc_signal)(struct ucred *cred,
  470                     struct proc *proc, int signum);
  471         int     (*mpo_check_proc_wait)(struct ucred *cred,
  472                     struct proc *proc);
  473         int     (*mpo_check_socket_accept)(struct ucred *cred,
  474                     struct socket *so, struct label *socketlabel);
  475         int     (*mpo_check_socket_bind)(struct ucred *cred,
  476                     struct socket *so, struct label *socketlabel,
  477                     struct sockaddr *sockaddr);
  478         int     (*mpo_check_socket_connect)(struct ucred *cred,
  479                     struct socket *so, struct label *socketlabel,
  480                     struct sockaddr *sockaddr);
  481         int     (*mpo_check_socket_create)(struct ucred *cred, int domain,
  482                     int type, int protocol);
  483         int     (*mpo_check_socket_deliver)(struct socket *so,
  484                     struct label *socketlabel, struct mbuf *m,
  485                     struct label *mbuflabel);
  486         void    (*_mpo_placeholder22)(void);
  487         int     (*mpo_check_socket_listen)(struct ucred *cred,
  488                     struct socket *so, struct label *socketlabel);
  489         int     (*mpo_check_socket_poll)(struct ucred *cred,
  490                     struct socket *so, struct label *socketlabel);
  491         int     (*mpo_check_socket_receive)(struct ucred *cred,
  492                     struct socket *so, struct label *socketlabel);
  493         int     (*mpo_check_socket_relabel)(struct ucred *cred,
  494                     struct socket *so, struct label *socketlabel,
  495                     struct label *newlabel);
  496         int     (*mpo_check_socket_send)(struct ucred *cred,
  497                     struct socket *so, struct label *socketlabel);
  498         int     (*mpo_check_socket_stat)(struct ucred *cred,
  499                     struct socket *so, struct label *socketlabel);
  500         int     (*mpo_check_socket_visible)(struct ucred *cred,
  501                     struct socket *so, struct label *socketlabel);
  502         int     (*mpo_check_sysarch_ioperm)(struct ucred *cred);
  503         int     (*mpo_check_system_acct)(struct ucred *cred,
  504                     struct vnode *vp, struct label *vlabel);
  505         int     (*mpo_check_system_nfsd)(struct ucred *cred);
  506         int     (*mpo_check_system_reboot)(struct ucred *cred, int howto);
  507         int     (*mpo_check_system_settime)(struct ucred *cred);
  508         int     (*mpo_check_system_swapon)(struct ucred *cred,
  509                     struct vnode *vp, struct label *label);
  510         int     (*mpo_check_system_swapoff)(struct ucred *cred,
  511                     struct vnode *vp, struct label *label);
  512         int     (*mpo_check_system_sysctl)(struct ucred *cred,
  513                     struct sysctl_oid *oidp, void *arg1, int arg2,
  514                     struct sysctl_req *req);
  515         void    (*_mpo_placeholder23)(void);
  516         int     (*mpo_check_vnode_access)(struct ucred *cred,
  517                     struct vnode *vp, struct label *label, int acc_mode);
  518         int     (*mpo_check_vnode_chdir)(struct ucred *cred,
  519                     struct vnode *dvp, struct label *dlabel);
  520         int     (*mpo_check_vnode_chroot)(struct ucred *cred,
  521                     struct vnode *dvp, struct label *dlabel);
  522         int     (*mpo_check_vnode_create)(struct ucred *cred,
  523                     struct vnode *dvp, struct label *dlabel,
  524                     struct componentname *cnp, struct vattr *vap);
  525         int     (*mpo_check_vnode_delete)(struct ucred *cred,
  526                     struct vnode *dvp, struct label *dlabel,
  527                     struct vnode *vp, struct label *label,
  528                     struct componentname *cnp);
  529         int     (*mpo_check_vnode_deleteacl)(struct ucred *cred,
  530                     struct vnode *vp, struct label *label, acl_type_t type);
  531         int     (*mpo_check_vnode_deleteextattr)(struct ucred *cred,
  532                     struct vnode *vp, struct label *label, int attrnamespace,
  533                     const char *name);
  534         int     (*mpo_check_vnode_exec)(struct ucred *cred, struct vnode *vp,
  535                     struct label *label, struct image_params *imgp,
  536                     struct label *execlabel);
  537         int     (*mpo_check_vnode_getacl)(struct ucred *cred,
  538                     struct vnode *vp, struct label *label, acl_type_t type);
  539         int     (*mpo_check_vnode_getextattr)(struct ucred *cred,
  540                     struct vnode *vp, struct label *label, int attrnamespace,
  541                     const char *name, struct uio *uio);
  542         void    (*_mpo_placeholder24)(void);
  543         int     (*mpo_check_vnode_link)(struct ucred *cred, struct vnode *dvp,
  544                     struct label *dlabel, struct vnode *vp,
  545                     struct label *label, struct componentname *cnp);
  546         int     (*mpo_check_vnode_listextattr)(struct ucred *cred,
  547                     struct vnode *vp, struct label *label, int attrnamespace);
  548         int     (*mpo_check_vnode_lookup)(struct ucred *cred,
  549                     struct vnode *dvp, struct label *dlabel,
  550                     struct componentname *cnp);
  551         int     (*mpo_check_vnode_mmap)(struct ucred *cred, struct vnode *vp,
  552                     struct label *label, int prot, int flags);
  553         void    (*mpo_check_vnode_mmap_downgrade)(struct ucred *cred,
  554                     struct vnode *vp, struct label *label, int *prot);
  555         int     (*mpo_check_vnode_mprotect)(struct ucred *cred,
  556                     struct vnode *vp, struct label *label, int prot);
  557         int     (*mpo_check_vnode_open)(struct ucred *cred, struct vnode *vp,
  558                     struct label *label, int acc_mode);
  559         int     (*mpo_check_vnode_poll)(struct ucred *active_cred,
  560                     struct ucred *file_cred, struct vnode *vp,
  561                     struct label *label);
  562         int     (*mpo_check_vnode_read)(struct ucred *active_cred,
  563                     struct ucred *file_cred, struct vnode *vp,
  564                     struct label *label);
  565         int     (*mpo_check_vnode_readdir)(struct ucred *cred,
  566                     struct vnode *dvp, struct label *dlabel);
  567         int     (*mpo_check_vnode_readlink)(struct ucred *cred,
  568                     struct vnode *vp, struct label *label);
  569         int     (*mpo_check_vnode_relabel)(struct ucred *cred,
  570                     struct vnode *vp, struct label *vnodelabel,
  571                     struct label *newlabel);
  572         int     (*mpo_check_vnode_rename_from)(struct ucred *cred,
  573                     struct vnode *dvp, struct label *dlabel, struct vnode *vp,
  574                     struct label *label, struct componentname *cnp);
  575         int     (*mpo_check_vnode_rename_to)(struct ucred *cred,
  576                     struct vnode *dvp, struct label *dlabel, struct vnode *vp,
  577                     struct label *label, int samedir,
  578                     struct componentname *cnp);
  579         int     (*mpo_check_vnode_revoke)(struct ucred *cred,
  580                     struct vnode *vp, struct label *label);
  581         int     (*mpo_check_vnode_setacl)(struct ucred *cred,
  582                     struct vnode *vp, struct label *label, acl_type_t type,
  583                     struct acl *acl);
  584         int     (*mpo_check_vnode_setextattr)(struct ucred *cred,
  585                     struct vnode *vp, struct label *label, int attrnamespace,
  586                     const char *name, struct uio *uio);
  587         int     (*mpo_check_vnode_setflags)(struct ucred *cred,
  588                     struct vnode *vp, struct label *label, u_long flags);
  589         int     (*mpo_check_vnode_setmode)(struct ucred *cred,
  590                     struct vnode *vp, struct label *label, mode_t mode);
  591         int     (*mpo_check_vnode_setowner)(struct ucred *cred,
  592                     struct vnode *vp, struct label *label, uid_t uid,
  593                     gid_t gid);
  594         int     (*mpo_check_vnode_setutimes)(struct ucred *cred,
  595                     struct vnode *vp, struct label *label,
  596                     struct timespec atime, struct timespec mtime);
  597         int     (*mpo_check_vnode_stat)(struct ucred *active_cred,
  598                     struct ucred *file_cred, struct vnode *vp,
  599                     struct label *label);
  600         int     (*mpo_check_vnode_write)(struct ucred *active_cred,
  601                     struct ucred *file_cred, struct vnode *vp,
  602                     struct label *label);
  603 };
  604 
  605 /*
  606  * struct mac_policy_conf is the registration structure for policies, and is
  607  * provided to the MAC Framework using MAC_POLICY_SET() to invoke a SYSINIT
  608  * to register the policy.  In general, the fields are immutable, with the
  609  * exception of the "security field", run-time flags, and policy list entry,
  610  * which are managed by the MAC Framework.  Be careful when modifying this
  611  * structure, as its layout is statically compiled into all policies.
  612  */
  613 struct mac_policy_conf {
  614         char                            *mpc_name;      /* policy name */
  615         char                            *mpc_fullname;  /* policy full name */
  616         struct mac_policy_ops           *mpc_ops;       /* policy operations */
  617         int                              mpc_loadtime_flags;    /* flags */
  618         int                             *mpc_field_off; /* security field */
  619         int                              mpc_runtime_flags; /* flags */
  620         LIST_ENTRY(mac_policy_conf)      mpc_list;      /* global list */
  621 };
  622 
  623 /* Flags for the mpc_loadtime_flags field. */
  624 #define MPC_LOADTIME_FLAG_NOTLATE       0x00000001
  625 #define MPC_LOADTIME_FLAG_UNLOADOK      0x00000002
  626 #define MPC_LOADTIME_FLAG_LABELMBUFS    0x00000004
  627 
  628 /* Flags for the mpc_runtime_flags field. */
  629 #define MPC_RUNTIME_FLAG_REGISTERED     0x00000001
  630 
  631 #define MAC_POLICY_SET(mpops, mpname, mpfullname, mpflags, privdata_wanted) \
  632         static struct mac_policy_conf mpname##_mac_policy_conf = {      \
  633                 #mpname,                                                \
  634                 mpfullname,                                             \
  635                 mpops,                                                  \
  636                 mpflags,                                                \
  637                 privdata_wanted,                                        \
  638                 0,                                                      \
  639         };                                                              \
  640         static moduledata_t mpname##_mod = {                            \
  641                 #mpname,                                                \
  642                 mac_policy_modevent,                                    \
  643                 &mpname##_mac_policy_conf                               \
  644         };                                                              \
  645         MODULE_DEPEND(mpname, kernel_mac_support, 2, 2, 2);             \
  646         DECLARE_MODULE(mpname, mpname##_mod, SI_SUB_MAC_POLICY,         \
  647             SI_ORDER_MIDDLE)
  648 
  649 int     mac_policy_modevent(module_t mod, int type, void *data);
  650 
  651 #define LABEL_TO_SLOT(l, s)     (l)->l_perpolicy[s]
  652 
  653 #endif /* !_SYS_MAC_POLICY_H_ */

Cache object: ee8f7ae0a97a40122185b7c88b740330


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.