mac_stub.c revision 145234
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 145234 2005-04-18 13:36:57Z 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_wait(struct ucred *cred, struct proc *proc) 846{ 847 848 return (0); 849} 850 851static int 852stub_check_proc_setuid(struct ucred *cred, uid_t uid) 853{ 854 855 return (0); 856} 857 858static int 859stub_check_proc_seteuid(struct ucred *cred, uid_t euid) 860{ 861 862 return (0); 863} 864 865static int 866stub_check_proc_setgid(struct ucred *cred, gid_t gid) 867{ 868 869 return (0); 870} 871 872static int 873stub_check_proc_setegid(struct ucred *cred, gid_t egid) 874{ 875 876 return (0); 877} 878 879static int 880stub_check_proc_setgroups(struct ucred *cred, int ngroups, 881 gid_t *gidset) 882{ 883 884 return (0); 885} 886 887static int 888stub_check_proc_setreuid(struct ucred *cred, uid_t ruid, uid_t euid) 889{ 890 891 return (0); 892} 893 894static int 895stub_check_proc_setregid(struct ucred *cred, gid_t rgid, gid_t egid) 896{ 897 898 return (0); 899} 900 901static int 902stub_check_proc_setresuid(struct ucred *cred, uid_t ruid, uid_t euid, 903 uid_t suid) 904{ 905 906 return (0); 907} 908 909static int 910stub_check_proc_setresgid(struct ucred *cred, gid_t rgid, gid_t egid, 911 gid_t sgid) 912{ 913 914 return (0); 915} 916 917static int 918stub_check_socket_accept(struct ucred *cred, struct socket *socket, 919 struct label *socketlabel) 920{ 921 922 return (0); 923} 924 925static int 926stub_check_socket_bind(struct ucred *cred, struct socket *socket, 927 struct label *socketlabel, struct sockaddr *sockaddr) 928{ 929 930 return (0); 931} 932 933static int 934stub_check_socket_connect(struct ucred *cred, struct socket *socket, 935 struct label *socketlabel, struct sockaddr *sockaddr) 936{ 937 938 return (0); 939} 940 941static int 942stub_check_socket_deliver(struct socket *so, struct label *socketlabel, 943 struct mbuf *m, struct label *mbuflabel) 944{ 945 946 return (0); 947} 948 949static int 950stub_check_socket_listen(struct ucred *cred, struct socket *so, 951 struct label *socketlabel) 952{ 953 954 return (0); 955} 956 957static int 958stub_check_socket_poll(struct ucred *cred, struct socket *so, 959 struct label *socketlabel) 960{ 961 962 return (0); 963} 964 965static int 966stub_check_socket_receive(struct ucred *cred, struct socket *so, 967 struct label *socketlabel) 968{ 969 970 return (0); 971} 972 973static int 974stub_check_socket_relabel(struct ucred *cred, struct socket *socket, 975 struct label *socketlabel, struct label *newlabel) 976{ 977 978 return (0); 979} 980static int 981stub_check_socket_send(struct ucred *cred, struct socket *so, 982 struct label *socketlabel) 983{ 984 985 return (0); 986} 987 988static int 989stub_check_socket_stat(struct ucred *cred, struct socket *so, 990 struct label *socketlabel) 991{ 992 993 return (0); 994} 995 996static int 997stub_check_socket_visible(struct ucred *cred, struct socket *socket, 998 struct label *socketlabel) 999{ 1000 1001 return (0); 1002} 1003 1004static int 1005stub_check_sysarch_ioperm(struct ucred *cred) 1006{ 1007 1008 return (0); 1009} 1010 1011static int 1012stub_check_system_acct(struct ucred *cred, struct vnode *vp, 1013 struct label *vlabel) 1014{ 1015 1016 return (0); 1017} 1018 1019static int 1020stub_check_system_reboot(struct ucred *cred, int how) 1021{ 1022 1023 return (0); 1024} 1025 1026static int 1027stub_check_system_settime(struct ucred *cred) 1028{ 1029 1030 return (0); 1031} 1032 1033static int 1034stub_check_system_swapon(struct ucred *cred, struct vnode *vp, 1035 struct label *label) 1036{ 1037 1038 return (0); 1039} 1040 1041static int 1042stub_check_system_swapoff(struct ucred *cred, struct vnode *vp, 1043 struct label *label) 1044{ 1045 1046 return (0); 1047} 1048 1049static int 1050stub_check_system_sysctl(struct ucred *cred, struct sysctl_oid *oidp, 1051 void *arg1, int arg2, struct sysctl_req *req) 1052{ 1053 1054 return (0); 1055} 1056 1057static int 1058stub_check_vnode_access(struct ucred *cred, struct vnode *vp, 1059 struct label *label, int acc_mode) 1060{ 1061 1062 return (0); 1063} 1064 1065static int 1066stub_check_vnode_chdir(struct ucred *cred, struct vnode *dvp, 1067 struct label *dlabel) 1068{ 1069 1070 return (0); 1071} 1072 1073static int 1074stub_check_vnode_chroot(struct ucred *cred, struct vnode *dvp, 1075 struct label *dlabel) 1076{ 1077 1078 return (0); 1079} 1080 1081static int 1082stub_check_vnode_create(struct ucred *cred, struct vnode *dvp, 1083 struct label *dlabel, struct componentname *cnp, struct vattr *vap) 1084{ 1085 1086 return (0); 1087} 1088 1089static int 1090stub_check_vnode_delete(struct ucred *cred, struct vnode *dvp, 1091 struct label *dlabel, struct vnode *vp, struct label *label, 1092 struct componentname *cnp) 1093{ 1094 1095 return (0); 1096} 1097 1098static int 1099stub_check_vnode_deleteacl(struct ucred *cred, struct vnode *vp, 1100 struct label *label, acl_type_t type) 1101{ 1102 1103 return (0); 1104} 1105 1106static int 1107stub_check_vnode_deleteextattr(struct ucred *cred, struct vnode *vp, 1108 struct label *label, int attrnamespace, const char *name) 1109{ 1110 1111 return (0); 1112} 1113 1114static int 1115stub_check_vnode_exec(struct ucred *cred, struct vnode *vp, 1116 struct label *label, struct image_params *imgp, 1117 struct label *execlabel) 1118{ 1119 1120 return (0); 1121} 1122 1123static int 1124stub_check_vnode_getacl(struct ucred *cred, struct vnode *vp, 1125 struct label *label, acl_type_t type) 1126{ 1127 1128 return (0); 1129} 1130 1131static int 1132stub_check_vnode_getextattr(struct ucred *cred, struct vnode *vp, 1133 struct label *label, int attrnamespace, const char *name, struct uio *uio) 1134{ 1135 1136 return (0); 1137} 1138 1139static int 1140stub_check_vnode_link(struct ucred *cred, struct vnode *dvp, 1141 struct label *dlabel, struct vnode *vp, struct label *label, 1142 struct componentname *cnp) 1143{ 1144 1145 return (0); 1146} 1147 1148static int 1149stub_check_vnode_listextattr(struct ucred *cred, struct vnode *vp, 1150 struct label *label, int attrnamespace) 1151{ 1152 1153 return (0); 1154} 1155 1156static int 1157stub_check_vnode_lookup(struct ucred *cred, struct vnode *dvp, 1158 struct label *dlabel, struct componentname *cnp) 1159{ 1160 1161 return (0); 1162} 1163 1164static int 1165stub_check_vnode_mmap(struct ucred *cred, struct vnode *vp, 1166 struct label *label, int prot, int flags) 1167{ 1168 1169 return (0); 1170} 1171 1172static int 1173stub_check_vnode_open(struct ucred *cred, struct vnode *vp, 1174 struct label *filelabel, int acc_mode) 1175{ 1176 1177 return (0); 1178} 1179 1180static int 1181stub_check_vnode_poll(struct ucred *active_cred, struct ucred *file_cred, 1182 struct vnode *vp, struct label *label) 1183{ 1184 1185 return (0); 1186} 1187 1188static int 1189stub_check_vnode_read(struct ucred *active_cred, struct ucred *file_cred, 1190 struct vnode *vp, struct label *label) 1191{ 1192 1193 return (0); 1194} 1195 1196static int 1197stub_check_vnode_readdir(struct ucred *cred, struct vnode *vp, 1198 struct label *dlabel) 1199{ 1200 1201 return (0); 1202} 1203 1204static int 1205stub_check_vnode_readlink(struct ucred *cred, struct vnode *vp, 1206 struct label *vnodelabel) 1207{ 1208 1209 return (0); 1210} 1211 1212static int 1213stub_check_vnode_relabel(struct ucred *cred, struct vnode *vp, 1214 struct label *vnodelabel, struct label *newlabel) 1215{ 1216 1217 return (0); 1218} 1219 1220static int 1221stub_check_vnode_rename_from(struct ucred *cred, struct vnode *dvp, 1222 struct label *dlabel, struct vnode *vp, struct label *label, 1223 struct componentname *cnp) 1224{ 1225 1226 return (0); 1227} 1228 1229static int 1230stub_check_vnode_rename_to(struct ucred *cred, struct vnode *dvp, 1231 struct label *dlabel, struct vnode *vp, struct label *label, int samedir, 1232 struct componentname *cnp) 1233{ 1234 1235 return (0); 1236} 1237 1238static int 1239stub_check_vnode_revoke(struct ucred *cred, struct vnode *vp, 1240 struct label *label) 1241{ 1242 1243 return (0); 1244} 1245 1246static int 1247stub_check_vnode_setacl(struct ucred *cred, struct vnode *vp, 1248 struct label *label, acl_type_t type, struct acl *acl) 1249{ 1250 1251 return (0); 1252} 1253 1254static int 1255stub_check_vnode_setextattr(struct ucred *cred, struct vnode *vp, 1256 struct label *label, int attrnamespace, const char *name, struct uio *uio) 1257{ 1258 1259 return (0); 1260} 1261 1262static int 1263stub_check_vnode_setflags(struct ucred *cred, struct vnode *vp, 1264 struct label *label, u_long flags) 1265{ 1266 1267 return (0); 1268} 1269 1270static int 1271stub_check_vnode_setmode(struct ucred *cred, struct vnode *vp, 1272 struct label *label, mode_t mode) 1273{ 1274 1275 return (0); 1276} 1277 1278static int 1279stub_check_vnode_setowner(struct ucred *cred, struct vnode *vp, 1280 struct label *label, uid_t uid, gid_t gid) 1281{ 1282 1283 return (0); 1284} 1285 1286static int 1287stub_check_vnode_setutimes(struct ucred *cred, struct vnode *vp, 1288 struct label *label, struct timespec atime, struct timespec mtime) 1289{ 1290 1291 return (0); 1292} 1293 1294static int 1295stub_check_vnode_stat(struct ucred *active_cred, struct ucred *file_cred, 1296 struct vnode *vp, struct label *label) 1297{ 1298 1299 return (0); 1300} 1301 1302static int 1303stub_check_vnode_write(struct ucred *active_cred, 1304 struct ucred *file_cred, struct vnode *vp, struct label *label) 1305{ 1306 1307 return (0); 1308} 1309 1310static struct mac_policy_ops mac_stub_ops = 1311{ 1312 .mpo_destroy = stub_destroy, 1313 .mpo_init = stub_init, 1314 .mpo_syscall = stub_syscall, 1315 .mpo_init_bpfdesc_label = stub_init_label, 1316 .mpo_init_cred_label = stub_init_label, 1317 .mpo_init_devfsdirent_label = stub_init_label, 1318 .mpo_init_ifnet_label = stub_init_label, 1319 .mpo_init_inpcb_label = stub_init_label_waitcheck, 1320 .mpo_init_sysv_msgmsg_label = stub_init_label, 1321 .mpo_init_sysv_msgqueue_label = stub_init_label, 1322 .mpo_init_sysv_sema_label = stub_init_label, 1323 .mpo_init_sysv_shm_label = stub_init_label, 1324 .mpo_init_ipq_label = stub_init_label_waitcheck, 1325 .mpo_init_mbuf_label = stub_init_label_waitcheck, 1326 .mpo_init_mount_label = stub_init_label, 1327 .mpo_init_mount_fs_label = stub_init_label, 1328 .mpo_init_pipe_label = stub_init_label, 1329 .mpo_init_socket_label = stub_init_label_waitcheck, 1330 .mpo_init_socket_peer_label = stub_init_label_waitcheck, 1331 .mpo_init_vnode_label = stub_init_label, 1332 .mpo_destroy_bpfdesc_label = stub_destroy_label, 1333 .mpo_destroy_cred_label = stub_destroy_label, 1334 .mpo_destroy_devfsdirent_label = stub_destroy_label, 1335 .mpo_destroy_ifnet_label = stub_destroy_label, 1336 .mpo_destroy_inpcb_label = stub_destroy_label, 1337 .mpo_destroy_sysv_msgmsg_label = stub_destroy_label, 1338 .mpo_destroy_sysv_msgqueue_label = stub_destroy_label, 1339 .mpo_destroy_sysv_sema_label = stub_destroy_label, 1340 .mpo_destroy_sysv_shm_label = stub_destroy_label, 1341 .mpo_destroy_ipq_label = stub_destroy_label, 1342 .mpo_destroy_mbuf_label = stub_destroy_label, 1343 .mpo_destroy_mount_label = stub_destroy_label, 1344 .mpo_destroy_mount_fs_label = stub_destroy_label, 1345 .mpo_destroy_pipe_label = stub_destroy_label, 1346 .mpo_destroy_socket_label = stub_destroy_label, 1347 .mpo_destroy_socket_peer_label = stub_destroy_label, 1348 .mpo_destroy_vnode_label = stub_destroy_label, 1349 .mpo_copy_cred_label = stub_copy_label, 1350 .mpo_copy_ifnet_label = stub_copy_label, 1351 .mpo_copy_mbuf_label = stub_copy_label, 1352 .mpo_copy_pipe_label = stub_copy_label, 1353 .mpo_copy_socket_label = stub_copy_label, 1354 .mpo_copy_vnode_label = stub_copy_label, 1355 .mpo_externalize_cred_label = stub_externalize_label, 1356 .mpo_externalize_ifnet_label = stub_externalize_label, 1357 .mpo_externalize_pipe_label = stub_externalize_label, 1358 .mpo_externalize_socket_label = stub_externalize_label, 1359 .mpo_externalize_socket_peer_label = stub_externalize_label, 1360 .mpo_externalize_vnode_label = stub_externalize_label, 1361 .mpo_internalize_cred_label = stub_internalize_label, 1362 .mpo_internalize_ifnet_label = stub_internalize_label, 1363 .mpo_internalize_pipe_label = stub_internalize_label, 1364 .mpo_internalize_socket_label = stub_internalize_label, 1365 .mpo_internalize_vnode_label = stub_internalize_label, 1366 .mpo_associate_vnode_devfs = stub_associate_vnode_devfs, 1367 .mpo_associate_vnode_extattr = stub_associate_vnode_extattr, 1368 .mpo_associate_vnode_singlelabel = stub_associate_vnode_singlelabel, 1369 .mpo_create_devfs_device = stub_create_devfs_device, 1370 .mpo_create_devfs_directory = stub_create_devfs_directory, 1371 .mpo_create_devfs_symlink = stub_create_devfs_symlink, 1372 .mpo_create_sysv_msgmsg = stub_create_sysv_msgmsg, 1373 .mpo_create_sysv_msgqueue = stub_create_sysv_msgqueue, 1374 .mpo_create_sysv_sema = stub_create_sysv_sema, 1375 .mpo_create_sysv_shm = stub_create_sysv_shm, 1376 .mpo_create_vnode_extattr = stub_create_vnode_extattr, 1377 .mpo_create_mount = stub_create_mount, 1378 .mpo_create_root_mount = stub_create_root_mount, 1379 .mpo_relabel_vnode = stub_relabel_vnode, 1380 .mpo_setlabel_vnode_extattr = stub_setlabel_vnode_extattr, 1381 .mpo_update_devfsdirent = stub_update_devfsdirent, 1382 .mpo_create_mbuf_from_socket = stub_create_mbuf_from_socket, 1383 .mpo_create_pipe = stub_create_pipe, 1384 .mpo_create_socket = stub_create_socket, 1385 .mpo_create_socket_from_socket = stub_create_socket_from_socket, 1386 .mpo_relabel_pipe = stub_relabel_pipe, 1387 .mpo_relabel_socket = stub_relabel_socket, 1388 .mpo_set_socket_peer_from_mbuf = stub_set_socket_peer_from_mbuf, 1389 .mpo_set_socket_peer_from_socket = stub_set_socket_peer_from_socket, 1390 .mpo_create_bpfdesc = stub_create_bpfdesc, 1391 .mpo_create_ifnet = stub_create_ifnet, 1392 .mpo_create_inpcb_from_socket = stub_create_inpcb_from_socket, 1393 .mpo_create_ipq = stub_create_ipq, 1394 .mpo_create_datagram_from_ipq = stub_create_datagram_from_ipq, 1395 .mpo_create_fragment = stub_create_fragment, 1396 .mpo_create_ipq = stub_create_ipq, 1397 .mpo_create_mbuf_from_inpcb = stub_create_mbuf_from_inpcb, 1398 .mpo_create_mbuf_from_mbuf = stub_create_mbuf_from_mbuf, 1399 .mpo_create_mbuf_linklayer = stub_create_mbuf_linklayer, 1400 .mpo_create_mbuf_from_bpfdesc = stub_create_mbuf_from_bpfdesc, 1401 .mpo_create_mbuf_from_ifnet = stub_create_mbuf_from_ifnet, 1402 .mpo_create_mbuf_multicast_encap = stub_create_mbuf_multicast_encap, 1403 .mpo_create_mbuf_netlayer = stub_create_mbuf_netlayer, 1404 .mpo_fragment_match = stub_fragment_match, 1405 .mpo_reflect_mbuf_icmp = stub_reflect_mbuf_icmp, 1406 .mpo_reflect_mbuf_tcp = stub_reflect_mbuf_tcp, 1407 .mpo_relabel_ifnet = stub_relabel_ifnet, 1408 .mpo_update_ipq = stub_update_ipq, 1409 .mpo_inpcb_sosetlabel = stub_inpcb_sosetlabel, 1410 .mpo_execve_transition = stub_execve_transition, 1411 .mpo_execve_will_transition = stub_execve_will_transition, 1412 .mpo_create_proc0 = stub_create_proc0, 1413 .mpo_create_proc1 = stub_create_proc1, 1414 .mpo_relabel_cred = stub_relabel_cred, 1415 .mpo_thread_userret = stub_thread_userret, 1416 .mpo_cleanup_sysv_msgmsg = stub_cleanup_sysv_msgmsg, 1417 .mpo_cleanup_sysv_msgqueue = stub_cleanup_sysv_msgqueue, 1418 .mpo_cleanup_sysv_sema = stub_cleanup_sysv_sema, 1419 .mpo_cleanup_sysv_shm = stub_cleanup_sysv_shm, 1420 .mpo_check_bpfdesc_receive = stub_check_bpfdesc_receive, 1421 .mpo_check_cred_relabel = stub_check_cred_relabel, 1422 .mpo_check_cred_visible = stub_check_cred_visible, 1423 .mpo_check_ifnet_relabel = stub_check_ifnet_relabel, 1424 .mpo_check_ifnet_transmit = stub_check_ifnet_transmit, 1425 .mpo_check_inpcb_deliver = stub_check_inpcb_deliver, 1426 .mpo_check_sysv_msgmsq = stub_check_sysv_msgmsq, 1427 .mpo_check_sysv_msgrcv = stub_check_sysv_msgrcv, 1428 .mpo_check_sysv_msgrmid = stub_check_sysv_msgrmid, 1429 .mpo_check_sysv_msqget = stub_check_sysv_msqget, 1430 .mpo_check_sysv_msqsnd = stub_check_sysv_msqsnd, 1431 .mpo_check_sysv_msqrcv = stub_check_sysv_msqrcv, 1432 .mpo_check_sysv_msqctl = stub_check_sysv_msqctl, 1433 .mpo_check_sysv_semctl = stub_check_sysv_semctl, 1434 .mpo_check_sysv_semget = stub_check_sysv_semget, 1435 .mpo_check_sysv_semop = stub_check_sysv_semop, 1436 .mpo_check_sysv_shmat = stub_check_sysv_shmat, 1437 .mpo_check_sysv_shmctl = stub_check_sysv_shmctl, 1438 .mpo_check_sysv_shmdt = stub_check_sysv_shmdt, 1439 .mpo_check_sysv_shmget = stub_check_sysv_shmget, 1440 .mpo_check_kenv_dump = stub_check_kenv_dump, 1441 .mpo_check_kenv_get = stub_check_kenv_get, 1442 .mpo_check_kenv_set = stub_check_kenv_set, 1443 .mpo_check_kenv_unset = stub_check_kenv_unset, 1444 .mpo_check_kld_load = stub_check_kld_load, 1445 .mpo_check_kld_stat = stub_check_kld_stat, 1446 .mpo_check_kld_unload = stub_check_kld_unload, 1447 .mpo_check_mount_stat = stub_check_mount_stat, 1448 .mpo_check_pipe_ioctl = stub_check_pipe_ioctl, 1449 .mpo_check_pipe_poll = stub_check_pipe_poll, 1450 .mpo_check_pipe_read = stub_check_pipe_read, 1451 .mpo_check_pipe_relabel = stub_check_pipe_relabel, 1452 .mpo_check_pipe_stat = stub_check_pipe_stat, 1453 .mpo_check_pipe_write = stub_check_pipe_write, 1454 .mpo_check_proc_debug = stub_check_proc_debug, 1455 .mpo_check_proc_sched = stub_check_proc_sched, 1456 .mpo_check_proc_setuid = stub_check_proc_setuid, 1457 .mpo_check_proc_seteuid = stub_check_proc_seteuid, 1458 .mpo_check_proc_setgid = stub_check_proc_setgid, 1459 .mpo_check_proc_setegid = stub_check_proc_setegid, 1460 .mpo_check_proc_setgroups = stub_check_proc_setgroups, 1461 .mpo_check_proc_setreuid = stub_check_proc_setreuid, 1462 .mpo_check_proc_setregid = stub_check_proc_setregid, 1463 .mpo_check_proc_setresuid = stub_check_proc_setresuid, 1464 .mpo_check_proc_setresgid = stub_check_proc_setresgid, 1465 .mpo_check_proc_signal = stub_check_proc_signal, 1466 .mpo_check_proc_wait = stub_check_proc_wait, 1467 .mpo_check_socket_accept = stub_check_socket_accept, 1468 .mpo_check_socket_bind = stub_check_socket_bind, 1469 .mpo_check_socket_connect = stub_check_socket_connect, 1470 .mpo_check_socket_deliver = stub_check_socket_deliver, 1471 .mpo_check_socket_listen = stub_check_socket_listen, 1472 .mpo_check_socket_poll = stub_check_socket_poll, 1473 .mpo_check_socket_receive = stub_check_socket_receive, 1474 .mpo_check_socket_relabel = stub_check_socket_relabel, 1475 .mpo_check_socket_send = stub_check_socket_send, 1476 .mpo_check_socket_stat = stub_check_socket_stat, 1477 .mpo_check_socket_visible = stub_check_socket_visible, 1478 .mpo_check_sysarch_ioperm = stub_check_sysarch_ioperm, 1479 .mpo_check_system_acct = stub_check_system_acct, 1480 .mpo_check_system_reboot = stub_check_system_reboot, 1481 .mpo_check_system_settime = stub_check_system_settime, 1482 .mpo_check_system_swapon = stub_check_system_swapon, 1483 .mpo_check_system_swapoff = stub_check_system_swapoff, 1484 .mpo_check_system_sysctl = stub_check_system_sysctl, 1485 .mpo_check_vnode_access = stub_check_vnode_access, 1486 .mpo_check_vnode_chdir = stub_check_vnode_chdir, 1487 .mpo_check_vnode_chroot = stub_check_vnode_chroot, 1488 .mpo_check_vnode_create = stub_check_vnode_create, 1489 .mpo_check_vnode_delete = stub_check_vnode_delete, 1490 .mpo_check_vnode_deleteacl = stub_check_vnode_deleteacl, 1491 .mpo_check_vnode_deleteextattr = stub_check_vnode_deleteextattr, 1492 .mpo_check_vnode_exec = stub_check_vnode_exec, 1493 .mpo_check_vnode_getacl = stub_check_vnode_getacl, 1494 .mpo_check_vnode_getextattr = stub_check_vnode_getextattr, 1495 .mpo_check_vnode_link = stub_check_vnode_link, 1496 .mpo_check_vnode_listextattr = stub_check_vnode_listextattr, 1497 .mpo_check_vnode_lookup = stub_check_vnode_lookup, 1498 .mpo_check_vnode_mmap = stub_check_vnode_mmap, 1499 .mpo_check_vnode_open = stub_check_vnode_open, 1500 .mpo_check_vnode_poll = stub_check_vnode_poll, 1501 .mpo_check_vnode_read = stub_check_vnode_read, 1502 .mpo_check_vnode_readdir = stub_check_vnode_readdir, 1503 .mpo_check_vnode_readlink = stub_check_vnode_readlink, 1504 .mpo_check_vnode_relabel = stub_check_vnode_relabel, 1505 .mpo_check_vnode_rename_from = stub_check_vnode_rename_from, 1506 .mpo_check_vnode_rename_to = stub_check_vnode_rename_to, 1507 .mpo_check_vnode_revoke = stub_check_vnode_revoke, 1508 .mpo_check_vnode_setacl = stub_check_vnode_setacl, 1509 .mpo_check_vnode_setextattr = stub_check_vnode_setextattr, 1510 .mpo_check_vnode_setflags = stub_check_vnode_setflags, 1511 .mpo_check_vnode_setmode = stub_check_vnode_setmode, 1512 .mpo_check_vnode_setowner = stub_check_vnode_setowner, 1513 .mpo_check_vnode_setutimes = stub_check_vnode_setutimes, 1514 .mpo_check_vnode_stat = stub_check_vnode_stat, 1515 .mpo_check_vnode_write = stub_check_vnode_write, 1516}; 1517 1518MAC_POLICY_SET(&mac_stub_ops, mac_stub, "TrustedBSD MAC/Stub", 1519 MPC_LOADTIME_FLAG_UNLOADOK, NULL); 1520