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