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