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-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999-2002 Robert N. M. Watson
    3  * Copyright (c) 2001-2004 Networks Associates Technology, Inc.
    4  * All rights reserved.
    5  *
    6  * This software was developed by Robert Watson for the TrustedBSD Project.
    7  *
    8  * This software was developed for the FreeBSD Project in part by Network
    9  * Associates Laboratories, the Security Research Division of Network
   10  * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"),
   11  * as part of the DARPA CHATS research program.
   12  *
   13  * Redistribution and use in source and binary forms, with or without
   14  * modification, are permitted provided that the following conditions
   15  * are met:
   16  * 1. Redistributions of source code must retain the above copyright
   17  *    notice, this list of conditions and the following disclaimer.
   18  * 2. Redistributions in binary form must reproduce the above copyright
   19  *    notice, this list of conditions and the following disclaimer in the
   20  *    documentation and/or other materials provided with the distribution.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  *
   34  * $FreeBSD$
   35  */
   36 /*
   37  * Kernel interface for MAC policy modules.
   38  */
   39 #ifndef _SYS_MAC_POLICY_H_
   40 #define _SYS_MAC_POLICY_H_
   41 
   42 /*-
   43  * Pluggable access control policy definition structure.
   44  *
   45  * List of operations that are performed as part of the implementation
   46  * of a MAC policy.  Policy implementors declare operations with a
   47  * mac_policy_ops structure, and using the MAC_POLICY_SET() macro.
   48  * If an entry point is not declared, then then the policy will be ignored
   49  * during evaluation of that event or check.
   50  *
   51  * Operations are sorted first by general class of operation, then
   52  * alphabetically.
   53  */
   54 struct acl;
   55 struct bpf_d;
   56 struct componentname;
   57 struct devfs_dirent;
   58 struct ifnet;
   59 struct image_params;
   60 struct inpcb;
   61 struct ipq;
   62 struct label;
   63 struct mac_policy_conf;
   64 struct mbuf;
   65 struct mount;
   66 struct pipepair;
   67 struct proc;
   68 struct sbuf;
   69 struct sockaddr;
   70 struct socket;
   71 struct sysctl_oid;
   72 struct sysctl_req;
   73 struct thread;
   74 struct ucred;
   75 struct uio;
   76 struct vattr;
   77 struct vnode;
   78 struct mac_policy_ops {
   79         /*
   80          * Policy module operations.
   81          */
   82         void    (*mpo_destroy)(struct mac_policy_conf *mpc);
   83         void    (*mpo_init)(struct mac_policy_conf *mpc);
   84 
   85         /*
   86          * General policy-directed security system call so that policies may
   87          * implement new services without reserving explicit system call
   88          * numbers.
   89          */
   90         int     (*mpo_syscall)(struct thread *td, int call, void *arg);
   91 
   92         /*
   93          * Label operations.  Initialize label storage, destroy label
   94          * storage, recycle for re-use without init/destroy, copy a label to
   95          * initialized storage, and externalize/internalize from/to
   96          * initialized storage.
   97          */
   98         void    (*mpo_init_bpfdesc_label)(struct label *label);
   99         void    (*mpo_init_cred_label)(struct label *label);
  100         void    (*mpo_init_devfsdirent_label)(struct label *label);
  101         void    (*mpo_init_ifnet_label)(struct label *label);
  102         int     (*mpo_init_inpcb_label)(struct label *label, int flag);
  103         int     (*mpo_init_ipq_label)(struct label *label, int flag);
  104         int     (*mpo_init_mbuf_label)(struct label *label, int flag);
  105         void    (*mpo_init_mount_label)(struct label *label);
  106         void    (*mpo_init_mount_fs_label)(struct label *label);
  107         int     (*mpo_init_socket_label)(struct label *label, int flag);
  108         int     (*mpo_init_socket_peer_label)(struct label *label, int flag);
  109         void    (*mpo_init_pipe_label)(struct label *label);
  110         void    (*mpo_init_proc_label)(struct label *label);
  111         void    (*mpo_init_vnode_label)(struct label *label);
  112         void    (*mpo_destroy_bpfdesc_label)(struct label *label);
  113         void    (*mpo_destroy_cred_label)(struct label *label);
  114         void    (*mpo_destroy_devfsdirent_label)(struct label *label);
  115         void    (*mpo_destroy_ifnet_label)(struct label *label);
  116         void    (*mpo_destroy_inpcb_label)(struct label *label);
  117         void    (*mpo_destroy_ipq_label)(struct label *label);
  118         void    (*mpo_destroy_mbuf_label)(struct label *label);
  119         void    (*mpo_destroy_mount_label)(struct label *label);
  120         void    (*mpo_destroy_mount_fs_label)(struct label *label);
  121         void    (*mpo_destroy_socket_label)(struct label *label);
  122         void    (*mpo_destroy_socket_peer_label)(struct label *label);
  123         void    (*mpo_destroy_pipe_label)(struct label *label);
  124         void    (*mpo_destroy_proc_label)(struct label *label);
  125         void    (*mpo_destroy_vnode_label)(struct label *label);
  126         void    (*mpo_copy_cred_label)(struct label *src,
  127                     struct label *dest);
  128         void    (*mpo_copy_ifnet_label)(struct label *src,
  129                     struct label *dest);
  130         void    (*mpo_copy_mbuf_label)(struct label *src,
  131                     struct label *dest);
  132         void    (*mpo_copy_pipe_label)(struct label *src,
  133                     struct label *dest);
  134         void    (*mpo_copy_socket_label)(struct label *src,
  135                     struct label *dest);
  136         void    (*mpo_copy_vnode_label)(struct label *src,
  137                     struct label *dest);
  138         int     (*mpo_externalize_cred_label)(struct label *label,
  139                     char *element_name, struct sbuf *sb, int *claimed);
  140         int     (*mpo_externalize_ifnet_label)(struct label *label,
  141                     char *element_name, struct sbuf *sb, int *claimed);
  142         int     (*mpo_externalize_pipe_label)(struct label *label,
  143                     char *element_name, struct sbuf *sb, int *claimed);
  144         int     (*mpo_externalize_socket_label)(struct label *label,
  145                     char *element_name, struct sbuf *sb, int *claimed);
  146         int     (*mpo_externalize_socket_peer_label)(struct label *label,
  147                     char *element_name, struct sbuf *sb, int *claimed);
  148         int     (*mpo_externalize_vnode_label)(struct label *label,
  149                     char *element_name, struct sbuf *sb, int *claimed);
  150         int     (*mpo_internalize_cred_label)(struct label *label,
  151                     char *element_name, char *element_data, int *claimed);
  152         int     (*mpo_internalize_ifnet_label)(struct label *label,
  153                     char *element_name, char *element_data, int *claimed);
  154         int     (*mpo_internalize_pipe_label)(struct label *label,
  155                     char *element_name, char *element_data, int *claimed);
  156         int     (*mpo_internalize_socket_label)(struct label *label,
  157                     char *element_name, char *element_data, int *claimed);
  158         int     (*mpo_internalize_vnode_label)(struct label *label,
  159                     char *element_name, char *element_data, int *claimed);
  160 
  161         /*
  162          * Labeling event operations: file system objects, and things that
  163          * look a lot like file system objects.
  164          */
  165         void    (*mpo_associate_vnode_devfs)(struct mount *mp,
  166                     struct label *fslabel, struct devfs_dirent *de,
  167                     struct label *delabel, struct vnode *vp,
  168                     struct label *vlabel);
  169         int     (*mpo_associate_vnode_extattr)(struct mount *mp,
  170                     struct label *fslabel, struct vnode *vp,
  171                     struct label *vlabel);
  172         void    (*mpo_associate_vnode_singlelabel)(struct mount *mp,
  173                     struct label *fslabel, struct vnode *vp,
  174                     struct label *vlabel);
  175         void    (*mpo_create_devfs_device)(struct mount *mp, struct cdev *dev,
  176                     struct devfs_dirent *de, struct label *label);
  177         void    (*mpo_create_devfs_directory)(struct mount *mp, char *dirname,
  178                     int dirnamelen, struct devfs_dirent *de,
  179                     struct label *label);
  180         void    (*mpo_create_devfs_symlink)(struct ucred *cred,
  181                     struct mount *mp, struct devfs_dirent *dd,
  182                     struct label *ddlabel, struct devfs_dirent *de,
  183                     struct label *delabel);
  184         int     (*mpo_create_vnode_extattr)(struct ucred *cred,
  185                     struct mount *mp, struct label *fslabel,
  186                     struct vnode *dvp, struct label *dlabel,
  187                     struct vnode *vp, struct label *vlabel,
  188                     struct componentname *cnp);
  189         void    (*mpo_create_mount)(struct ucred *cred, struct mount *mp,
  190                     struct label *mntlabel, struct label *fslabel);
  191         void    (*mpo_create_root_mount)(struct ucred *cred, struct mount *mp,
  192                     struct label *mountlabel, struct label *fslabel);
  193         void    (*mpo_relabel_vnode)(struct ucred *cred, struct vnode *vp,
  194                     struct label *vnodelabel, struct label *label);
  195         int     (*mpo_setlabel_vnode_extattr)(struct ucred *cred,
  196                     struct vnode *vp, struct label *vlabel,
  197                     struct label *intlabel);
  198         void    (*mpo_update_devfsdirent)(struct mount *mp,
  199                     struct devfs_dirent *devfs_dirent,
  200                     struct label *direntlabel, struct vnode *vp,
  201                     struct label *vnodelabel);
  202 
  203         /*
  204          * Labeling event operations: IPC objects.
  205          */
  206         void    (*mpo_create_mbuf_from_socket)(struct socket *so,
  207                     struct label *socketlabel, struct mbuf *m,
  208                     struct label *mbuflabel);
  209         void    (*mpo_create_socket)(struct ucred *cred, struct socket *so,
  210                     struct label *socketlabel);
  211         void    (*mpo_create_socket_from_socket)(struct socket *oldsocket,
  212                     struct label *oldsocketlabel, struct socket *newsocket,
  213                     struct label *newsocketlabel);
  214         void    (*mpo_relabel_socket)(struct ucred *cred, struct socket *so,
  215                     struct label *oldlabel, struct label *newlabel);
  216         void    (*mpo_relabel_pipe)(struct ucred *cred, struct pipepair *pp,
  217                     struct label *oldlabel, struct label *newlabel);
  218         void    (*mpo_set_socket_peer_from_mbuf)(struct mbuf *mbuf,
  219                     struct label *mbuflabel, struct socket *so,
  220                     struct label *socketpeerlabel);
  221         void    (*mpo_set_socket_peer_from_socket)(struct socket *oldsocket,
  222                     struct label *oldsocketlabel, struct socket *newsocket,
  223                     struct label *newsocketpeerlabel);
  224         void    (*mpo_create_pipe)(struct ucred *cred, struct pipepair *pp,
  225                     struct label *pipelabel);
  226 
  227         /*
  228          * Labeling event operations: network objects.
  229          */
  230         void    (*mpo_create_bpfdesc)(struct ucred *cred, struct bpf_d *bpf_d,
  231                     struct label *bpflabel);
  232         void    (*mpo_create_ifnet)(struct ifnet *ifnet,
  233                     struct label *ifnetlabel);
  234         void    (*mpo_create_inpcb_from_socket)(struct socket *so,
  235                     struct label *solabel, struct inpcb *inp,
  236                     struct label *inplabel);
  237         void    (*mpo_create_ipq)(struct mbuf *fragment,
  238                     struct label *fragmentlabel, struct ipq *ipq,
  239                     struct label *ipqlabel);
  240         void    (*mpo_create_datagram_from_ipq)
  241                     (struct ipq *ipq, struct label *ipqlabel,
  242                     struct mbuf *datagram, struct label *datagramlabel);
  243         void    (*mpo_create_fragment)(struct mbuf *datagram,
  244                     struct label *datagramlabel, struct mbuf *fragment,
  245                     struct label *fragmentlabel);
  246         void    (*mpo_create_mbuf_from_inpcb)(struct inpcb *inp,
  247                     struct label *inplabel, struct mbuf *m,
  248                     struct label *mlabel);
  249         void    (*mpo_create_mbuf_from_mbuf)(struct mbuf *oldmbuf,
  250                     struct label *oldlabel, struct mbuf *newmbuf,
  251                     struct label *newlabel);
  252         void    (*mpo_create_mbuf_linklayer)(struct ifnet *ifnet,
  253                     struct label *ifnetlabel, struct mbuf *mbuf,
  254                     struct label *mbuflabel);
  255         void    (*mpo_create_mbuf_from_bpfdesc)(struct bpf_d *bpf_d,
  256                     struct label *bpflabel, struct mbuf *mbuf,
  257                     struct label *mbuflabel);
  258         void    (*mpo_create_mbuf_from_ifnet)(struct ifnet *ifnet,
  259                     struct label *ifnetlabel, struct mbuf *mbuf,
  260                     struct label *mbuflabel);
  261         void    (*mpo_create_mbuf_multicast_encap)(struct mbuf *oldmbuf,
  262                     struct label *oldmbuflabel, struct ifnet *ifnet,
  263                     struct label *ifnetlabel, struct mbuf *newmbuf,
  264                     struct label *newmbuflabel);
  265         void    (*mpo_create_mbuf_netlayer)(struct mbuf *oldmbuf,
  266                     struct label *oldmbuflabel, struct mbuf *newmbuf,
  267                     struct label *newmbuflabel);
  268         int     (*mpo_fragment_match)(struct mbuf *fragment,
  269                     struct label *fragmentlabel, struct ipq *ipq,
  270                     struct label *ipqlabel);
  271         void    (*mpo_reflect_mbuf_icmp)(struct mbuf *m,
  272                     struct label *mlabel);
  273         void    (*mpo_reflect_mbuf_tcp)(struct mbuf *m, struct label *mlabel);
  274         void    (*mpo_relabel_ifnet)(struct ucred *cred, struct ifnet *ifnet,
  275                     struct label *ifnetlabel, struct label *newlabel);
  276         void    (*mpo_update_ipq)(struct mbuf *fragment,
  277                     struct label *fragmentlabel, struct ipq *ipq,
  278                     struct label *ipqlabel);
  279         void    (*mpo_inpcb_sosetlabel)(struct socket *so,
  280                     struct label *label, struct inpcb *inp,
  281                     struct label *inplabel);
  282 
  283         /*
  284          * Labeling event operations: processes.
  285          */
  286         void    (*mpo_execve_transition)(struct ucred *old, struct ucred *new,
  287                     struct vnode *vp, struct label *vnodelabel,
  288                     struct label *interpvnodelabel,
  289                     struct image_params *imgp, struct label *execlabel);
  290         int     (*mpo_execve_will_transition)(struct ucred *old,
  291                     struct vnode *vp, struct label *vnodelabel,
  292                     struct label *interpvnodelabel,
  293                     struct image_params *imgp, struct label *execlabel);
  294         void    (*mpo_create_proc0)(struct ucred *cred);
  295         void    (*mpo_create_proc1)(struct ucred *cred);
  296         void    (*mpo_relabel_cred)(struct ucred *cred,
  297                     struct label *newlabel);
  298         void    (*mpo_thread_userret)(struct thread *thread);
  299 
  300         /*
  301          * Access control checks.
  302          */
  303         int     (*mpo_check_bpfdesc_receive)(struct bpf_d *bpf_d,
  304                     struct label *bpflabel, struct ifnet *ifnet,
  305                     struct label *ifnetlabel);
  306         int     (*mpo_check_cred_relabel)(struct ucred *cred,
  307                     struct label *newlabel);
  308         int     (*mpo_check_cred_visible)(struct ucred *u1, struct ucred *u2);
  309         int     (*mpo_check_ifnet_relabel)(struct ucred *cred,
  310                     struct ifnet *ifnet, struct label *ifnetlabel,
  311                     struct label *newlabel);
  312         int     (*mpo_check_ifnet_transmit)(struct ifnet *ifnet,
  313                     struct label *ifnetlabel, struct mbuf *m,
  314                     struct label *mbuflabel);
  315         int     (*mpo_check_inpcb_deliver)(struct inpcb *inp,
  316                     struct label *inplabel, struct mbuf *m,
  317                     struct label *mlabel);
  318         int     (*mpo_check_kenv_dump)(struct ucred *cred);
  319         int     (*mpo_check_kenv_get)(struct ucred *cred, char *name);
  320         int     (*mpo_check_kenv_set)(struct ucred *cred, char *name,
  321                     char *value);
  322         int     (*mpo_check_kenv_unset)(struct ucred *cred, char *name);
  323         int     (*mpo_check_kld_load)(struct ucred *cred, struct vnode *vp,
  324                     struct label *vlabel);
  325         int     (*mpo_check_kld_stat)(struct ucred *cred);
  326         int     (*mpo_check_kld_unload)(struct ucred *cred);
  327         int     (*mpo_check_mount_stat)(struct ucred *cred, struct mount *mp,
  328                     struct label *mntlabel);
  329         int     (*mpo_check_pipe_ioctl)(struct ucred *cred,
  330                     struct pipepair *pp, struct label *pipelabel,
  331                     unsigned long cmd, void *data);
  332         int     (*mpo_check_pipe_poll)(struct ucred *cred,
  333                     struct pipepair *pp, struct label *pipelabel);
  334         int     (*mpo_check_pipe_read)(struct ucred *cred,
  335                     struct pipepair *pp, struct label *pipelabel);
  336         int     (*mpo_check_pipe_relabel)(struct ucred *cred,
  337                     struct pipepair *pp, struct label *pipelabel,
  338                     struct label *newlabel);
  339         int     (*mpo_check_pipe_stat)(struct ucred *cred,
  340                     struct pipepair *pp, struct label *pipelabel);
  341         int     (*mpo_check_pipe_write)(struct ucred *cred,
  342                     struct pipepair *pp, struct label *pipelabel);
  343         int     (*mpo_check_proc_debug)(struct ucred *cred,
  344                     struct proc *proc);
  345         int     (*mpo_check_proc_sched)(struct ucred *cred,
  346                     struct proc *proc);
  347         int     (*mpo_check_proc_signal)(struct ucred *cred,
  348                     struct proc *proc, int signum);
  349         int     (*mpo_check_socket_bind)(struct ucred *cred,
  350                     struct socket *so, struct label *socketlabel,
  351                     struct sockaddr *sockaddr);
  352         int     (*mpo_check_socket_connect)(struct ucred *cred,
  353                     struct socket *so, struct label *socketlabel,
  354                     struct sockaddr *sockaddr);
  355         int     (*mpo_check_socket_deliver)(struct socket *so,
  356                     struct label *socketlabel, struct mbuf *m,
  357                     struct label *mbuflabel);
  358         int     (*mpo_check_socket_listen)(struct ucred *cred,
  359                     struct socket *so, struct label *socketlabel);
  360         int     (*mpo_check_socket_receive)(struct ucred *cred,
  361                     struct socket *so, struct label *socketlabel);
  362         int     (*mpo_check_socket_relabel)(struct ucred *cred,
  363                     struct socket *so, struct label *socketlabel,
  364                     struct label *newlabel);
  365         int     (*mpo_check_socket_send)(struct ucred *cred,
  366                     struct socket *so, struct label *socketlabel);
  367         int     (*mpo_check_socket_visible)(struct ucred *cred,
  368                     struct socket *so, struct label *socketlabel);
  369         int     (*mpo_check_sysarch_ioperm)(struct ucred *cred);
  370         int     (*mpo_check_system_acct)(struct ucred *cred,
  371                     struct vnode *vp, struct label *vlabel);
  372         int     (*mpo_check_system_nfsd)(struct ucred *cred);
  373         int     (*mpo_check_system_reboot)(struct ucred *cred, int howto);
  374         int     (*mpo_check_system_settime)(struct ucred *cred);
  375         int     (*mpo_check_system_swapon)(struct ucred *cred,
  376                     struct vnode *vp, struct label *label);
  377         int     (*mpo_check_system_swapoff)(struct ucred *cred,
  378                     struct vnode *vp, struct label *label);
  379         int     (*mpo_check_system_sysctl)(struct ucred *cred,
  380                     struct sysctl_oid *oidp, void *arg1, int arg2,
  381                     struct sysctl_req *req);
  382         int     (*mpo_check_vnode_access)(struct ucred *cred,
  383                     struct vnode *vp, struct label *label, int acc_mode);
  384         int     (*mpo_check_vnode_chdir)(struct ucred *cred,
  385                     struct vnode *dvp, struct label *dlabel);
  386         int     (*mpo_check_vnode_chroot)(struct ucred *cred,
  387                     struct vnode *dvp, struct label *dlabel);
  388         int     (*mpo_check_vnode_create)(struct ucred *cred,
  389                     struct vnode *dvp, struct label *dlabel,
  390                     struct componentname *cnp, struct vattr *vap);
  391         int     (*mpo_check_vnode_delete)(struct ucred *cred,
  392                     struct vnode *dvp, struct label *dlabel,
  393                     struct vnode *vp, struct label *label,
  394                     struct componentname *cnp);
  395         int     (*mpo_check_vnode_deleteacl)(struct ucred *cred,
  396                     struct vnode *vp, struct label *label, acl_type_t type);
  397         int     (*mpo_check_vnode_deleteextattr)(struct ucred *cred,
  398                     struct vnode *vp, struct label *label, int attrnamespace,
  399                     const char *name);
  400         int     (*mpo_check_vnode_exec)(struct ucred *cred, struct vnode *vp,
  401                     struct label *label, struct image_params *imgp,
  402                     struct label *execlabel);
  403         int     (*mpo_check_vnode_getacl)(struct ucred *cred,
  404                     struct vnode *vp, struct label *label, acl_type_t type);
  405         int     (*mpo_check_vnode_getextattr)(struct ucred *cred,
  406                     struct vnode *vp, struct label *label, int attrnamespace,
  407                     const char *name, struct uio *uio);
  408         int     (*mpo_check_vnode_link)(struct ucred *cred, struct vnode *dvp,
  409                     struct label *dlabel, struct vnode *vp,
  410                     struct label *label, struct componentname *cnp);
  411         int     (*mpo_check_vnode_listextattr)(struct ucred *cred,
  412                     struct vnode *vp, struct label *label, int attrnamespace);
  413         int     (*mpo_check_vnode_lookup)(struct ucred *cred,
  414                     struct vnode *dvp, struct label *dlabel,
  415                     struct componentname *cnp);
  416         int     (*mpo_check_vnode_mmap)(struct ucred *cred, struct vnode *vp,
  417                     struct label *label, int prot, int flags);
  418         void    (*mpo_check_vnode_mmap_downgrade)(struct ucred *cred,
  419                     struct vnode *vp, struct label *label, int *prot);
  420         int     (*mpo_check_vnode_mprotect)(struct ucred *cred,
  421                     struct vnode *vp, struct label *label, int prot);
  422         int     (*mpo_check_vnode_open)(struct ucred *cred, struct vnode *vp,
  423                     struct label *label, int acc_mode);
  424         int     (*mpo_check_vnode_poll)(struct ucred *active_cred,
  425                     struct ucred *file_cred, struct vnode *vp,
  426                     struct label *label);
  427         int     (*mpo_check_vnode_read)(struct ucred *active_cred,
  428                     struct ucred *file_cred, struct vnode *vp,
  429                     struct label *label);
  430         int     (*mpo_check_vnode_readdir)(struct ucred *cred,
  431                     struct vnode *dvp, struct label *dlabel);
  432         int     (*mpo_check_vnode_readlink)(struct ucred *cred,
  433                     struct vnode *vp, struct label *label);
  434         int     (*mpo_check_vnode_relabel)(struct ucred *cred,
  435                     struct vnode *vp, struct label *vnodelabel,
  436                     struct label *newlabel);
  437         int     (*mpo_check_vnode_rename_from)(struct ucred *cred,
  438                     struct vnode *dvp, struct label *dlabel, struct vnode *vp,
  439                     struct label *label, struct componentname *cnp);
  440         int     (*mpo_check_vnode_rename_to)(struct ucred *cred,
  441                     struct vnode *dvp, struct label *dlabel, struct vnode *vp,
  442                     struct label *label, int samedir,
  443                     struct componentname *cnp);
  444         int     (*mpo_check_vnode_revoke)(struct ucred *cred,
  445                     struct vnode *vp, struct label *label);
  446         int     (*mpo_check_vnode_setacl)(struct ucred *cred,
  447                     struct vnode *vp, struct label *label, acl_type_t type,
  448                     struct acl *acl);
  449         int     (*mpo_check_vnode_setextattr)(struct ucred *cred,
  450                     struct vnode *vp, struct label *label, int attrnamespace,
  451                     const char *name, struct uio *uio);
  452         int     (*mpo_check_vnode_setflags)(struct ucred *cred,
  453                     struct vnode *vp, struct label *label, u_long flags);
  454         int     (*mpo_check_vnode_setmode)(struct ucred *cred,
  455                     struct vnode *vp, struct label *label, mode_t mode);
  456         int     (*mpo_check_vnode_setowner)(struct ucred *cred,
  457                     struct vnode *vp, struct label *label, uid_t uid,
  458                     gid_t gid);
  459         int     (*mpo_check_vnode_setutimes)(struct ucred *cred,
  460                     struct vnode *vp, struct label *label,
  461                     struct timespec atime, struct timespec mtime);
  462         int     (*mpo_check_vnode_stat)(struct ucred *active_cred,
  463                     struct ucred *file_cred, struct vnode *vp,
  464                     struct label *label);
  465         int     (*mpo_check_vnode_write)(struct ucred *active_cred,
  466                     struct ucred *file_cred, struct vnode *vp,
  467                     struct label *label);
  468 };
  469 
  470 /*
  471  * struct mac_policy_conf is the registration structure for policies, and is
  472  * provided to the MAC Framework using MAC_POLICY_SET() to invoke a SYSINIT
  473  * to register the policy.  In general, the fields are immutable, with the
  474  * exception of the "security field", run-time flags, and policy list entry,
  475  * which are managed by the MAC Framework.  Be careful when modifying this
  476  * structure, as its layout is statically compiled into all policies.
  477  */
  478 struct mac_policy_conf {
  479         char                            *mpc_name;      /* policy name */
  480         char                            *mpc_fullname;  /* policy full name */
  481         struct mac_policy_ops           *mpc_ops;       /* policy operations */
  482         int                              mpc_loadtime_flags;    /* flags */
  483         int                             *mpc_field_off; /* security field */
  484         int                              mpc_runtime_flags; /* flags */
  485         LIST_ENTRY(mac_policy_conf)      mpc_list;      /* global list */
  486 };
  487 
  488 /* Flags for the mpc_loadtime_flags field. */
  489 #define MPC_LOADTIME_FLAG_NOTLATE       0x00000001
  490 #define MPC_LOADTIME_FLAG_UNLOADOK      0x00000002
  491 #define MPC_LOADTIME_FLAG_LABELMBUFS    0x00000004
  492 
  493 /* Flags for the mpc_runtime_flags field. */
  494 #define MPC_RUNTIME_FLAG_REGISTERED     0x00000001
  495 
  496 #define MAC_POLICY_SET(mpops, mpname, mpfullname, mpflags, privdata_wanted) \
  497         static struct mac_policy_conf mpname##_mac_policy_conf = {      \
  498                 #mpname,                                                \
  499                 mpfullname,                                             \
  500                 mpops,                                                  \
  501                 mpflags,                                                \
  502                 privdata_wanted,                                        \
  503                 0,                                                      \
  504         };                                                              \
  505         static moduledata_t mpname##_mod = {                            \
  506                 #mpname,                                                \
  507                 mac_policy_modevent,                                    \
  508                 &mpname##_mac_policy_conf                               \
  509         };                                                              \
  510         MODULE_DEPEND(mpname, kernel_mac_support, 1, 1, 1);             \
  511         DECLARE_MODULE(mpname, mpname##_mod, SI_SUB_MAC_POLICY,         \
  512             SI_ORDER_MIDDLE)
  513 
  514 int     mac_policy_modevent(module_t mod, int type, void *data);
  515 
  516 #define LABEL_TO_SLOT(l, s)     (l)->l_perpolicy[s]
  517 
  518 #endif /* !_SYS_MAC_POLICY_H_ */

Cache object: 511ffe7414b3fd30ef20cdcae5ed4414


[ 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.