mac_stub.c revision 140879
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 140879 2005-01-26 23:43:32Z 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_socket_bind(struct ucred *cred, struct socket *socket,
846    struct label *socketlabel, struct sockaddr *sockaddr)
847{
848
849	return (0);
850}
851
852static int
853stub_check_socket_connect(struct ucred *cred, struct socket *socket,
854    struct label *socketlabel, struct sockaddr *sockaddr)
855{
856
857	return (0);
858}
859
860static int
861stub_check_socket_deliver(struct socket *so, struct label *socketlabel,
862    struct mbuf *m, struct label *mbuflabel)
863{
864
865	return (0);
866}
867
868static int
869stub_check_socket_listen(struct ucred *cred, struct socket *so,
870    struct label *socketlabel)
871{
872
873	return (0);
874}
875
876static int
877stub_check_socket_relabel(struct ucred *cred, struct socket *socket,
878    struct label *socketlabel, struct label *newlabel)
879{
880
881	return (0);
882}
883
884static int
885stub_check_socket_visible(struct ucred *cred, struct socket *socket,
886   struct label *socketlabel)
887{
888
889	return (0);
890}
891
892static int
893stub_check_sysarch_ioperm(struct ucred *cred)
894{
895
896	return (0);
897}
898
899static int
900stub_check_system_acct(struct ucred *cred, struct vnode *vp,
901    struct label *vlabel)
902{
903
904	return (0);
905}
906
907static int
908stub_check_system_reboot(struct ucred *cred, int how)
909{
910
911	return (0);
912}
913
914static int
915stub_check_system_settime(struct ucred *cred)
916{
917
918	return (0);
919}
920
921static int
922stub_check_system_swapon(struct ucred *cred, struct vnode *vp,
923    struct label *label)
924{
925
926	return (0);
927}
928
929static int
930stub_check_system_swapoff(struct ucred *cred, struct vnode *vp,
931    struct label *label)
932{
933
934	return (0);
935}
936
937static int
938stub_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
945static int
946stub_check_vnode_access(struct ucred *cred, struct vnode *vp,
947    struct label *label, int acc_mode)
948{
949
950	return (0);
951}
952
953static int
954stub_check_vnode_chdir(struct ucred *cred, struct vnode *dvp,
955    struct label *dlabel)
956{
957
958	return (0);
959}
960
961static int
962stub_check_vnode_chroot(struct ucred *cred, struct vnode *dvp,
963    struct label *dlabel)
964{
965
966	return (0);
967}
968
969static int
970stub_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
977static int
978stub_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
986static int
987stub_check_vnode_deleteacl(struct ucred *cred, struct vnode *vp,
988    struct label *label, acl_type_t type)
989{
990
991	return (0);
992}
993
994static int
995stub_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
1002static int
1003stub_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
1011static int
1012stub_check_vnode_getacl(struct ucred *cred, struct vnode *vp,
1013    struct label *label, acl_type_t type)
1014{
1015
1016	return (0);
1017}
1018
1019static int
1020stub_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
1027static int
1028stub_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
1036static int
1037stub_check_vnode_listextattr(struct ucred *cred, struct vnode *vp,
1038    struct label *label, int attrnamespace)
1039{
1040
1041	return (0);
1042}
1043
1044static int
1045stub_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
1046    struct label *dlabel, struct componentname *cnp)
1047{
1048
1049	return (0);
1050}
1051
1052static int
1053stub_check_vnode_mmap(struct ucred *cred, struct vnode *vp,
1054    struct label *label, int prot)
1055{
1056
1057	return (0);
1058}
1059
1060static int
1061stub_check_vnode_open(struct ucred *cred, struct vnode *vp,
1062    struct label *filelabel, int acc_mode)
1063{
1064
1065	return (0);
1066}
1067
1068static int
1069stub_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
1076static int
1077stub_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
1084static int
1085stub_check_vnode_readdir(struct ucred *cred, struct vnode *vp,
1086    struct label *dlabel)
1087{
1088
1089	return (0);
1090}
1091
1092static int
1093stub_check_vnode_readlink(struct ucred *cred, struct vnode *vp,
1094    struct label *vnodelabel)
1095{
1096
1097	return (0);
1098}
1099
1100static int
1101stub_check_vnode_relabel(struct ucred *cred, struct vnode *vp,
1102    struct label *vnodelabel, struct label *newlabel)
1103{
1104
1105	return (0);
1106}
1107
1108static int
1109stub_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
1117static int
1118stub_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
1126static int
1127stub_check_vnode_revoke(struct ucred *cred, struct vnode *vp,
1128    struct label *label)
1129{
1130
1131	return (0);
1132}
1133
1134static int
1135stub_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
1142static int
1143stub_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
1150static int
1151stub_check_vnode_setflags(struct ucred *cred, struct vnode *vp,
1152    struct label *label, u_long flags)
1153{
1154
1155	return (0);
1156}
1157
1158static int
1159stub_check_vnode_setmode(struct ucred *cred, struct vnode *vp,
1160    struct label *label, mode_t mode)
1161{
1162
1163	return (0);
1164}
1165
1166static int
1167stub_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
1174static int
1175stub_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
1182static int
1183stub_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
1190static int
1191stub_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
1198static 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
1391MAC_POLICY_SET(&mac_stub_ops, mac_stub, "TrustedBSD MAC/Stub",
1392    MPC_LOADTIME_FLAG_UNLOADOK, NULL);
1393