mac_stub.c revision 145147
1/*- 2 * Copyright (c) 1999-2002 Robert N. M. Watson 3 * Copyright (c) 2001-2005 McAfee, 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 McAfee 9 * Research, the Security Research Division of McAfee, Inc. under 10 * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA 11 * CHATS research program. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $FreeBSD: head/sys/security/mac_stub/mac_stub.c 145147 2005-04-16 13:29:15Z rwatson $ 35 */ 36 37/* 38 * Developed by the TrustedBSD Project. 39 * 40 * Stub module that implements a NOOP for most (if not all) MAC Framework 41 * policy entry points. 42 */ 43 44#include <sys/types.h> 45#include <sys/param.h> 46#include <sys/acl.h> 47#include <sys/conf.h> 48#include <sys/extattr.h> 49#include <sys/kernel.h> 50#include <sys/mac.h> 51#include <sys/mount.h> 52#include <sys/proc.h> 53#include <sys/systm.h> 54#include <sys/sysproto.h> 55#include <sys/sysent.h> 56#include <sys/vnode.h> 57#include <sys/file.h> 58#include <sys/socket.h> 59#include <sys/socketvar.h> 60#include <sys/pipe.h> 61#include <sys/sysctl.h> 62#include <sys/msg.h> 63#include <sys/sem.h> 64#include <sys/shm.h> 65 66#include <fs/devfs/devfs.h> 67 68#include <net/bpfdesc.h> 69#include <net/if.h> 70#include <net/if_types.h> 71#include <net/if_var.h> 72 73#include <netinet/in.h> 74#include <netinet/in_pcb.h> 75#include <netinet/ip_var.h> 76 77#include <vm/vm.h> 78 79#include <sys/mac_policy.h> 80 81SYSCTL_DECL(_security_mac); 82 83SYSCTL_NODE(_security_mac, OID_AUTO, stub, CTLFLAG_RW, 0, 84 "TrustedBSD mac_stub policy controls"); 85 86static int stub_enabled = 1; 87SYSCTL_INT(_security_mac_stub, OID_AUTO, enabled, CTLFLAG_RW, 88 &stub_enabled, 0, "Enforce mac_stub policy"); 89 90/* 91 * Policy module operations. 92 */ 93static void 94stub_destroy(struct mac_policy_conf *conf) 95{ 96 97} 98 99static void 100stub_init(struct mac_policy_conf *conf) 101{ 102 103} 104 105static int 106stub_syscall(struct thread *td, int call, void *arg) 107{ 108 109 return (0); 110} 111 112/* 113 * Label operations. 114 */ 115static void 116stub_init_label(struct label *label) 117{ 118 119} 120 121static int 122stub_init_label_waitcheck(struct label *label, int flag) 123{ 124 125 return (0); 126} 127 128static void 129stub_destroy_label(struct label *label) 130{ 131 132} 133 134static void 135stub_copy_label(struct label *src, struct label *dest) 136{ 137 138} 139 140static int 141stub_externalize_label(struct label *label, char *element_name, 142 struct sbuf *sb, int *claimed) 143{ 144 145 return (0); 146} 147 148static int 149stub_internalize_label(struct label *label, char *element_name, 150 char *element_data, int *claimed) 151{ 152 153 return (0); 154} 155 156/* 157 * Labeling event operations: file system objects, and things that look 158 * a lot like file system objects. 159 */ 160static void 161stub_associate_vnode_devfs(struct mount *mp, struct label *fslabel, 162 struct devfs_dirent *de, struct label *delabel, struct vnode *vp, 163 struct label *vlabel) 164{ 165 166} 167 168static int 169stub_associate_vnode_extattr(struct mount *mp, struct label *fslabel, 170 struct vnode *vp, struct label *vlabel) 171{ 172 173 return (0); 174} 175 176static void 177stub_associate_vnode_singlelabel(struct mount *mp, 178 struct label *fslabel, struct vnode *vp, struct label *vlabel) 179{ 180 181} 182 183static void 184stub_create_devfs_device(struct mount *mp, struct cdev *dev, 185 struct devfs_dirent *devfs_dirent, struct label *label) 186{ 187 188} 189 190static void 191stub_create_devfs_directory(struct mount *mp, char *dirname, 192 int dirnamelen, struct devfs_dirent *devfs_dirent, struct label *label) 193{ 194 195} 196 197static void 198stub_create_devfs_symlink(struct ucred *cred, struct mount *mp, 199 struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de, 200 struct label *delabel) 201{ 202 203} 204 205static int 206stub_create_vnode_extattr(struct ucred *cred, struct mount *mp, 207 struct label *fslabel, struct vnode *dvp, struct label *dlabel, 208 struct vnode *vp, struct label *vlabel, struct componentname *cnp) 209{ 210 211 return (0); 212} 213 214static void 215stub_create_mount(struct ucred *cred, struct mount *mp, 216 struct label *mntlabel, struct label *fslabel) 217{ 218 219} 220 221static void 222stub_create_root_mount(struct ucred *cred, struct mount *mp, 223 struct label *mntlabel, struct label *fslabel) 224{ 225 226} 227 228static void 229stub_relabel_vnode(struct ucred *cred, struct vnode *vp, 230 struct label *vnodelabel, struct label *label) 231{ 232 233} 234 235static int 236stub_setlabel_vnode_extattr(struct ucred *cred, struct vnode *vp, 237 struct label *vlabel, struct label *intlabel) 238{ 239 240 return (0); 241} 242 243static void 244stub_update_devfsdirent(struct mount *mp, 245 struct devfs_dirent *devfs_dirent, struct label *direntlabel, 246 struct vnode *vp, struct label *vnodelabel) 247{ 248 249} 250 251/* 252 * Labeling event operations: IPC object. 253 */ 254static void 255stub_create_mbuf_from_socket(struct socket *so, struct label *socketlabel, 256 struct mbuf *m, struct label *mbuflabel) 257{ 258 259} 260 261static void 262stub_create_socket(struct ucred *cred, struct socket *socket, 263 struct label *socketlabel) 264{ 265 266} 267 268static void 269stub_create_pipe(struct ucred *cred, struct pipepair *pp, 270 struct label *pipelabel) 271{ 272 273} 274 275static void 276stub_create_socket_from_socket(struct socket *oldsocket, 277 struct label *oldsocketlabel, struct socket *newsocket, 278 struct label *newsocketlabel) 279{ 280 281} 282 283static void 284stub_relabel_socket(struct ucred *cred, struct socket *socket, 285 struct label *socketlabel, struct label *newlabel) 286{ 287 288} 289 290static void 291stub_relabel_pipe(struct ucred *cred, struct pipepair *pp, 292 struct label *pipelabel, struct label *newlabel) 293{ 294 295} 296 297static void 298stub_set_socket_peer_from_mbuf(struct mbuf *mbuf, struct label *mbuflabel, 299 struct socket *socket, struct label *socketpeerlabel) 300{ 301 302} 303 304static void 305stub_set_socket_peer_from_socket(struct socket *oldsocket, 306 struct label *oldsocketlabel, struct socket *newsocket, 307 struct label *newsocketpeerlabel) 308{ 309 310} 311 312/* 313 * Labeling event operations: network objects. 314 */ 315static void 316stub_create_bpfdesc(struct ucred *cred, struct bpf_d *bpf_d, 317 struct label *bpflabel) 318{ 319 320} 321 322static void 323stub_create_datagram_from_ipq(struct ipq *ipq, struct label *ipqlabel, 324 struct mbuf *datagram, struct label *datagramlabel) 325{ 326 327} 328 329static void 330stub_create_fragment(struct mbuf *datagram, struct label *datagramlabel, 331 struct mbuf *fragment, struct label *fragmentlabel) 332{ 333 334} 335 336static void 337stub_create_ifnet(struct ifnet *ifnet, struct label *ifnetlabel) 338{ 339 340} 341 342static void 343stub_create_inpcb_from_socket(struct socket *so, struct label *solabel, 344 struct inpcb *inp, struct label *inplabel) 345{ 346 347} 348 349static void 350stub_create_sysv_msgmsg(struct ucred *cred, struct msqid_kernel *msqkptr, 351 struct label *msqlabel, struct msg *msgptr, struct label *msglabel) 352{ 353 354} 355 356static void 357stub_create_sysv_msgqueue(struct ucred *cred, struct msqid_kernel *msqkptr, 358 struct label *msqlabel) 359{ 360 361} 362 363static void 364stub_create_sysv_sema(struct ucred *cred, struct semid_kernel *semakptr, 365 struct label *semalabel) 366{ 367 368} 369 370static void 371stub_create_sysv_shm(struct ucred *cred, struct shmid_kernel *shmsegptr, 372 struct label *shmalabel) 373{ 374 375} 376 377static void 378stub_create_ipq(struct mbuf *fragment, struct label *fragmentlabel, 379 struct ipq *ipq, struct label *ipqlabel) 380{ 381 382} 383 384static void 385stub_create_mbuf_from_inpcb(struct inpcb *inp, struct label *inplabel, 386 struct mbuf *m, struct label *mlabel) 387{ 388 389} 390 391static void 392stub_create_mbuf_from_mbuf(struct mbuf *oldmbuf, 393 struct label *oldmbuflabel, struct mbuf *newmbuf, 394 struct label *newmbuflabel) 395{ 396 397} 398 399static void 400stub_create_mbuf_linklayer(struct ifnet *ifnet, struct label *ifnetlabel, 401 struct mbuf *mbuf, struct label *mbuflabel) 402{ 403 404} 405 406static void 407stub_create_mbuf_from_bpfdesc(struct bpf_d *bpf_d, struct label *bpflabel, 408 struct mbuf *mbuf, struct label *mbuflabel) 409{ 410 411} 412 413static void 414stub_create_mbuf_from_ifnet(struct ifnet *ifnet, struct label *ifnetlabel, 415 struct mbuf *m, struct label *mbuflabel) 416{ 417 418} 419 420static void 421stub_create_mbuf_multicast_encap(struct mbuf *oldmbuf, 422 struct label *oldmbuflabel, struct ifnet *ifnet, struct label *ifnetlabel, 423 struct mbuf *newmbuf, struct label *newmbuflabel) 424{ 425 426} 427 428static void 429stub_create_mbuf_netlayer(struct mbuf *oldmbuf, 430 struct label *oldmbuflabel, struct mbuf *newmbuf, struct label *newmbuflabel) 431{ 432 433} 434 435static int 436stub_fragment_match(struct mbuf *fragment, struct label *fragmentlabel, 437 struct ipq *ipq, struct label *ipqlabel) 438{ 439 440 return (1); 441} 442 443static void 444stub_reflect_mbuf_icmp(struct mbuf *m, struct label *mlabel) 445{ 446 447} 448 449static void 450stub_reflect_mbuf_tcp(struct mbuf *m, struct label *mlabel) 451{ 452 453} 454 455static void 456stub_relabel_ifnet(struct ucred *cred, struct ifnet *ifnet, 457 struct label *ifnetlabel, struct label *newlabel) 458{ 459 460} 461 462static void 463stub_update_ipq(struct mbuf *fragment, struct label *fragmentlabel, 464 struct ipq *ipq, struct label *ipqlabel) 465{ 466 467} 468 469static void 470stub_inpcb_sosetlabel(struct socket *so, struct label *solabel, 471 struct inpcb *inp, struct label *inplabel) 472{ 473 474} 475 476/* 477 * Labeling event operations: processes. 478 */ 479static void 480stub_execve_transition(struct ucred *old, struct ucred *new, 481 struct vnode *vp, struct label *vnodelabel, 482 struct label *interpvnodelabel, struct image_params *imgp, 483 struct label *execlabel) 484{ 485 486} 487 488static int 489stub_execve_will_transition(struct ucred *old, struct vnode *vp, 490 struct label *vnodelabel, struct label *interpvnodelabel, 491 struct image_params *imgp, struct label *execlabel) 492{ 493 494 return (0); 495} 496 497static void 498stub_create_proc0(struct ucred *cred) 499{ 500 501} 502 503static void 504stub_create_proc1(struct ucred *cred) 505{ 506 507} 508 509static void 510stub_relabel_cred(struct ucred *cred, struct label *newlabel) 511{ 512 513} 514 515static void 516stub_thread_userret(struct thread *td) 517{ 518 519} 520 521/* 522 * Label cleanup/flush operations 523 */ 524static void 525stub_cleanup_sysv_msgmsg(struct label *msglabel) 526{ 527 528} 529 530static void 531stub_cleanup_sysv_msgqueue(struct label *msqlabel) 532{ 533 534} 535 536static void 537stub_cleanup_sysv_sema(struct label *semalabel) 538{ 539 540} 541 542static void 543stub_cleanup_sysv_shm(struct label *shmlabel) 544{ 545 546} 547 548/* 549 * Access control checks. 550 */ 551static int 552stub_check_bpfdesc_receive(struct bpf_d *bpf_d, struct label *bpflabel, 553 struct ifnet *ifnet, struct label *ifnet_label) 554{ 555 556 return (0); 557} 558 559static int 560stub_check_cred_relabel(struct ucred *cred, struct label *newlabel) 561{ 562 563 return (0); 564} 565 566static int 567stub_check_cred_visible(struct ucred *u1, struct ucred *u2) 568{ 569 570 return (0); 571} 572 573static int 574stub_check_ifnet_relabel(struct ucred *cred, struct ifnet *ifnet, 575 struct label *ifnetlabel, struct label *newlabel) 576{ 577 578 return (0); 579} 580 581static int 582stub_check_ifnet_transmit(struct ifnet *ifnet, struct label *ifnetlabel, 583 struct mbuf *m, struct label *mbuflabel) 584{ 585 586 return (0); 587} 588 589static int 590stub_check_inpcb_deliver(struct inpcb *inp, struct label *inplabel, 591 struct mbuf *m, struct label *mlabel) 592{ 593 594 return (0); 595} 596 597static int 598stub_check_sysv_msgmsq(struct ucred *cred, struct msg *msgptr, 599 struct label *msglabel, struct msqid_kernel *msqkptr, 600 struct label *msqklabel) 601{ 602 603 return (0); 604} 605 606static int 607stub_check_sysv_msgrcv(struct ucred *cred, struct msg *msgptr, 608 struct label *msglabel) 609{ 610 611 return (0); 612} 613 614 615static int 616stub_check_sysv_msgrmid(struct ucred *cred, struct msg *msgptr, 617 struct label *msglabel) 618{ 619 620 return (0); 621} 622 623 624static int 625stub_check_sysv_msqget(struct ucred *cred, struct msqid_kernel *msqkptr, 626 struct label *msqklabel) 627{ 628 629 return (0); 630} 631 632 633static int 634stub_check_sysv_msqsnd(struct ucred *cred, struct msqid_kernel *msqkptr, 635 struct label *msqklabel) 636{ 637 638 return (0); 639} 640 641static int 642stub_check_sysv_msqrcv(struct ucred *cred, struct msqid_kernel *msqkptr, 643 struct label *msqklabel) 644{ 645 646 return (0); 647} 648 649 650static int 651stub_check_sysv_msqctl(struct ucred *cred, struct msqid_kernel *msqkptr, 652 struct label *msqklabel, int cmd) 653{ 654 655 return (0); 656} 657 658 659static int 660stub_check_sysv_semctl(struct ucred *cred, struct semid_kernel *semakptr, 661 struct label *semaklabel, int cmd) 662{ 663 664 return (0); 665} 666 667static int 668stub_check_sysv_semget(struct ucred *cred, struct semid_kernel *semakptr, 669 struct label *semaklabel) 670{ 671 672 return (0); 673} 674 675 676static int 677stub_check_sysv_semop(struct ucred *cred, struct semid_kernel *semakptr, 678 struct label *semaklabel, size_t accesstype) 679{ 680 681 return (0); 682} 683 684static int 685stub_check_sysv_shmat(struct ucred *cred, struct shmid_kernel *shmsegptr, 686 struct label *shmseglabel, int shmflg) 687{ 688 689 return (0); 690} 691 692static int 693stub_check_sysv_shmctl(struct ucred *cred, struct shmid_kernel *shmsegptr, 694 struct label *shmseglabel, int cmd) 695{ 696 697 return (0); 698} 699 700static int 701stub_check_sysv_shmdt(struct ucred *cred, struct shmid_kernel *shmsegptr, 702 struct label *shmseglabel) 703{ 704 705 return (0); 706} 707 708 709static int 710stub_check_sysv_shmget(struct ucred *cred, struct shmid_kernel *shmsegptr, 711 struct label *shmseglabel, int shmflg) 712{ 713 714 return (0); 715} 716 717static int 718stub_check_kenv_dump(struct ucred *cred) 719{ 720 721 return (0); 722} 723 724static int 725stub_check_kenv_get(struct ucred *cred, char *name) 726{ 727 728 return (0); 729} 730 731static int 732stub_check_kenv_set(struct ucred *cred, char *name, char *value) 733{ 734 735 return (0); 736} 737 738static int 739stub_check_kenv_unset(struct ucred *cred, char *name) 740{ 741 742 return (0); 743} 744 745static int 746stub_check_kld_load(struct ucred *cred, struct vnode *vp, 747 struct label *vlabel) 748{ 749 750 return (0); 751} 752 753static int 754stub_check_kld_stat(struct ucred *cred) 755{ 756 757 return (0); 758} 759 760static int 761stub_check_kld_unload(struct ucred *cred) 762{ 763 764 return (0); 765} 766 767static int 768stub_check_mount_stat(struct ucred *cred, struct mount *mp, 769 struct label *mntlabel) 770{ 771 772 return (0); 773} 774 775static int 776stub_check_pipe_ioctl(struct ucred *cred, struct pipepair *pp, 777 struct label *pipelabel, unsigned long cmd, void /* caddr_t */ *data) 778{ 779 780 return (0); 781} 782 783static int 784stub_check_pipe_poll(struct ucred *cred, struct pipepair *pp, 785 struct label *pipelabel) 786{ 787 788 return (0); 789} 790 791static int 792stub_check_pipe_read(struct ucred *cred, struct pipepair *pp, 793 struct label *pipelabel) 794{ 795 796 return (0); 797} 798 799static int 800stub_check_pipe_relabel(struct ucred *cred, struct pipepair *pp, 801 struct label *pipelabel, struct label *newlabel) 802{ 803 804 return (0); 805} 806 807static int 808stub_check_pipe_stat(struct ucred *cred, struct pipepair *pp, 809 struct label *pipelabel) 810{ 811 812 return (0); 813} 814 815static int 816stub_check_pipe_write(struct ucred *cred, struct pipepair *pp, 817 struct label *pipelabel) 818{ 819 820 return (0); 821} 822 823static int 824stub_check_proc_debug(struct ucred *cred, struct proc *proc) 825{ 826 827 return (0); 828} 829 830static int 831stub_check_proc_sched(struct ucred *cred, struct proc *proc) 832{ 833 834 return (0); 835} 836 837static int 838stub_check_proc_signal(struct ucred *cred, struct proc *proc, int signum) 839{ 840 841 return (0); 842} 843 844static int 845stub_check_proc_setuid(struct ucred *cred, uid_t uid) 846{ 847 848 return (0); 849} 850 851static int 852stub_check_proc_seteuid(struct ucred *cred, uid_t euid) 853{ 854 855 return (0); 856} 857 858static int 859stub_check_proc_setgid(struct ucred *cred, gid_t gid) 860{ 861 862 return (0); 863} 864 865static int 866stub_check_proc_setegid(struct ucred *cred, gid_t egid) 867{ 868 869 return (0); 870} 871 872static int 873stub_check_proc_setgroups(struct ucred *cred, int ngroups, 874 gid_t *gidset) 875{ 876 877 return (0); 878} 879 880static int 881stub_check_proc_setreuid(struct ucred *cred, uid_t ruid, uid_t euid) 882{ 883 884 return (0); 885} 886 887static int 888stub_check_proc_setregid(struct ucred *cred, gid_t rgid, gid_t egid) 889{ 890 891 return (0); 892} 893 894static int 895stub_check_proc_setresuid(struct ucred *cred, uid_t ruid, uid_t euid, 896 uid_t suid) 897{ 898 899 return (0); 900} 901 902static int 903stub_check_proc_setresgid(struct ucred *cred, gid_t rgid, gid_t egid, 904 gid_t sgid) 905{ 906 907 return (0); 908} 909 910static int 911stub_check_socket_bind(struct ucred *cred, struct socket *socket, 912 struct label *socketlabel, struct sockaddr *sockaddr) 913{ 914 915 return (0); 916} 917 918static int 919stub_check_socket_connect(struct ucred *cred, struct socket *socket, 920 struct label *socketlabel, struct sockaddr *sockaddr) 921{ 922 923 return (0); 924} 925 926static int 927stub_check_socket_deliver(struct socket *so, struct label *socketlabel, 928 struct mbuf *m, struct label *mbuflabel) 929{ 930 931 return (0); 932} 933 934static int 935stub_check_socket_listen(struct ucred *cred, struct socket *so, 936 struct label *socketlabel) 937{ 938 939 return (0); 940} 941 942static int 943stub_check_socket_relabel(struct ucred *cred, struct socket *socket, 944 struct label *socketlabel, struct label *newlabel) 945{ 946 947 return (0); 948} 949 950static int 951stub_check_socket_visible(struct ucred *cred, struct socket *socket, 952 struct label *socketlabel) 953{ 954 955 return (0); 956} 957 958static int 959stub_check_sysarch_ioperm(struct ucred *cred) 960{ 961 962 return (0); 963} 964 965static int 966stub_check_system_acct(struct ucred *cred, struct vnode *vp, 967 struct label *vlabel) 968{ 969 970 return (0); 971} 972 973static int 974stub_check_system_reboot(struct ucred *cred, int how) 975{ 976 977 return (0); 978} 979 980static int 981stub_check_system_settime(struct ucred *cred) 982{ 983 984 return (0); 985} 986 987static int 988stub_check_system_swapon(struct ucred *cred, struct vnode *vp, 989 struct label *label) 990{ 991 992 return (0); 993} 994 995static int 996stub_check_system_swapoff(struct ucred *cred, struct vnode *vp, 997 struct label *label) 998{ 999 1000 return (0); 1001} 1002 1003static int 1004stub_check_system_sysctl(struct ucred *cred, struct sysctl_oid *oidp, 1005 void *arg1, int arg2, struct sysctl_req *req) 1006{ 1007 1008 return (0); 1009} 1010 1011static int 1012stub_check_vnode_access(struct ucred *cred, struct vnode *vp, 1013 struct label *label, int acc_mode) 1014{ 1015 1016 return (0); 1017} 1018 1019static int 1020stub_check_vnode_chdir(struct ucred *cred, struct vnode *dvp, 1021 struct label *dlabel) 1022{ 1023 1024 return (0); 1025} 1026 1027static int 1028stub_check_vnode_chroot(struct ucred *cred, struct vnode *dvp, 1029 struct label *dlabel) 1030{ 1031 1032 return (0); 1033} 1034 1035static int 1036stub_check_vnode_create(struct ucred *cred, struct vnode *dvp, 1037 struct label *dlabel, struct componentname *cnp, struct vattr *vap) 1038{ 1039 1040 return (0); 1041} 1042 1043static int 1044stub_check_vnode_delete(struct ucred *cred, struct vnode *dvp, 1045 struct label *dlabel, struct vnode *vp, struct label *label, 1046 struct componentname *cnp) 1047{ 1048 1049 return (0); 1050} 1051 1052static int 1053stub_check_vnode_deleteacl(struct ucred *cred, struct vnode *vp, 1054 struct label *label, acl_type_t type) 1055{ 1056 1057 return (0); 1058} 1059 1060static int 1061stub_check_vnode_deleteextattr(struct ucred *cred, struct vnode *vp, 1062 struct label *label, int attrnamespace, const char *name) 1063{ 1064 1065 return (0); 1066} 1067 1068static int 1069stub_check_vnode_exec(struct ucred *cred, struct vnode *vp, 1070 struct label *label, struct image_params *imgp, 1071 struct label *execlabel) 1072{ 1073 1074 return (0); 1075} 1076 1077static int 1078stub_check_vnode_getacl(struct ucred *cred, struct vnode *vp, 1079 struct label *label, acl_type_t type) 1080{ 1081 1082 return (0); 1083} 1084 1085static int 1086stub_check_vnode_getextattr(struct ucred *cred, struct vnode *vp, 1087 struct label *label, int attrnamespace, const char *name, struct uio *uio) 1088{ 1089 1090 return (0); 1091} 1092 1093static int 1094stub_check_vnode_link(struct ucred *cred, struct vnode *dvp, 1095 struct label *dlabel, struct vnode *vp, struct label *label, 1096 struct componentname *cnp) 1097{ 1098 1099 return (0); 1100} 1101 1102static int 1103stub_check_vnode_listextattr(struct ucred *cred, struct vnode *vp, 1104 struct label *label, int attrnamespace) 1105{ 1106 1107 return (0); 1108} 1109 1110static int 1111stub_check_vnode_lookup(struct ucred *cred, struct vnode *dvp, 1112 struct label *dlabel, struct componentname *cnp) 1113{ 1114 1115 return (0); 1116} 1117 1118static int 1119stub_check_vnode_mmap(struct ucred *cred, struct vnode *vp, 1120 struct label *label, int prot, int flags) 1121{ 1122 1123 return (0); 1124} 1125 1126static int 1127stub_check_vnode_open(struct ucred *cred, struct vnode *vp, 1128 struct label *filelabel, int acc_mode) 1129{ 1130 1131 return (0); 1132} 1133 1134static int 1135stub_check_vnode_poll(struct ucred *active_cred, struct ucred *file_cred, 1136 struct vnode *vp, struct label *label) 1137{ 1138 1139 return (0); 1140} 1141 1142static int 1143stub_check_vnode_read(struct ucred *active_cred, struct ucred *file_cred, 1144 struct vnode *vp, struct label *label) 1145{ 1146 1147 return (0); 1148} 1149 1150static int 1151stub_check_vnode_readdir(struct ucred *cred, struct vnode *vp, 1152 struct label *dlabel) 1153{ 1154 1155 return (0); 1156} 1157 1158static int 1159stub_check_vnode_readlink(struct ucred *cred, struct vnode *vp, 1160 struct label *vnodelabel) 1161{ 1162 1163 return (0); 1164} 1165 1166static int 1167stub_check_vnode_relabel(struct ucred *cred, struct vnode *vp, 1168 struct label *vnodelabel, struct label *newlabel) 1169{ 1170 1171 return (0); 1172} 1173 1174static int 1175stub_check_vnode_rename_from(struct ucred *cred, struct vnode *dvp, 1176 struct label *dlabel, struct vnode *vp, struct label *label, 1177 struct componentname *cnp) 1178{ 1179 1180 return (0); 1181} 1182 1183static int 1184stub_check_vnode_rename_to(struct ucred *cred, struct vnode *dvp, 1185 struct label *dlabel, struct vnode *vp, struct label *label, int samedir, 1186 struct componentname *cnp) 1187{ 1188 1189 return (0); 1190} 1191 1192static int 1193stub_check_vnode_revoke(struct ucred *cred, struct vnode *vp, 1194 struct label *label) 1195{ 1196 1197 return (0); 1198} 1199 1200static int 1201stub_check_vnode_setacl(struct ucred *cred, struct vnode *vp, 1202 struct label *label, acl_type_t type, struct acl *acl) 1203{ 1204 1205 return (0); 1206} 1207 1208static int 1209stub_check_vnode_setextattr(struct ucred *cred, struct vnode *vp, 1210 struct label *label, int attrnamespace, const char *name, struct uio *uio) 1211{ 1212 1213 return (0); 1214} 1215 1216static int 1217stub_check_vnode_setflags(struct ucred *cred, struct vnode *vp, 1218 struct label *label, u_long flags) 1219{ 1220 1221 return (0); 1222} 1223 1224static int 1225stub_check_vnode_setmode(struct ucred *cred, struct vnode *vp, 1226 struct label *label, mode_t mode) 1227{ 1228 1229 return (0); 1230} 1231 1232static int 1233stub_check_vnode_setowner(struct ucred *cred, struct vnode *vp, 1234 struct label *label, uid_t uid, gid_t gid) 1235{ 1236 1237 return (0); 1238} 1239 1240static int 1241stub_check_vnode_setutimes(struct ucred *cred, struct vnode *vp, 1242 struct label *label, struct timespec atime, struct timespec mtime) 1243{ 1244 1245 return (0); 1246} 1247 1248static int 1249stub_check_vnode_stat(struct ucred *active_cred, struct ucred *file_cred, 1250 struct vnode *vp, struct label *label) 1251{ 1252 1253 return (0); 1254} 1255 1256static int 1257stub_check_vnode_write(struct ucred *active_cred, 1258 struct ucred *file_cred, struct vnode *vp, struct label *label) 1259{ 1260 1261 return (0); 1262} 1263 1264static struct mac_policy_ops mac_stub_ops = 1265{ 1266 .mpo_destroy = stub_destroy, 1267 .mpo_init = stub_init, 1268 .mpo_syscall = stub_syscall, 1269 .mpo_init_bpfdesc_label = stub_init_label, 1270 .mpo_init_cred_label = stub_init_label, 1271 .mpo_init_devfsdirent_label = stub_init_label, 1272 .mpo_init_ifnet_label = stub_init_label, 1273 .mpo_init_inpcb_label = stub_init_label_waitcheck, 1274 .mpo_init_sysv_msgmsg_label = stub_init_label, 1275 .mpo_init_sysv_msgqueue_label = stub_init_label, 1276 .mpo_init_sysv_sema_label = stub_init_label, 1277 .mpo_init_sysv_shm_label = stub_init_label, 1278 .mpo_init_ipq_label = stub_init_label_waitcheck, 1279 .mpo_init_mbuf_label = stub_init_label_waitcheck, 1280 .mpo_init_mount_label = stub_init_label, 1281 .mpo_init_mount_fs_label = stub_init_label, 1282 .mpo_init_pipe_label = stub_init_label, 1283 .mpo_init_socket_label = stub_init_label_waitcheck, 1284 .mpo_init_socket_peer_label = stub_init_label_waitcheck, 1285 .mpo_init_vnode_label = stub_init_label, 1286 .mpo_destroy_bpfdesc_label = stub_destroy_label, 1287 .mpo_destroy_cred_label = stub_destroy_label, 1288 .mpo_destroy_devfsdirent_label = stub_destroy_label, 1289 .mpo_destroy_ifnet_label = stub_destroy_label, 1290 .mpo_destroy_inpcb_label = stub_destroy_label, 1291 .mpo_destroy_sysv_msgmsg_label = stub_destroy_label, 1292 .mpo_destroy_sysv_msgqueue_label = stub_destroy_label, 1293 .mpo_destroy_sysv_sema_label = stub_destroy_label, 1294 .mpo_destroy_sysv_shm_label = stub_destroy_label, 1295 .mpo_destroy_ipq_label = stub_destroy_label, 1296 .mpo_destroy_mbuf_label = stub_destroy_label, 1297 .mpo_destroy_mount_label = stub_destroy_label, 1298 .mpo_destroy_mount_fs_label = stub_destroy_label, 1299 .mpo_destroy_pipe_label = stub_destroy_label, 1300 .mpo_destroy_socket_label = stub_destroy_label, 1301 .mpo_destroy_socket_peer_label = stub_destroy_label, 1302 .mpo_destroy_vnode_label = stub_destroy_label, 1303 .mpo_copy_cred_label = stub_copy_label, 1304 .mpo_copy_ifnet_label = stub_copy_label, 1305 .mpo_copy_mbuf_label = stub_copy_label, 1306 .mpo_copy_pipe_label = stub_copy_label, 1307 .mpo_copy_socket_label = stub_copy_label, 1308 .mpo_copy_vnode_label = stub_copy_label, 1309 .mpo_externalize_cred_label = stub_externalize_label, 1310 .mpo_externalize_ifnet_label = stub_externalize_label, 1311 .mpo_externalize_pipe_label = stub_externalize_label, 1312 .mpo_externalize_socket_label = stub_externalize_label, 1313 .mpo_externalize_socket_peer_label = stub_externalize_label, 1314 .mpo_externalize_vnode_label = stub_externalize_label, 1315 .mpo_internalize_cred_label = stub_internalize_label, 1316 .mpo_internalize_ifnet_label = stub_internalize_label, 1317 .mpo_internalize_pipe_label = stub_internalize_label, 1318 .mpo_internalize_socket_label = stub_internalize_label, 1319 .mpo_internalize_vnode_label = stub_internalize_label, 1320 .mpo_associate_vnode_devfs = stub_associate_vnode_devfs, 1321 .mpo_associate_vnode_extattr = stub_associate_vnode_extattr, 1322 .mpo_associate_vnode_singlelabel = stub_associate_vnode_singlelabel, 1323 .mpo_create_devfs_device = stub_create_devfs_device, 1324 .mpo_create_devfs_directory = stub_create_devfs_directory, 1325 .mpo_create_devfs_symlink = stub_create_devfs_symlink, 1326 .mpo_create_sysv_msgmsg = stub_create_sysv_msgmsg, 1327 .mpo_create_sysv_msgqueue = stub_create_sysv_msgqueue, 1328 .mpo_create_sysv_sema = stub_create_sysv_sema, 1329 .mpo_create_sysv_shm = stub_create_sysv_shm, 1330 .mpo_create_vnode_extattr = stub_create_vnode_extattr, 1331 .mpo_create_mount = stub_create_mount, 1332 .mpo_create_root_mount = stub_create_root_mount, 1333 .mpo_relabel_vnode = stub_relabel_vnode, 1334 .mpo_setlabel_vnode_extattr = stub_setlabel_vnode_extattr, 1335 .mpo_update_devfsdirent = stub_update_devfsdirent, 1336 .mpo_create_mbuf_from_socket = stub_create_mbuf_from_socket, 1337 .mpo_create_pipe = stub_create_pipe, 1338 .mpo_create_socket = stub_create_socket, 1339 .mpo_create_socket_from_socket = stub_create_socket_from_socket, 1340 .mpo_relabel_pipe = stub_relabel_pipe, 1341 .mpo_relabel_socket = stub_relabel_socket, 1342 .mpo_set_socket_peer_from_mbuf = stub_set_socket_peer_from_mbuf, 1343 .mpo_set_socket_peer_from_socket = stub_set_socket_peer_from_socket, 1344 .mpo_create_bpfdesc = stub_create_bpfdesc, 1345 .mpo_create_ifnet = stub_create_ifnet, 1346 .mpo_create_inpcb_from_socket = stub_create_inpcb_from_socket, 1347 .mpo_create_ipq = stub_create_ipq, 1348 .mpo_create_datagram_from_ipq = stub_create_datagram_from_ipq, 1349 .mpo_create_fragment = stub_create_fragment, 1350 .mpo_create_ipq = stub_create_ipq, 1351 .mpo_create_mbuf_from_inpcb = stub_create_mbuf_from_inpcb, 1352 .mpo_create_mbuf_from_mbuf = stub_create_mbuf_from_mbuf, 1353 .mpo_create_mbuf_linklayer = stub_create_mbuf_linklayer, 1354 .mpo_create_mbuf_from_bpfdesc = stub_create_mbuf_from_bpfdesc, 1355 .mpo_create_mbuf_from_ifnet = stub_create_mbuf_from_ifnet, 1356 .mpo_create_mbuf_multicast_encap = stub_create_mbuf_multicast_encap, 1357 .mpo_create_mbuf_netlayer = stub_create_mbuf_netlayer, 1358 .mpo_fragment_match = stub_fragment_match, 1359 .mpo_reflect_mbuf_icmp = stub_reflect_mbuf_icmp, 1360 .mpo_reflect_mbuf_tcp = stub_reflect_mbuf_tcp, 1361 .mpo_relabel_ifnet = stub_relabel_ifnet, 1362 .mpo_update_ipq = stub_update_ipq, 1363 .mpo_inpcb_sosetlabel = stub_inpcb_sosetlabel, 1364 .mpo_execve_transition = stub_execve_transition, 1365 .mpo_execve_will_transition = stub_execve_will_transition, 1366 .mpo_create_proc0 = stub_create_proc0, 1367 .mpo_create_proc1 = stub_create_proc1, 1368 .mpo_relabel_cred = stub_relabel_cred, 1369 .mpo_thread_userret = stub_thread_userret, 1370 .mpo_cleanup_sysv_msgmsg = stub_cleanup_sysv_msgmsg, 1371 .mpo_cleanup_sysv_msgqueue = stub_cleanup_sysv_msgqueue, 1372 .mpo_cleanup_sysv_sema = stub_cleanup_sysv_sema, 1373 .mpo_cleanup_sysv_shm = stub_cleanup_sysv_shm, 1374 .mpo_check_bpfdesc_receive = stub_check_bpfdesc_receive, 1375 .mpo_check_cred_relabel = stub_check_cred_relabel, 1376 .mpo_check_cred_visible = stub_check_cred_visible, 1377 .mpo_check_ifnet_relabel = stub_check_ifnet_relabel, 1378 .mpo_check_ifnet_transmit = stub_check_ifnet_transmit, 1379 .mpo_check_inpcb_deliver = stub_check_inpcb_deliver, 1380 .mpo_check_sysv_msgmsq = stub_check_sysv_msgmsq, 1381 .mpo_check_sysv_msgrcv = stub_check_sysv_msgrcv, 1382 .mpo_check_sysv_msgrmid = stub_check_sysv_msgrmid, 1383 .mpo_check_sysv_msqget = stub_check_sysv_msqget, 1384 .mpo_check_sysv_msqsnd = stub_check_sysv_msqsnd, 1385 .mpo_check_sysv_msqrcv = stub_check_sysv_msqrcv, 1386 .mpo_check_sysv_msqctl = stub_check_sysv_msqctl, 1387 .mpo_check_sysv_semctl = stub_check_sysv_semctl, 1388 .mpo_check_sysv_semget = stub_check_sysv_semget, 1389 .mpo_check_sysv_semop = stub_check_sysv_semop, 1390 .mpo_check_sysv_shmat = stub_check_sysv_shmat, 1391 .mpo_check_sysv_shmctl = stub_check_sysv_shmctl, 1392 .mpo_check_sysv_shmdt = stub_check_sysv_shmdt, 1393 .mpo_check_sysv_shmget = stub_check_sysv_shmget, 1394 .mpo_check_kenv_dump = stub_check_kenv_dump, 1395 .mpo_check_kenv_get = stub_check_kenv_get, 1396 .mpo_check_kenv_set = stub_check_kenv_set, 1397 .mpo_check_kenv_unset = stub_check_kenv_unset, 1398 .mpo_check_kld_load = stub_check_kld_load, 1399 .mpo_check_kld_stat = stub_check_kld_stat, 1400 .mpo_check_kld_unload = stub_check_kld_unload, 1401 .mpo_check_mount_stat = stub_check_mount_stat, 1402 .mpo_check_pipe_ioctl = stub_check_pipe_ioctl, 1403 .mpo_check_pipe_poll = stub_check_pipe_poll, 1404 .mpo_check_pipe_read = stub_check_pipe_read, 1405 .mpo_check_pipe_relabel = stub_check_pipe_relabel, 1406 .mpo_check_pipe_stat = stub_check_pipe_stat, 1407 .mpo_check_pipe_write = stub_check_pipe_write, 1408 .mpo_check_proc_debug = stub_check_proc_debug, 1409 .mpo_check_proc_sched = stub_check_proc_sched, 1410 .mpo_check_proc_setuid = stub_check_proc_setuid, 1411 .mpo_check_proc_seteuid = stub_check_proc_seteuid, 1412 .mpo_check_proc_setgid = stub_check_proc_setgid, 1413 .mpo_check_proc_setegid = stub_check_proc_setegid, 1414 .mpo_check_proc_setgroups = stub_check_proc_setgroups, 1415 .mpo_check_proc_setreuid = stub_check_proc_setreuid, 1416 .mpo_check_proc_setregid = stub_check_proc_setregid, 1417 .mpo_check_proc_setresuid = stub_check_proc_setresuid, 1418 .mpo_check_proc_setresgid = stub_check_proc_setresgid, 1419 .mpo_check_proc_signal = stub_check_proc_signal, 1420 .mpo_check_socket_bind = stub_check_socket_bind, 1421 .mpo_check_socket_connect = stub_check_socket_connect, 1422 .mpo_check_socket_deliver = stub_check_socket_deliver, 1423 .mpo_check_socket_listen = stub_check_socket_listen, 1424 .mpo_check_socket_relabel = stub_check_socket_relabel, 1425 .mpo_check_socket_visible = stub_check_socket_visible, 1426 .mpo_check_sysarch_ioperm = stub_check_sysarch_ioperm, 1427 .mpo_check_system_acct = stub_check_system_acct, 1428 .mpo_check_system_reboot = stub_check_system_reboot, 1429 .mpo_check_system_settime = stub_check_system_settime, 1430 .mpo_check_system_swapon = stub_check_system_swapon, 1431 .mpo_check_system_swapoff = stub_check_system_swapoff, 1432 .mpo_check_system_sysctl = stub_check_system_sysctl, 1433 .mpo_check_vnode_access = stub_check_vnode_access, 1434 .mpo_check_vnode_chdir = stub_check_vnode_chdir, 1435 .mpo_check_vnode_chroot = stub_check_vnode_chroot, 1436 .mpo_check_vnode_create = stub_check_vnode_create, 1437 .mpo_check_vnode_delete = stub_check_vnode_delete, 1438 .mpo_check_vnode_deleteacl = stub_check_vnode_deleteacl, 1439 .mpo_check_vnode_deleteextattr = stub_check_vnode_deleteextattr, 1440 .mpo_check_vnode_exec = stub_check_vnode_exec, 1441 .mpo_check_vnode_getacl = stub_check_vnode_getacl, 1442 .mpo_check_vnode_getextattr = stub_check_vnode_getextattr, 1443 .mpo_check_vnode_link = stub_check_vnode_link, 1444 .mpo_check_vnode_listextattr = stub_check_vnode_listextattr, 1445 .mpo_check_vnode_lookup = stub_check_vnode_lookup, 1446 .mpo_check_vnode_mmap = stub_check_vnode_mmap, 1447 .mpo_check_vnode_open = stub_check_vnode_open, 1448 .mpo_check_vnode_poll = stub_check_vnode_poll, 1449 .mpo_check_vnode_read = stub_check_vnode_read, 1450 .mpo_check_vnode_readdir = stub_check_vnode_readdir, 1451 .mpo_check_vnode_readlink = stub_check_vnode_readlink, 1452 .mpo_check_vnode_relabel = stub_check_vnode_relabel, 1453 .mpo_check_vnode_rename_from = stub_check_vnode_rename_from, 1454 .mpo_check_vnode_rename_to = stub_check_vnode_rename_to, 1455 .mpo_check_vnode_revoke = stub_check_vnode_revoke, 1456 .mpo_check_vnode_setacl = stub_check_vnode_setacl, 1457 .mpo_check_vnode_setextattr = stub_check_vnode_setextattr, 1458 .mpo_check_vnode_setflags = stub_check_vnode_setflags, 1459 .mpo_check_vnode_setmode = stub_check_vnode_setmode, 1460 .mpo_check_vnode_setowner = stub_check_vnode_setowner, 1461 .mpo_check_vnode_setutimes = stub_check_vnode_setutimes, 1462 .mpo_check_vnode_stat = stub_check_vnode_stat, 1463 .mpo_check_vnode_write = stub_check_vnode_write, 1464}; 1465 1466MAC_POLICY_SET(&mac_stub_ops, mac_stub, "TrustedBSD MAC/Stub", 1467 MPC_LOADTIME_FLAG_UNLOADOK, NULL); 1468