2 * Copyright (c) 1999-2002 Robert N. M. Watson
3 * Copyright (c) 2001-2005 McAfee, Inc.
6 * This software was developed by Robert Watson for the TrustedBSD Project.
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.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
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.
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
38 * Developed by the TrustedBSD Project.
39 * MLS fixed label mandatory confidentiality policy.
42 #include <sys/types.h>
43 #include <sys/param.h>
46 #include <sys/extattr.h>
47 #include <sys/kernel.h>
50 #include <sys/malloc.h>
51 #include <sys/mount.h>
54 #include <sys/systm.h>
55 #include <sys/sysproto.h>
56 #include <sys/sysent.h>
57 #include <sys/systm.h>
58 #include <sys/vnode.h>
60 #include <sys/socket.h>
61 #include <sys/socketvar.h>
63 #include <sys/sysctl.h>
68 #include <posix4/ksem.h>
70 #include <fs/devfs/devfs.h>
72 #include <net/bpfdesc.h>
74 #include <net/if_types.h>
75 #include <net/if_var.h>
77 #include <netinet/in.h>
78 #include <netinet/in_pcb.h>
79 #include <netinet/ip_var.h>
84 #include <sys/mac_policy.h>
86 #include <security/mac_mls/mac_mls.h>
88 SYSCTL_DECL(_security_mac);
90 SYSCTL_NODE(_security_mac, OID_AUTO, mls, CTLFLAG_RW, 0,
91 "TrustedBSD mac_mls policy controls");
93 static int mac_mls_label_size = sizeof(struct mac_mls);
94 SYSCTL_INT(_security_mac_mls, OID_AUTO, label_size, CTLFLAG_RD,
95 &mac_mls_label_size, 0, "Size of struct mac_mls");
97 static int mac_mls_enabled = 1;
98 SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RW,
99 &mac_mls_enabled, 0, "Enforce MAC/MLS policy");
100 TUNABLE_INT("security.mac.mls.enabled", &mac_mls_enabled);
102 static int destroyed_not_inited;
103 SYSCTL_INT(_security_mac_mls, OID_AUTO, destroyed_not_inited, CTLFLAG_RD,
104 &destroyed_not_inited, 0, "Count of labels destroyed but not inited");
106 static int ptys_equal = 0;
107 SYSCTL_INT(_security_mac_mls, OID_AUTO, ptys_equal, CTLFLAG_RW,
108 &ptys_equal, 0, "Label pty devices as mls/equal on create");
109 TUNABLE_INT("security.mac.mls.ptys_equal", &ptys_equal);
111 static int revocation_enabled = 0;
112 SYSCTL_INT(_security_mac_mls, OID_AUTO, revocation_enabled, CTLFLAG_RW,
113 &revocation_enabled, 0, "Revoke access to objects on relabel");
114 TUNABLE_INT("security.mac.mls.revocation_enabled", &revocation_enabled);
116 static int max_compartments = MAC_MLS_MAX_COMPARTMENTS;
117 SYSCTL_INT(_security_mac_mls, OID_AUTO, max_compartments, CTLFLAG_RD,
118 &max_compartments, 0, "Maximum compartments the policy supports");
120 static int mac_mls_slot;
121 #define SLOT(l) ((struct mac_mls *)LABEL_TO_SLOT((l), mac_mls_slot).l_ptr)
122 #define SLOT_SET(l, val) (LABEL_TO_SLOT((l), mac_mls_slot).l_ptr = (val))
124 static uma_zone_t zone_mls;
127 mls_bit_set_empty(u_char *set) {
130 for (i = 0; i < MAC_MLS_MAX_COMPARTMENTS >> 3; i++)
136 static struct mac_mls *
140 return (uma_zalloc(zone_mls, flag | M_ZERO));
144 mls_free(struct mac_mls *mac_mls)
148 uma_zfree(zone_mls, mac_mls);
150 atomic_add_int(&destroyed_not_inited, 1);
154 mls_atmostflags(struct mac_mls *mac_mls, int flags)
157 if ((mac_mls->mm_flags & flags) != mac_mls->mm_flags)
163 mac_mls_dominate_element(struct mac_mls_element *a,
164 struct mac_mls_element *b)
168 switch (a->mme_type) {
169 case MAC_MLS_TYPE_EQUAL:
170 case MAC_MLS_TYPE_HIGH:
173 case MAC_MLS_TYPE_LOW:
174 switch (b->mme_type) {
175 case MAC_MLS_TYPE_LEVEL:
176 case MAC_MLS_TYPE_HIGH:
179 case MAC_MLS_TYPE_EQUAL:
180 case MAC_MLS_TYPE_LOW:
184 panic("mac_mls_dominate_element: b->mme_type invalid");
187 case MAC_MLS_TYPE_LEVEL:
188 switch (b->mme_type) {
189 case MAC_MLS_TYPE_EQUAL:
190 case MAC_MLS_TYPE_LOW:
193 case MAC_MLS_TYPE_HIGH:
196 case MAC_MLS_TYPE_LEVEL:
197 for (bit = 1; bit <= MAC_MLS_MAX_COMPARTMENTS; bit++)
198 if (!MAC_MLS_BIT_TEST(bit,
199 a->mme_compartments) &&
200 MAC_MLS_BIT_TEST(bit, b->mme_compartments))
202 return (a->mme_level >= b->mme_level);
205 panic("mac_mls_dominate_element: b->mme_type invalid");
209 panic("mac_mls_dominate_element: a->mme_type invalid");
216 mac_mls_range_in_range(struct mac_mls *rangea, struct mac_mls *rangeb)
219 return (mac_mls_dominate_element(&rangeb->mm_rangehigh,
220 &rangea->mm_rangehigh) &&
221 mac_mls_dominate_element(&rangea->mm_rangelow,
222 &rangeb->mm_rangelow));
226 mac_mls_effective_in_range(struct mac_mls *effective, struct mac_mls *range)
229 KASSERT((effective->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
230 ("mac_mls_effective_in_range: a not effective"));
231 KASSERT((range->mm_flags & MAC_MLS_FLAG_RANGE) != 0,
232 ("mac_mls_effective_in_range: b not range"));
234 return (mac_mls_dominate_element(&range->mm_rangehigh,
235 &effective->mm_effective) &&
236 mac_mls_dominate_element(&effective->mm_effective,
237 &range->mm_rangelow));
243 mac_mls_dominate_effective(struct mac_mls *a, struct mac_mls *b)
245 KASSERT((a->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
246 ("mac_mls_dominate_effective: a not effective"));
247 KASSERT((b->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
248 ("mac_mls_dominate_effective: b not effective"));
250 return (mac_mls_dominate_element(&a->mm_effective, &b->mm_effective));
254 mac_mls_equal_element(struct mac_mls_element *a, struct mac_mls_element *b)
257 if (a->mme_type == MAC_MLS_TYPE_EQUAL ||
258 b->mme_type == MAC_MLS_TYPE_EQUAL)
261 return (a->mme_type == b->mme_type && a->mme_level == b->mme_level);
265 mac_mls_equal_effective(struct mac_mls *a, struct mac_mls *b)
268 KASSERT((a->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
269 ("mac_mls_equal_effective: a not effective"));
270 KASSERT((b->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
271 ("mac_mls_equal_effective: b not effective"));
273 return (mac_mls_equal_element(&a->mm_effective, &b->mm_effective));
277 mac_mls_contains_equal(struct mac_mls *mac_mls)
280 if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE)
281 if (mac_mls->mm_effective.mme_type == MAC_MLS_TYPE_EQUAL)
284 if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) {
285 if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_EQUAL)
287 if (mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_EQUAL)
295 mac_mls_subject_privileged(struct mac_mls *mac_mls)
298 KASSERT((mac_mls->mm_flags & MAC_MLS_FLAGS_BOTH) ==
300 ("mac_mls_subject_privileged: subject doesn't have both labels"));
302 /* If the effective is EQUAL, it's ok. */
303 if (mac_mls->mm_effective.mme_type == MAC_MLS_TYPE_EQUAL)
306 /* If either range endpoint is EQUAL, it's ok. */
307 if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_EQUAL ||
308 mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_EQUAL)
311 /* If the range is low-high, it's ok. */
312 if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_LOW &&
313 mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_HIGH)
321 mac_mls_valid(struct mac_mls *mac_mls)
324 if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
325 switch (mac_mls->mm_effective.mme_type) {
326 case MAC_MLS_TYPE_LEVEL:
329 case MAC_MLS_TYPE_EQUAL:
330 case MAC_MLS_TYPE_HIGH:
331 case MAC_MLS_TYPE_LOW:
332 if (mac_mls->mm_effective.mme_level != 0 ||
333 !MAC_MLS_BIT_SET_EMPTY(
334 mac_mls->mm_effective.mme_compartments))
342 if (mac_mls->mm_effective.mme_type != MAC_MLS_TYPE_UNDEF)
346 if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) {
347 switch (mac_mls->mm_rangelow.mme_type) {
348 case MAC_MLS_TYPE_LEVEL:
351 case MAC_MLS_TYPE_EQUAL:
352 case MAC_MLS_TYPE_HIGH:
353 case MAC_MLS_TYPE_LOW:
354 if (mac_mls->mm_rangelow.mme_level != 0 ||
355 !MAC_MLS_BIT_SET_EMPTY(
356 mac_mls->mm_rangelow.mme_compartments))
364 switch (mac_mls->mm_rangehigh.mme_type) {
365 case MAC_MLS_TYPE_LEVEL:
368 case MAC_MLS_TYPE_EQUAL:
369 case MAC_MLS_TYPE_HIGH:
370 case MAC_MLS_TYPE_LOW:
371 if (mac_mls->mm_rangehigh.mme_level != 0 ||
372 !MAC_MLS_BIT_SET_EMPTY(
373 mac_mls->mm_rangehigh.mme_compartments))
380 if (!mac_mls_dominate_element(&mac_mls->mm_rangehigh,
381 &mac_mls->mm_rangelow))
384 if (mac_mls->mm_rangelow.mme_type != MAC_MLS_TYPE_UNDEF ||
385 mac_mls->mm_rangehigh.mme_type != MAC_MLS_TYPE_UNDEF)
393 mac_mls_set_range(struct mac_mls *mac_mls, u_short typelow,
394 u_short levellow, u_char *compartmentslow, u_short typehigh,
395 u_short levelhigh, u_char *compartmentshigh)
398 mac_mls->mm_rangelow.mme_type = typelow;
399 mac_mls->mm_rangelow.mme_level = levellow;
400 if (compartmentslow != NULL)
401 memcpy(mac_mls->mm_rangelow.mme_compartments,
403 sizeof(mac_mls->mm_rangelow.mme_compartments));
404 mac_mls->mm_rangehigh.mme_type = typehigh;
405 mac_mls->mm_rangehigh.mme_level = levelhigh;
406 if (compartmentshigh != NULL)
407 memcpy(mac_mls->mm_rangehigh.mme_compartments,
409 sizeof(mac_mls->mm_rangehigh.mme_compartments));
410 mac_mls->mm_flags |= MAC_MLS_FLAG_RANGE;
414 mac_mls_set_effective(struct mac_mls *mac_mls, u_short type, u_short level,
415 u_char *compartments)
418 mac_mls->mm_effective.mme_type = type;
419 mac_mls->mm_effective.mme_level = level;
420 if (compartments != NULL)
421 memcpy(mac_mls->mm_effective.mme_compartments, compartments,
422 sizeof(mac_mls->mm_effective.mme_compartments));
423 mac_mls->mm_flags |= MAC_MLS_FLAG_EFFECTIVE;
427 mac_mls_copy_range(struct mac_mls *labelfrom, struct mac_mls *labelto)
430 KASSERT((labelfrom->mm_flags & MAC_MLS_FLAG_RANGE) != 0,
431 ("mac_mls_copy_range: labelfrom not range"));
433 labelto->mm_rangelow = labelfrom->mm_rangelow;
434 labelto->mm_rangehigh = labelfrom->mm_rangehigh;
435 labelto->mm_flags |= MAC_MLS_FLAG_RANGE;
439 mac_mls_copy_effective(struct mac_mls *labelfrom, struct mac_mls *labelto)
442 KASSERT((labelfrom->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
443 ("mac_mls_copy_effective: labelfrom not effective"));
445 labelto->mm_effective = labelfrom->mm_effective;
446 labelto->mm_flags |= MAC_MLS_FLAG_EFFECTIVE;
450 mac_mls_copy(struct mac_mls *source, struct mac_mls *dest)
453 if (source->mm_flags & MAC_MLS_FLAG_EFFECTIVE)
454 mac_mls_copy_effective(source, dest);
455 if (source->mm_flags & MAC_MLS_FLAG_RANGE)
456 mac_mls_copy_range(source, dest);
460 * Policy module operations.
463 mac_mls_init(struct mac_policy_conf *conf)
466 zone_mls = uma_zcreate("mac_mls", sizeof(struct mac_mls), NULL,
467 NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
474 mac_mls_init_label(struct label *label)
477 SLOT_SET(label, mls_alloc(M_WAITOK));
481 mac_mls_init_label_waitcheck(struct label *label, int flag)
484 SLOT_SET(label, mls_alloc(flag));
485 if (SLOT(label) == NULL)
492 mac_mls_destroy_label(struct label *label)
495 mls_free(SLOT(label));
496 SLOT_SET(label, NULL);
500 * mac_mls_element_to_string() accepts an sbuf and MLS element. It
501 * converts the MLS element to a string and stores the result in the
502 * sbuf; if there isn't space in the sbuf, -1 is returned.
505 mac_mls_element_to_string(struct sbuf *sb, struct mac_mls_element *element)
509 switch (element->mme_type) {
510 case MAC_MLS_TYPE_HIGH:
511 return (sbuf_printf(sb, "high"));
513 case MAC_MLS_TYPE_LOW:
514 return (sbuf_printf(sb, "low"));
516 case MAC_MLS_TYPE_EQUAL:
517 return (sbuf_printf(sb, "equal"));
519 case MAC_MLS_TYPE_LEVEL:
520 if (sbuf_printf(sb, "%d", element->mme_level) == -1)
524 for (i = 1; i <= MAC_MLS_MAX_COMPARTMENTS; i++) {
525 if (MAC_MLS_BIT_TEST(i, element->mme_compartments)) {
527 if (sbuf_putc(sb, ':') == -1)
529 if (sbuf_printf(sb, "%d", i) == -1)
533 if (sbuf_printf(sb, "+%d", i) == -1)
541 panic("mac_mls_element_to_string: invalid type (%d)",
547 * mac_mls_to_string() converts an MLS label to a string, and places
548 * the results in the passed sbuf. It returns 0 on success, or EINVAL
549 * if there isn't room in the sbuf. Note: the sbuf will be modified
550 * even in a failure case, so the caller may need to revert the sbuf
551 * by restoring the offset if that's undesired.
554 mac_mls_to_string(struct sbuf *sb, struct mac_mls *mac_mls)
557 if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
558 if (mac_mls_element_to_string(sb, &mac_mls->mm_effective)
563 if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) {
564 if (sbuf_putc(sb, '(') == -1)
567 if (mac_mls_element_to_string(sb, &mac_mls->mm_rangelow)
571 if (sbuf_putc(sb, '-') == -1)
574 if (mac_mls_element_to_string(sb, &mac_mls->mm_rangehigh)
578 if (sbuf_putc(sb, ')') == -1)
586 mac_mls_externalize_label(struct label *label, char *element_name,
587 struct sbuf *sb, int *claimed)
589 struct mac_mls *mac_mls;
591 if (strcmp(MAC_MLS_LABEL_NAME, element_name) != 0)
596 mac_mls = SLOT(label);
598 return (mac_mls_to_string(sb, mac_mls));
602 mac_mls_parse_element(struct mac_mls_element *element, char *string)
604 char *compartment, *end, *level;
607 if (strcmp(string, "high") == 0 ||
608 strcmp(string, "hi") == 0) {
609 element->mme_type = MAC_MLS_TYPE_HIGH;
610 element->mme_level = MAC_MLS_TYPE_UNDEF;
611 } else if (strcmp(string, "low") == 0 ||
612 strcmp(string, "lo") == 0) {
613 element->mme_type = MAC_MLS_TYPE_LOW;
614 element->mme_level = MAC_MLS_TYPE_UNDEF;
615 } else if (strcmp(string, "equal") == 0 ||
616 strcmp(string, "eq") == 0) {
617 element->mme_type = MAC_MLS_TYPE_EQUAL;
618 element->mme_level = MAC_MLS_TYPE_UNDEF;
620 element->mme_type = MAC_MLS_TYPE_LEVEL;
623 * Numeric level piece of the element.
625 level = strsep(&string, ":");
626 value = strtol(level, &end, 10);
627 if (end == level || *end != '\0')
629 if (value < 0 || value > 65535)
631 element->mme_level = value;
634 * Optional compartment piece of the element. If none
635 * are included, we assume that the label has no
643 while ((compartment = strsep(&string, "+")) != NULL) {
644 value = strtol(compartment, &end, 10);
645 if (compartment == end || *end != '\0')
647 if (value < 1 || value > MAC_MLS_MAX_COMPARTMENTS)
649 MAC_MLS_BIT_SET(value, element->mme_compartments);
657 * Note: destructively consumes the string, make a local copy before
658 * calling if that's a problem.
661 mac_mls_parse(struct mac_mls *mac_mls, char *string)
663 char *rangehigh, *rangelow, *effective;
666 effective = strsep(&string, "(");
667 if (*effective == '\0')
670 if (string != NULL) {
671 rangelow = strsep(&string, "-");
674 rangehigh = strsep(&string, ")");
684 KASSERT((rangelow != NULL && rangehigh != NULL) ||
685 (rangelow == NULL && rangehigh == NULL),
686 ("mac_mls_parse: range mismatch"));
688 bzero(mac_mls, sizeof(*mac_mls));
689 if (effective != NULL) {
690 error = mac_mls_parse_element(&mac_mls->mm_effective, effective);
693 mac_mls->mm_flags |= MAC_MLS_FLAG_EFFECTIVE;
696 if (rangelow != NULL) {
697 error = mac_mls_parse_element(&mac_mls->mm_rangelow,
701 error = mac_mls_parse_element(&mac_mls->mm_rangehigh,
705 mac_mls->mm_flags |= MAC_MLS_FLAG_RANGE;
708 error = mac_mls_valid(mac_mls);
716 mac_mls_internalize_label(struct label *label, char *element_name,
717 char *element_data, int *claimed)
719 struct mac_mls *mac_mls, mac_mls_temp;
722 if (strcmp(MAC_MLS_LABEL_NAME, element_name) != 0)
727 error = mac_mls_parse(&mac_mls_temp, element_data);
731 mac_mls = SLOT(label);
732 *mac_mls = mac_mls_temp;
738 mac_mls_copy_label(struct label *src, struct label *dest)
741 *SLOT(dest) = *SLOT(src);
745 * Labeling event operations: file system objects, and things that look
746 * a lot like file system objects.
749 mac_mls_create_devfs_device(struct ucred *cred, struct mount *mp,
750 struct cdev *dev, struct devfs_dirent *devfs_dirent, struct label *label)
752 struct mac_mls *mac_mls;
755 mac_mls = SLOT(label);
756 if (strcmp(dev->si_name, "null") == 0 ||
757 strcmp(dev->si_name, "zero") == 0 ||
758 strcmp(dev->si_name, "random") == 0 ||
759 strncmp(dev->si_name, "fd/", strlen("fd/")) == 0)
760 mls_type = MAC_MLS_TYPE_EQUAL;
761 else if (strcmp(dev->si_name, "kmem") == 0 ||
762 strcmp(dev->si_name, "mem") == 0)
763 mls_type = MAC_MLS_TYPE_HIGH;
764 else if (ptys_equal &&
765 (strncmp(dev->si_name, "ttyp", strlen("ttyp")) == 0 ||
766 strncmp(dev->si_name, "ptyp", strlen("ptyp")) == 0))
767 mls_type = MAC_MLS_TYPE_EQUAL;
769 mls_type = MAC_MLS_TYPE_LOW;
770 mac_mls_set_effective(mac_mls, mls_type, 0, NULL);
774 mac_mls_create_devfs_directory(struct mount *mp, char *dirname,
775 int dirnamelen, struct devfs_dirent *devfs_dirent, struct label *label)
777 struct mac_mls *mac_mls;
779 mac_mls = SLOT(label);
780 mac_mls_set_effective(mac_mls, MAC_MLS_TYPE_LOW, 0, NULL);
784 mac_mls_create_devfs_symlink(struct ucred *cred, struct mount *mp,
785 struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de,
786 struct label *delabel)
788 struct mac_mls *source, *dest;
790 source = SLOT(cred->cr_label);
791 dest = SLOT(delabel);
793 mac_mls_copy_effective(source, dest);
797 mac_mls_create_mount(struct ucred *cred, struct mount *mp,
798 struct label *mntlabel, struct label *fslabel)
800 struct mac_mls *source, *dest;
802 source = SLOT(cred->cr_label);
803 dest = SLOT(mntlabel);
804 mac_mls_copy_effective(source, dest);
805 dest = SLOT(fslabel);
806 mac_mls_copy_effective(source, dest);
810 mac_mls_relabel_vnode(struct ucred *cred, struct vnode *vp,
811 struct label *vnodelabel, struct label *label)
813 struct mac_mls *source, *dest;
815 source = SLOT(label);
816 dest = SLOT(vnodelabel);
818 mac_mls_copy(source, dest);
822 mac_mls_update_devfsdirent(struct mount *mp,
823 struct devfs_dirent *devfs_dirent, struct label *direntlabel,
824 struct vnode *vp, struct label *vnodelabel)
826 struct mac_mls *source, *dest;
828 source = SLOT(vnodelabel);
829 dest = SLOT(direntlabel);
831 mac_mls_copy_effective(source, dest);
835 mac_mls_associate_vnode_devfs(struct mount *mp, struct label *fslabel,
836 struct devfs_dirent *de, struct label *delabel, struct vnode *vp,
837 struct label *vlabel)
839 struct mac_mls *source, *dest;
841 source = SLOT(delabel);
844 mac_mls_copy_effective(source, dest);
848 mac_mls_associate_vnode_extattr(struct mount *mp, struct label *fslabel,
849 struct vnode *vp, struct label *vlabel)
851 struct mac_mls temp, *source, *dest;
854 source = SLOT(fslabel);
857 buflen = sizeof(temp);
858 bzero(&temp, buflen);
860 error = vn_extattr_get(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE,
861 MAC_MLS_EXTATTR_NAME, &buflen, (char *) &temp, curthread);
862 if (error == ENOATTR || error == EOPNOTSUPP) {
863 /* Fall back to the fslabel. */
864 mac_mls_copy_effective(source, dest);
869 if (buflen != sizeof(temp)) {
870 printf("mac_mls_associate_vnode_extattr: bad size %d\n",
874 if (mac_mls_valid(&temp) != 0) {
875 printf("mac_mls_associate_vnode_extattr: invalid\n");
878 if ((temp.mm_flags & MAC_MLS_FLAGS_BOTH) != MAC_MLS_FLAG_EFFECTIVE) {
879 printf("mac_mls_associated_vnode_extattr: not effective\n");
883 mac_mls_copy_effective(&temp, dest);
888 mac_mls_associate_vnode_singlelabel(struct mount *mp,
889 struct label *fslabel, struct vnode *vp, struct label *vlabel)
891 struct mac_mls *source, *dest;
893 source = SLOT(fslabel);
896 mac_mls_copy_effective(source, dest);
900 mac_mls_create_vnode_extattr(struct ucred *cred, struct mount *mp,
901 struct label *fslabel, struct vnode *dvp, struct label *dlabel,
902 struct vnode *vp, struct label *vlabel, struct componentname *cnp)
904 struct mac_mls *source, *dest, temp;
908 buflen = sizeof(temp);
909 bzero(&temp, buflen);
911 source = SLOT(cred->cr_label);
913 mac_mls_copy_effective(source, &temp);
915 error = vn_extattr_set(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE,
916 MAC_MLS_EXTATTR_NAME, buflen, (char *) &temp, curthread);
918 mac_mls_copy_effective(source, dest);
923 mac_mls_setlabel_vnode_extattr(struct ucred *cred, struct vnode *vp,
924 struct label *vlabel, struct label *intlabel)
926 struct mac_mls *source, temp;
930 buflen = sizeof(temp);
931 bzero(&temp, buflen);
933 source = SLOT(intlabel);
934 if ((source->mm_flags & MAC_MLS_FLAG_EFFECTIVE) == 0)
937 mac_mls_copy_effective(source, &temp);
939 error = vn_extattr_set(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE,
940 MAC_MLS_EXTATTR_NAME, buflen, (char *) &temp, curthread);
945 * Labeling event operations: IPC object.
948 mac_mls_create_inpcb_from_socket(struct socket *so, struct label *solabel,
949 struct inpcb *inp, struct label *inplabel)
951 struct mac_mls *source, *dest;
953 source = SLOT(solabel);
954 dest = SLOT(inplabel);
956 mac_mls_copy_effective(source, dest);
960 mac_mls_create_mbuf_from_socket(struct socket *so, struct label *socketlabel,
961 struct mbuf *m, struct label *mbuflabel)
963 struct mac_mls *source, *dest;
965 source = SLOT(socketlabel);
966 dest = SLOT(mbuflabel);
968 mac_mls_copy_effective(source, dest);
972 mac_mls_create_socket(struct ucred *cred, struct socket *socket,
973 struct label *socketlabel)
975 struct mac_mls *source, *dest;
977 source = SLOT(cred->cr_label);
978 dest = SLOT(socketlabel);
980 mac_mls_copy_effective(source, dest);
984 mac_mls_create_pipe(struct ucred *cred, struct pipepair *pp,
985 struct label *pipelabel)
987 struct mac_mls *source, *dest;
989 source = SLOT(cred->cr_label);
990 dest = SLOT(pipelabel);
992 mac_mls_copy_effective(source, dest);
996 mac_mls_create_posix_sem(struct ucred *cred, struct ksem *ksemptr,
997 struct label *ks_label)
999 struct mac_mls *source, *dest;
1001 source = SLOT(cred->cr_label);
1002 dest = SLOT(ks_label);
1004 mac_mls_copy_effective(source, dest);
1008 mac_mls_create_socket_from_socket(struct socket *oldsocket,
1009 struct label *oldsocketlabel, struct socket *newsocket,
1010 struct label *newsocketlabel)
1012 struct mac_mls *source, *dest;
1014 source = SLOT(oldsocketlabel);
1015 dest = SLOT(newsocketlabel);
1017 mac_mls_copy_effective(source, dest);
1021 mac_mls_relabel_socket(struct ucred *cred, struct socket *socket,
1022 struct label *socketlabel, struct label *newlabel)
1024 struct mac_mls *source, *dest;
1026 source = SLOT(newlabel);
1027 dest = SLOT(socketlabel);
1029 mac_mls_copy(source, dest);
1033 mac_mls_relabel_pipe(struct ucred *cred, struct pipepair *pp,
1034 struct label *pipelabel, struct label *newlabel)
1036 struct mac_mls *source, *dest;
1038 source = SLOT(newlabel);
1039 dest = SLOT(pipelabel);
1041 mac_mls_copy(source, dest);
1045 mac_mls_set_socket_peer_from_mbuf(struct mbuf *mbuf, struct label *mbuflabel,
1046 struct socket *socket, struct label *socketpeerlabel)
1048 struct mac_mls *source, *dest;
1050 source = SLOT(mbuflabel);
1051 dest = SLOT(socketpeerlabel);
1053 mac_mls_copy_effective(source, dest);
1057 * Labeling event operations: System V IPC objects.
1061 mac_mls_create_sysv_msgmsg(struct ucred *cred, struct msqid_kernel *msqkptr,
1062 struct label *msqlabel, struct msg *msgptr, struct label *msglabel)
1064 struct mac_mls *source, *dest;
1066 /* Ignore the msgq label */
1067 source = SLOT(cred->cr_label);
1068 dest = SLOT(msglabel);
1070 mac_mls_copy_effective(source, dest);
1074 mac_mls_create_sysv_msgqueue(struct ucred *cred, struct msqid_kernel *msqkptr,
1075 struct label *msqlabel)
1077 struct mac_mls *source, *dest;
1079 source = SLOT(cred->cr_label);
1080 dest = SLOT(msqlabel);
1082 mac_mls_copy_effective(source, dest);
1086 mac_mls_create_sysv_sem(struct ucred *cred, struct semid_kernel *semakptr,
1087 struct label *semalabel)
1089 struct mac_mls *source, *dest;
1091 source = SLOT(cred->cr_label);
1092 dest = SLOT(semalabel);
1094 mac_mls_copy_effective(source, dest);
1098 mac_mls_create_sysv_shm(struct ucred *cred, struct shmid_kernel *shmsegptr,
1099 struct label *shmlabel)
1101 struct mac_mls *source, *dest;
1103 source = SLOT(cred->cr_label);
1104 dest = SLOT(shmlabel);
1106 mac_mls_copy_effective(source, dest);
1110 * Labeling event operations: network objects.
1113 mac_mls_set_socket_peer_from_socket(struct socket *oldsocket,
1114 struct label *oldsocketlabel, struct socket *newsocket,
1115 struct label *newsocketpeerlabel)
1117 struct mac_mls *source, *dest;
1119 source = SLOT(oldsocketlabel);
1120 dest = SLOT(newsocketpeerlabel);
1122 mac_mls_copy_effective(source, dest);
1126 mac_mls_create_bpfdesc(struct ucred *cred, struct bpf_d *bpf_d,
1127 struct label *bpflabel)
1129 struct mac_mls *source, *dest;
1131 source = SLOT(cred->cr_label);
1132 dest = SLOT(bpflabel);
1134 mac_mls_copy_effective(source, dest);
1138 mac_mls_create_ifnet(struct ifnet *ifnet, struct label *ifnetlabel)
1140 struct mac_mls *dest;
1143 dest = SLOT(ifnetlabel);
1145 if (ifnet->if_type == IFT_LOOP)
1146 type = MAC_MLS_TYPE_EQUAL;
1148 type = MAC_MLS_TYPE_LOW;
1150 mac_mls_set_effective(dest, type, 0, NULL);
1151 mac_mls_set_range(dest, type, 0, NULL, type, 0, NULL);
1155 mac_mls_create_ipq(struct mbuf *fragment, struct label *fragmentlabel,
1156 struct ipq *ipq, struct label *ipqlabel)
1158 struct mac_mls *source, *dest;
1160 source = SLOT(fragmentlabel);
1161 dest = SLOT(ipqlabel);
1163 mac_mls_copy_effective(source, dest);
1167 mac_mls_create_datagram_from_ipq(struct ipq *ipq, struct label *ipqlabel,
1168 struct mbuf *datagram, struct label *datagramlabel)
1170 struct mac_mls *source, *dest;
1172 source = SLOT(ipqlabel);
1173 dest = SLOT(datagramlabel);
1175 /* Just use the head, since we require them all to match. */
1176 mac_mls_copy_effective(source, dest);
1180 mac_mls_create_fragment(struct mbuf *datagram, struct label *datagramlabel,
1181 struct mbuf *fragment, struct label *fragmentlabel)
1183 struct mac_mls *source, *dest;
1185 source = SLOT(datagramlabel);
1186 dest = SLOT(fragmentlabel);
1188 mac_mls_copy_effective(source, dest);
1192 mac_mls_create_mbuf_from_inpcb(struct inpcb *inp, struct label *inplabel,
1193 struct mbuf *m, struct label *mlabel)
1195 struct mac_mls *source, *dest;
1197 source = SLOT(inplabel);
1198 dest = SLOT(mlabel);
1200 mac_mls_copy_effective(source, dest);
1204 mac_mls_create_mbuf_linklayer(struct ifnet *ifnet, struct label *ifnetlabel,
1205 struct mbuf *mbuf, struct label *mbuflabel)
1207 struct mac_mls *dest;
1209 dest = SLOT(mbuflabel);
1211 mac_mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL);
1215 mac_mls_create_mbuf_from_bpfdesc(struct bpf_d *bpf_d, struct label *bpflabel,
1216 struct mbuf *mbuf, struct label *mbuflabel)
1218 struct mac_mls *source, *dest;
1220 source = SLOT(bpflabel);
1221 dest = SLOT(mbuflabel);
1223 mac_mls_copy_effective(source, dest);
1227 mac_mls_create_mbuf_from_ifnet(struct ifnet *ifnet, struct label *ifnetlabel,
1228 struct mbuf *m, struct label *mbuflabel)
1230 struct mac_mls *source, *dest;
1232 source = SLOT(ifnetlabel);
1233 dest = SLOT(mbuflabel);
1235 mac_mls_copy_effective(source, dest);
1239 mac_mls_create_mbuf_multicast_encap(struct mbuf *oldmbuf,
1240 struct label *oldmbuflabel, struct ifnet *ifnet, struct label *ifnetlabel,
1241 struct mbuf *newmbuf, struct label *newmbuflabel)
1243 struct mac_mls *source, *dest;
1245 source = SLOT(oldmbuflabel);
1246 dest = SLOT(newmbuflabel);
1248 mac_mls_copy_effective(source, dest);
1252 mac_mls_create_mbuf_netlayer(struct mbuf *oldmbuf, struct label *oldmbuflabel,
1253 struct mbuf *newmbuf, struct label *newmbuflabel)
1255 struct mac_mls *source, *dest;
1257 source = SLOT(oldmbuflabel);
1258 dest = SLOT(newmbuflabel);
1260 mac_mls_copy_effective(source, dest);
1264 mac_mls_fragment_match(struct mbuf *fragment, struct label *fragmentlabel,
1265 struct ipq *ipq, struct label *ipqlabel)
1267 struct mac_mls *a, *b;
1270 b = SLOT(fragmentlabel);
1272 return (mac_mls_equal_effective(a, b));
1276 mac_mls_relabel_ifnet(struct ucred *cred, struct ifnet *ifnet,
1277 struct label *ifnetlabel, struct label *newlabel)
1279 struct mac_mls *source, *dest;
1281 source = SLOT(newlabel);
1282 dest = SLOT(ifnetlabel);
1284 mac_mls_copy(source, dest);
1288 mac_mls_update_ipq(struct mbuf *fragment, struct label *fragmentlabel,
1289 struct ipq *ipq, struct label *ipqlabel)
1292 /* NOOP: we only accept matching labels, so no need to update */
1296 mac_mls_inpcb_sosetlabel(struct socket *so, struct label *solabel,
1297 struct inpcb *inp, struct label *inplabel)
1299 struct mac_mls *source, *dest;
1301 source = SLOT(solabel);
1302 dest = SLOT(inplabel);
1304 mac_mls_copy(source, dest);
1308 * Labeling event operations: processes.
1311 mac_mls_create_proc0(struct ucred *cred)
1313 struct mac_mls *dest;
1315 dest = SLOT(cred->cr_label);
1317 mac_mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL);
1318 mac_mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH,
1323 mac_mls_create_proc1(struct ucred *cred)
1325 struct mac_mls *dest;
1327 dest = SLOT(cred->cr_label);
1329 mac_mls_set_effective(dest, MAC_MLS_TYPE_LOW, 0, NULL);
1330 mac_mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH,
1335 mac_mls_relabel_cred(struct ucred *cred, struct label *newlabel)
1337 struct mac_mls *source, *dest;
1339 source = SLOT(newlabel);
1340 dest = SLOT(cred->cr_label);
1342 mac_mls_copy(source, dest);
1346 * Label cleanup/flush operations.
1349 mac_mls_cleanup_sysv_msgmsg(struct label *msglabel)
1352 bzero(SLOT(msglabel), sizeof(struct mac_mls));
1356 mac_mls_cleanup_sysv_msgqueue(struct label *msqlabel)
1359 bzero(SLOT(msqlabel), sizeof(struct mac_mls));
1363 mac_mls_cleanup_sysv_sem(struct label *semalabel)
1366 bzero(SLOT(semalabel), sizeof(struct mac_mls));
1370 mac_mls_cleanup_sysv_shm(struct label *shmlabel)
1373 bzero(SLOT(shmlabel), sizeof(struct mac_mls));
1377 * Access control checks.
1380 mac_mls_check_bpfdesc_receive(struct bpf_d *bpf_d, struct label *bpflabel,
1381 struct ifnet *ifnet, struct label *ifnetlabel)
1383 struct mac_mls *a, *b;
1385 if (!mac_mls_enabled)
1389 b = SLOT(ifnetlabel);
1391 if (mac_mls_equal_effective(a, b))
1397 mac_mls_check_cred_relabel(struct ucred *cred, struct label *newlabel)
1399 struct mac_mls *subj, *new;
1402 subj = SLOT(cred->cr_label);
1403 new = SLOT(newlabel);
1406 * If there is an MLS label update for the credential, it may be
1407 * an update of effective, range, or both.
1409 error = mls_atmostflags(new, MAC_MLS_FLAGS_BOTH);
1414 * If the MLS label is to be changed, authorize as appropriate.
1416 if (new->mm_flags & MAC_MLS_FLAGS_BOTH) {
1418 * If the change request modifies both the MLS label effective
1419 * and range, check that the new effective will be in the
1422 if ((new->mm_flags & MAC_MLS_FLAGS_BOTH) ==
1423 MAC_MLS_FLAGS_BOTH &&
1424 !mac_mls_effective_in_range(new, new))
1428 * To change the MLS effective label on a credential, the
1429 * new effective label must be in the current range.
1431 if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE &&
1432 !mac_mls_effective_in_range(new, subj))
1436 * To change the MLS range label on a credential, the
1437 * new range must be in the current range.
1439 if (new->mm_flags & MAC_MLS_FLAG_RANGE &&
1440 !mac_mls_range_in_range(new, subj))
1444 * To have EQUAL in any component of the new credential
1445 * MLS label, the subject must already have EQUAL in
1448 if (mac_mls_contains_equal(new)) {
1449 error = mac_mls_subject_privileged(subj);
1459 mac_mls_check_cred_visible(struct ucred *u1, struct ucred *u2)
1461 struct mac_mls *subj, *obj;
1463 if (!mac_mls_enabled)
1466 subj = SLOT(u1->cr_label);
1467 obj = SLOT(u2->cr_label);
1470 if (!mac_mls_dominate_effective(subj, obj))
1477 mac_mls_check_ifnet_relabel(struct ucred *cred, struct ifnet *ifnet,
1478 struct label *ifnetlabel, struct label *newlabel)
1480 struct mac_mls *subj, *new;
1483 subj = SLOT(cred->cr_label);
1484 new = SLOT(newlabel);
1487 * If there is an MLS label update for the interface, it may
1488 * be an update of effective, range, or both.
1490 error = mls_atmostflags(new, MAC_MLS_FLAGS_BOTH);
1495 * Relabeling network interfaces requires MLS privilege.
1497 error = mac_mls_subject_privileged(subj);
1503 mac_mls_check_ifnet_transmit(struct ifnet *ifnet, struct label *ifnetlabel,
1504 struct mbuf *m, struct label *mbuflabel)
1506 struct mac_mls *p, *i;
1508 if (!mac_mls_enabled)
1511 p = SLOT(mbuflabel);
1512 i = SLOT(ifnetlabel);
1514 return (mac_mls_effective_in_range(p, i) ? 0 : EACCES);
1518 mac_mls_check_inpcb_deliver(struct inpcb *inp, struct label *inplabel,
1519 struct mbuf *m, struct label *mlabel)
1521 struct mac_mls *p, *i;
1523 if (!mac_mls_enabled)
1529 return (mac_mls_equal_effective(p, i) ? 0 : EACCES);
1533 mac_mls_check_sysv_msgrcv(struct ucred *cred, struct msg *msgptr,
1534 struct label *msglabel)
1536 struct mac_mls *subj, *obj;
1538 if (!mac_mls_enabled)
1541 subj = SLOT(cred->cr_label);
1542 obj = SLOT(msglabel);
1544 if (!mac_mls_dominate_effective(subj, obj))
1551 mac_mls_check_sysv_msgrmid(struct ucred *cred, struct msg *msgptr,
1552 struct label *msglabel)
1554 struct mac_mls *subj, *obj;
1556 if (!mac_mls_enabled)
1559 subj = SLOT(cred->cr_label);
1560 obj = SLOT(msglabel);
1562 if (!mac_mls_dominate_effective(obj, subj))
1569 mac_mls_check_sysv_msqget(struct ucred *cred, struct msqid_kernel *msqkptr,
1570 struct label *msqklabel)
1572 struct mac_mls *subj, *obj;
1574 if (!mac_mls_enabled)
1577 subj = SLOT(cred->cr_label);
1578 obj = SLOT(msqklabel);
1580 if (!mac_mls_dominate_effective(subj, obj))
1587 mac_mls_check_sysv_msqsnd(struct ucred *cred, struct msqid_kernel *msqkptr,
1588 struct label *msqklabel)
1590 struct mac_mls *subj, *obj;
1592 if (!mac_mls_enabled)
1595 subj = SLOT(cred->cr_label);
1596 obj = SLOT(msqklabel);
1598 if (!mac_mls_dominate_effective(obj, subj))
1605 mac_mls_check_sysv_msqrcv(struct ucred *cred, struct msqid_kernel *msqkptr,
1606 struct label *msqklabel)
1608 struct mac_mls *subj, *obj;
1610 if (!mac_mls_enabled)
1613 subj = SLOT(cred->cr_label);
1614 obj = SLOT(msqklabel);
1616 if (!mac_mls_dominate_effective(subj, obj))
1623 mac_mls_check_sysv_msqctl(struct ucred *cred, struct msqid_kernel *msqkptr,
1624 struct label *msqklabel, int cmd)
1626 struct mac_mls *subj, *obj;
1628 if (!mac_mls_enabled)
1631 subj = SLOT(cred->cr_label);
1632 obj = SLOT(msqklabel);
1637 if (!mac_mls_dominate_effective(obj, subj))
1642 if (!mac_mls_dominate_effective(subj, obj))
1654 mac_mls_check_sysv_semctl(struct ucred *cred, struct semid_kernel *semakptr,
1655 struct label *semaklabel, int cmd)
1657 struct mac_mls *subj, *obj;
1659 if (!mac_mls_enabled)
1662 subj = SLOT(cred->cr_label);
1663 obj = SLOT(semaklabel);
1670 if (!mac_mls_dominate_effective(obj, subj))
1680 if (!mac_mls_dominate_effective(subj, obj))
1692 mac_mls_check_sysv_semget(struct ucred *cred, struct semid_kernel *semakptr,
1693 struct label *semaklabel)
1695 struct mac_mls *subj, *obj;
1697 if (!mac_mls_enabled)
1700 subj = SLOT(cred->cr_label);
1701 obj = SLOT(semaklabel);
1703 if (!mac_mls_dominate_effective(subj, obj))
1710 mac_mls_check_sysv_semop(struct ucred *cred, struct semid_kernel *semakptr,
1711 struct label *semaklabel, size_t accesstype)
1713 struct mac_mls *subj, *obj;
1715 if (!mac_mls_enabled)
1718 subj = SLOT(cred->cr_label);
1719 obj = SLOT(semaklabel);
1721 if( accesstype & SEM_R )
1722 if (!mac_mls_dominate_effective(subj, obj))
1725 if( accesstype & SEM_A )
1726 if (!mac_mls_dominate_effective(obj, subj))
1733 mac_mls_check_sysv_shmat(struct ucred *cred, struct shmid_kernel *shmsegptr,
1734 struct label *shmseglabel, int shmflg)
1736 struct mac_mls *subj, *obj;
1738 if (!mac_mls_enabled)
1741 subj = SLOT(cred->cr_label);
1742 obj = SLOT(shmseglabel);
1744 if (!mac_mls_dominate_effective(subj, obj))
1746 if ((shmflg & SHM_RDONLY) == 0)
1747 if (!mac_mls_dominate_effective(obj, subj))
1754 mac_mls_check_sysv_shmctl(struct ucred *cred, struct shmid_kernel *shmsegptr,
1755 struct label *shmseglabel, int cmd)
1757 struct mac_mls *subj, *obj;
1759 if (!mac_mls_enabled)
1762 subj = SLOT(cred->cr_label);
1763 obj = SLOT(shmseglabel);
1768 if (!mac_mls_dominate_effective(obj, subj))
1774 if (!mac_mls_dominate_effective(subj, obj))
1786 mac_mls_check_sysv_shmget(struct ucred *cred, struct shmid_kernel *shmsegptr,
1787 struct label *shmseglabel, int shmflg)
1789 struct mac_mls *subj, *obj;
1791 if (!mac_mls_enabled)
1794 subj = SLOT(cred->cr_label);
1795 obj = SLOT(shmseglabel);
1797 if (!mac_mls_dominate_effective(obj, subj))
1804 mac_mls_check_mount_stat(struct ucred *cred, struct mount *mp,
1805 struct label *mntlabel)
1807 struct mac_mls *subj, *obj;
1809 if (!mac_mls_enabled)
1812 subj = SLOT(cred->cr_label);
1813 obj = SLOT(mntlabel);
1815 if (!mac_mls_dominate_effective(subj, obj))
1822 mac_mls_check_pipe_ioctl(struct ucred *cred, struct pipepair *pp,
1823 struct label *pipelabel, unsigned long cmd, void /* caddr_t */ *data)
1826 if(!mac_mls_enabled)
1829 /* XXX: This will be implemented soon... */
1835 mac_mls_check_pipe_poll(struct ucred *cred, struct pipepair *pp,
1836 struct label *pipelabel)
1838 struct mac_mls *subj, *obj;
1840 if (!mac_mls_enabled)
1843 subj = SLOT(cred->cr_label);
1844 obj = SLOT((pipelabel));
1846 if (!mac_mls_dominate_effective(subj, obj))
1853 mac_mls_check_pipe_read(struct ucred *cred, struct pipepair *pp,
1854 struct label *pipelabel)
1856 struct mac_mls *subj, *obj;
1858 if (!mac_mls_enabled)
1861 subj = SLOT(cred->cr_label);
1862 obj = SLOT((pipelabel));
1864 if (!mac_mls_dominate_effective(subj, obj))
1871 mac_mls_check_pipe_relabel(struct ucred *cred, struct pipepair *pp,
1872 struct label *pipelabel, struct label *newlabel)
1874 struct mac_mls *subj, *obj, *new;
1877 new = SLOT(newlabel);
1878 subj = SLOT(cred->cr_label);
1879 obj = SLOT(pipelabel);
1882 * If there is an MLS label update for a pipe, it must be a
1885 error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE);
1890 * To perform a relabel of a pipe (MLS label or not), MLS must
1891 * authorize the relabel.
1893 if (!mac_mls_effective_in_range(obj, subj))
1897 * If the MLS label is to be changed, authorize as appropriate.
1899 if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
1901 * To change the MLS label on a pipe, the new pipe label
1902 * must be in the subject range.
1904 if (!mac_mls_effective_in_range(new, subj))
1908 * To change the MLS label on a pipe to be EQUAL, the
1909 * subject must have appropriate privilege.
1911 if (mac_mls_contains_equal(new)) {
1912 error = mac_mls_subject_privileged(subj);
1922 mac_mls_check_pipe_stat(struct ucred *cred, struct pipepair *pp,
1923 struct label *pipelabel)
1925 struct mac_mls *subj, *obj;
1927 if (!mac_mls_enabled)
1930 subj = SLOT(cred->cr_label);
1931 obj = SLOT((pipelabel));
1933 if (!mac_mls_dominate_effective(subj, obj))
1940 mac_mls_check_pipe_write(struct ucred *cred, struct pipepair *pp,
1941 struct label *pipelabel)
1943 struct mac_mls *subj, *obj;
1945 if (!mac_mls_enabled)
1948 subj = SLOT(cred->cr_label);
1949 obj = SLOT((pipelabel));
1951 if (!mac_mls_dominate_effective(obj, subj))
1958 mac_mls_check_posix_sem_write(struct ucred *cred, struct ksem *ksemptr,
1959 struct label *ks_label)
1961 struct mac_mls *subj, *obj;
1963 if (!mac_mls_enabled)
1966 subj = SLOT(cred->cr_label);
1967 obj = SLOT(ks_label);
1969 if (!mac_mls_dominate_effective(obj, subj))
1976 mac_mls_check_posix_sem_rdonly(struct ucred *cred, struct ksem *ksemptr,
1977 struct label *ks_label)
1979 struct mac_mls *subj, *obj;
1981 if (!mac_mls_enabled)
1984 subj = SLOT(cred->cr_label);
1985 obj = SLOT(ks_label);
1987 if (!mac_mls_dominate_effective(subj, obj))
1994 mac_mls_check_proc_debug(struct ucred *cred, struct proc *proc)
1996 struct mac_mls *subj, *obj;
1998 if (!mac_mls_enabled)
2001 subj = SLOT(cred->cr_label);
2002 obj = SLOT(proc->p_ucred->cr_label);
2004 /* XXX: range checks */
2005 if (!mac_mls_dominate_effective(subj, obj))
2007 if (!mac_mls_dominate_effective(obj, subj))
2014 mac_mls_check_proc_sched(struct ucred *cred, struct proc *proc)
2016 struct mac_mls *subj, *obj;
2018 if (!mac_mls_enabled)
2021 subj = SLOT(cred->cr_label);
2022 obj = SLOT(proc->p_ucred->cr_label);
2024 /* XXX: range checks */
2025 if (!mac_mls_dominate_effective(subj, obj))
2027 if (!mac_mls_dominate_effective(obj, subj))
2034 mac_mls_check_proc_signal(struct ucred *cred, struct proc *proc, int signum)
2036 struct mac_mls *subj, *obj;
2038 if (!mac_mls_enabled)
2041 subj = SLOT(cred->cr_label);
2042 obj = SLOT(proc->p_ucred->cr_label);
2044 /* XXX: range checks */
2045 if (!mac_mls_dominate_effective(subj, obj))
2047 if (!mac_mls_dominate_effective(obj, subj))
2054 mac_mls_check_socket_deliver(struct socket *so, struct label *socketlabel,
2055 struct mbuf *m, struct label *mbuflabel)
2057 struct mac_mls *p, *s;
2059 if (!mac_mls_enabled)
2062 p = SLOT(mbuflabel);
2063 s = SLOT(socketlabel);
2065 return (mac_mls_equal_effective(p, s) ? 0 : EACCES);
2069 mac_mls_check_socket_relabel(struct ucred *cred, struct socket *socket,
2070 struct label *socketlabel, struct label *newlabel)
2072 struct mac_mls *subj, *obj, *new;
2075 new = SLOT(newlabel);
2076 subj = SLOT(cred->cr_label);
2077 obj = SLOT(socketlabel);
2080 * If there is an MLS label update for the socket, it may be
2081 * an update of effective.
2083 error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE);
2088 * To relabel a socket, the old socket effective must be in the subject
2091 if (!mac_mls_effective_in_range(obj, subj))
2095 * If the MLS label is to be changed, authorize as appropriate.
2097 if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
2099 * To relabel a socket, the new socket effective must be in
2100 * the subject range.
2102 if (!mac_mls_effective_in_range(new, subj))
2106 * To change the MLS label on the socket to contain EQUAL,
2107 * the subject must have appropriate privilege.
2109 if (mac_mls_contains_equal(new)) {
2110 error = mac_mls_subject_privileged(subj);
2120 mac_mls_check_socket_visible(struct ucred *cred, struct socket *socket,
2121 struct label *socketlabel)
2123 struct mac_mls *subj, *obj;
2125 if (!mac_mls_enabled)
2128 subj = SLOT(cred->cr_label);
2129 obj = SLOT(socketlabel);
2131 if (!mac_mls_dominate_effective(subj, obj))
2138 mac_mls_check_system_swapon(struct ucred *cred, struct vnode *vp,
2139 struct label *label)
2141 struct mac_mls *subj, *obj;
2143 if (!mac_mls_enabled)
2146 subj = SLOT(cred->cr_label);
2149 if (!mac_mls_dominate_effective(obj, subj) ||
2150 !mac_mls_dominate_effective(subj, obj))
2157 mac_mls_check_vnode_chdir(struct ucred *cred, struct vnode *dvp,
2158 struct label *dlabel)
2160 struct mac_mls *subj, *obj;
2162 if (!mac_mls_enabled)
2165 subj = SLOT(cred->cr_label);
2168 if (!mac_mls_dominate_effective(subj, obj))
2175 mac_mls_check_vnode_chroot(struct ucred *cred, struct vnode *dvp,
2176 struct label *dlabel)
2178 struct mac_mls *subj, *obj;
2180 if (!mac_mls_enabled)
2183 subj = SLOT(cred->cr_label);
2186 if (!mac_mls_dominate_effective(subj, obj))
2193 mac_mls_check_vnode_create(struct ucred *cred, struct vnode *dvp,
2194 struct label *dlabel, struct componentname *cnp, struct vattr *vap)
2196 struct mac_mls *subj, *obj;
2198 if (!mac_mls_enabled)
2201 subj = SLOT(cred->cr_label);
2204 if (!mac_mls_dominate_effective(obj, subj))
2211 mac_mls_check_vnode_delete(struct ucred *cred, struct vnode *dvp,
2212 struct label *dlabel, struct vnode *vp, struct label *label,
2213 struct componentname *cnp)
2215 struct mac_mls *subj, *obj;
2217 if (!mac_mls_enabled)
2220 subj = SLOT(cred->cr_label);
2223 if (!mac_mls_dominate_effective(obj, subj))
2228 if (!mac_mls_dominate_effective(obj, subj))
2235 mac_mls_check_vnode_deleteacl(struct ucred *cred, struct vnode *vp,
2236 struct label *label, acl_type_t type)
2238 struct mac_mls *subj, *obj;
2240 if (!mac_mls_enabled)
2243 subj = SLOT(cred->cr_label);
2246 if (!mac_mls_dominate_effective(obj, subj))
2253 mac_mls_check_vnode_deleteextattr(struct ucred *cred, struct vnode *vp,
2254 struct label *label, int attrnamespace, const char *name)
2256 struct mac_mls *subj, *obj;
2258 if (!mac_mls_enabled)
2261 subj = SLOT(cred->cr_label);
2264 if (!mac_mls_dominate_effective(obj, subj))
2271 mac_mls_check_vnode_exec(struct ucred *cred, struct vnode *vp,
2272 struct label *label, struct image_params *imgp,
2273 struct label *execlabel)
2275 struct mac_mls *subj, *obj, *exec;
2278 if (execlabel != NULL) {
2280 * We currently don't permit labels to be changed at
2281 * exec-time as part of MLS, so disallow non-NULL
2282 * MLS label elements in the execlabel.
2284 exec = SLOT(execlabel);
2285 error = mls_atmostflags(exec, 0);
2290 if (!mac_mls_enabled)
2293 subj = SLOT(cred->cr_label);
2296 if (!mac_mls_dominate_effective(subj, obj))
2303 mac_mls_check_vnode_getacl(struct ucred *cred, struct vnode *vp,
2304 struct label *label, acl_type_t type)
2306 struct mac_mls *subj, *obj;
2308 if (!mac_mls_enabled)
2311 subj = SLOT(cred->cr_label);
2314 if (!mac_mls_dominate_effective(subj, obj))
2321 mac_mls_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
2322 struct label *label, int attrnamespace, const char *name, struct uio *uio)
2324 struct mac_mls *subj, *obj;
2326 if (!mac_mls_enabled)
2329 subj = SLOT(cred->cr_label);
2332 if (!mac_mls_dominate_effective(subj, obj))
2339 mac_mls_check_vnode_link(struct ucred *cred, struct vnode *dvp,
2340 struct label *dlabel, struct vnode *vp, struct label *label,
2341 struct componentname *cnp)
2343 struct mac_mls *subj, *obj;
2345 if (!mac_mls_enabled)
2348 subj = SLOT(cred->cr_label);
2351 if (!mac_mls_dominate_effective(obj, subj))
2355 if (!mac_mls_dominate_effective(obj, subj))
2362 mac_mls_check_vnode_listextattr(struct ucred *cred, struct vnode *vp,
2363 struct label *label, int attrnamespace)
2366 struct mac_mls *subj, *obj;
2368 if (!mac_mls_enabled)
2371 subj = SLOT(cred->cr_label);
2374 if (!mac_mls_dominate_effective(subj, obj))
2381 mac_mls_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
2382 struct label *dlabel, struct componentname *cnp)
2384 struct mac_mls *subj, *obj;
2386 if (!mac_mls_enabled)
2389 subj = SLOT(cred->cr_label);
2392 if (!mac_mls_dominate_effective(subj, obj))
2399 mac_mls_check_vnode_mmap(struct ucred *cred, struct vnode *vp,
2400 struct label *label, int prot, int flags)
2402 struct mac_mls *subj, *obj;
2405 * Rely on the use of open()-time protections to handle
2406 * non-revocation cases.
2408 if (!mac_mls_enabled || !revocation_enabled)
2411 subj = SLOT(cred->cr_label);
2414 if (prot & (VM_PROT_READ | VM_PROT_EXECUTE)) {
2415 if (!mac_mls_dominate_effective(subj, obj))
2418 if (((prot & VM_PROT_WRITE) != 0) && ((flags & MAP_SHARED) != 0)) {
2419 if (!mac_mls_dominate_effective(obj, subj))
2427 mac_mls_check_vnode_open(struct ucred *cred, struct vnode *vp,
2428 struct label *vnodelabel, int acc_mode)
2430 struct mac_mls *subj, *obj;
2432 if (!mac_mls_enabled)
2435 subj = SLOT(cred->cr_label);
2436 obj = SLOT(vnodelabel);
2438 /* XXX privilege override for admin? */
2439 if (acc_mode & (VREAD | VEXEC | VSTAT)) {
2440 if (!mac_mls_dominate_effective(subj, obj))
2443 if (acc_mode & (VWRITE | VAPPEND | VADMIN)) {
2444 if (!mac_mls_dominate_effective(obj, subj))
2452 mac_mls_check_vnode_poll(struct ucred *active_cred, struct ucred *file_cred,
2453 struct vnode *vp, struct label *label)
2455 struct mac_mls *subj, *obj;
2457 if (!mac_mls_enabled || !revocation_enabled)
2460 subj = SLOT(active_cred->cr_label);
2463 if (!mac_mls_dominate_effective(subj, obj))
2470 mac_mls_check_vnode_read(struct ucred *active_cred, struct ucred *file_cred,
2471 struct vnode *vp, struct label *label)
2473 struct mac_mls *subj, *obj;
2475 if (!mac_mls_enabled || !revocation_enabled)
2478 subj = SLOT(active_cred->cr_label);
2481 if (!mac_mls_dominate_effective(subj, obj))
2488 mac_mls_check_vnode_readdir(struct ucred *cred, struct vnode *dvp,
2489 struct label *dlabel)
2491 struct mac_mls *subj, *obj;
2493 if (!mac_mls_enabled)
2496 subj = SLOT(cred->cr_label);
2499 if (!mac_mls_dominate_effective(subj, obj))
2506 mac_mls_check_vnode_readlink(struct ucred *cred, struct vnode *vp,
2507 struct label *vnodelabel)
2509 struct mac_mls *subj, *obj;
2511 if (!mac_mls_enabled)
2514 subj = SLOT(cred->cr_label);
2515 obj = SLOT(vnodelabel);
2517 if (!mac_mls_dominate_effective(subj, obj))
2524 mac_mls_check_vnode_relabel(struct ucred *cred, struct vnode *vp,
2525 struct label *vnodelabel, struct label *newlabel)
2527 struct mac_mls *old, *new, *subj;
2530 old = SLOT(vnodelabel);
2531 new = SLOT(newlabel);
2532 subj = SLOT(cred->cr_label);
2535 * If there is an MLS label update for the vnode, it must be a
2538 error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE);
2543 * To perform a relabel of the vnode (MLS label or not), MLS must
2544 * authorize the relabel.
2546 if (!mac_mls_effective_in_range(old, subj))
2550 * If the MLS label is to be changed, authorize as appropriate.
2552 if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
2554 * To change the MLS label on a vnode, the new vnode label
2555 * must be in the subject range.
2557 if (!mac_mls_effective_in_range(new, subj))
2561 * To change the MLS label on the vnode to be EQUAL,
2562 * the subject must have appropriate privilege.
2564 if (mac_mls_contains_equal(new)) {
2565 error = mac_mls_subject_privileged(subj);
2576 mac_mls_check_vnode_rename_from(struct ucred *cred, struct vnode *dvp,
2577 struct label *dlabel, struct vnode *vp, struct label *label,
2578 struct componentname *cnp)
2580 struct mac_mls *subj, *obj;
2582 if (!mac_mls_enabled)
2585 subj = SLOT(cred->cr_label);
2588 if (!mac_mls_dominate_effective(obj, subj))
2593 if (!mac_mls_dominate_effective(obj, subj))
2600 mac_mls_check_vnode_rename_to(struct ucred *cred, struct vnode *dvp,
2601 struct label *dlabel, struct vnode *vp, struct label *label, int samedir,
2602 struct componentname *cnp)
2604 struct mac_mls *subj, *obj;
2606 if (!mac_mls_enabled)
2609 subj = SLOT(cred->cr_label);
2612 if (!mac_mls_dominate_effective(obj, subj))
2618 if (!mac_mls_dominate_effective(obj, subj))
2626 mac_mls_check_vnode_revoke(struct ucred *cred, struct vnode *vp,
2627 struct label *label)
2629 struct mac_mls *subj, *obj;
2631 if (!mac_mls_enabled)
2634 subj = SLOT(cred->cr_label);
2637 if (!mac_mls_dominate_effective(obj, subj))
2644 mac_mls_check_vnode_setacl(struct ucred *cred, struct vnode *vp,
2645 struct label *label, acl_type_t type, struct acl *acl)
2647 struct mac_mls *subj, *obj;
2649 if (!mac_mls_enabled)
2652 subj = SLOT(cred->cr_label);
2655 if (!mac_mls_dominate_effective(obj, subj))
2662 mac_mls_check_vnode_setextattr(struct ucred *cred, struct vnode *vp,
2663 struct label *vnodelabel, int attrnamespace, const char *name,
2666 struct mac_mls *subj, *obj;
2668 if (!mac_mls_enabled)
2671 subj = SLOT(cred->cr_label);
2672 obj = SLOT(vnodelabel);
2674 if (!mac_mls_dominate_effective(obj, subj))
2677 /* XXX: protect the MAC EA in a special way? */
2683 mac_mls_check_vnode_setflags(struct ucred *cred, struct vnode *vp,
2684 struct label *vnodelabel, u_long flags)
2686 struct mac_mls *subj, *obj;
2688 if (!mac_mls_enabled)
2691 subj = SLOT(cred->cr_label);
2692 obj = SLOT(vnodelabel);
2694 if (!mac_mls_dominate_effective(obj, subj))
2701 mac_mls_check_vnode_setmode(struct ucred *cred, struct vnode *vp,
2702 struct label *vnodelabel, mode_t mode)
2704 struct mac_mls *subj, *obj;
2706 if (!mac_mls_enabled)
2709 subj = SLOT(cred->cr_label);
2710 obj = SLOT(vnodelabel);
2712 if (!mac_mls_dominate_effective(obj, subj))
2719 mac_mls_check_vnode_setowner(struct ucred *cred, struct vnode *vp,
2720 struct label *vnodelabel, uid_t uid, gid_t gid)
2722 struct mac_mls *subj, *obj;
2724 if (!mac_mls_enabled)
2727 subj = SLOT(cred->cr_label);
2728 obj = SLOT(vnodelabel);
2730 if (!mac_mls_dominate_effective(obj, subj))
2737 mac_mls_check_vnode_setutimes(struct ucred *cred, struct vnode *vp,
2738 struct label *vnodelabel, struct timespec atime, struct timespec mtime)
2740 struct mac_mls *subj, *obj;
2742 if (!mac_mls_enabled)
2745 subj = SLOT(cred->cr_label);
2746 obj = SLOT(vnodelabel);
2748 if (!mac_mls_dominate_effective(obj, subj))
2755 mac_mls_check_vnode_stat(struct ucred *active_cred, struct ucred *file_cred,
2756 struct vnode *vp, struct label *vnodelabel)
2758 struct mac_mls *subj, *obj;
2760 if (!mac_mls_enabled)
2763 subj = SLOT(active_cred->cr_label);
2764 obj = SLOT(vnodelabel);
2766 if (!mac_mls_dominate_effective(subj, obj))
2773 mac_mls_check_vnode_write(struct ucred *active_cred, struct ucred *file_cred,
2774 struct vnode *vp, struct label *label)
2776 struct mac_mls *subj, *obj;
2778 if (!mac_mls_enabled || !revocation_enabled)
2781 subj = SLOT(active_cred->cr_label);
2784 if (!mac_mls_dominate_effective(obj, subj))
2790 static struct mac_policy_ops mac_mls_ops =
2792 .mpo_init = mac_mls_init,
2793 .mpo_init_bpfdesc_label = mac_mls_init_label,
2794 .mpo_init_cred_label = mac_mls_init_label,
2795 .mpo_init_devfsdirent_label = mac_mls_init_label,
2796 .mpo_init_ifnet_label = mac_mls_init_label,
2797 .mpo_init_inpcb_label = mac_mls_init_label_waitcheck,
2798 .mpo_init_sysv_msgmsg_label = mac_mls_init_label,
2799 .mpo_init_sysv_msgqueue_label = mac_mls_init_label,
2800 .mpo_init_sysv_sem_label = mac_mls_init_label,
2801 .mpo_init_sysv_shm_label = mac_mls_init_label,
2802 .mpo_init_ipq_label = mac_mls_init_label_waitcheck,
2803 .mpo_init_mbuf_label = mac_mls_init_label_waitcheck,
2804 .mpo_init_mount_label = mac_mls_init_label,
2805 .mpo_init_mount_fs_label = mac_mls_init_label,
2806 .mpo_init_pipe_label = mac_mls_init_label,
2807 .mpo_init_posix_sem_label = mac_mls_init_label,
2808 .mpo_init_socket_label = mac_mls_init_label_waitcheck,
2809 .mpo_init_socket_peer_label = mac_mls_init_label_waitcheck,
2810 .mpo_init_vnode_label = mac_mls_init_label,
2811 .mpo_destroy_bpfdesc_label = mac_mls_destroy_label,
2812 .mpo_destroy_cred_label = mac_mls_destroy_label,
2813 .mpo_destroy_devfsdirent_label = mac_mls_destroy_label,
2814 .mpo_destroy_ifnet_label = mac_mls_destroy_label,
2815 .mpo_destroy_inpcb_label = mac_mls_destroy_label,
2816 .mpo_destroy_sysv_msgmsg_label = mac_mls_destroy_label,
2817 .mpo_destroy_sysv_msgqueue_label = mac_mls_destroy_label,
2818 .mpo_destroy_sysv_sem_label = mac_mls_destroy_label,
2819 .mpo_destroy_sysv_shm_label = mac_mls_destroy_label,
2820 .mpo_destroy_ipq_label = mac_mls_destroy_label,
2821 .mpo_destroy_mbuf_label = mac_mls_destroy_label,
2822 .mpo_destroy_mount_label = mac_mls_destroy_label,
2823 .mpo_destroy_mount_fs_label = mac_mls_destroy_label,
2824 .mpo_destroy_pipe_label = mac_mls_destroy_label,
2825 .mpo_destroy_posix_sem_label = mac_mls_destroy_label,
2826 .mpo_destroy_socket_label = mac_mls_destroy_label,
2827 .mpo_destroy_socket_peer_label = mac_mls_destroy_label,
2828 .mpo_destroy_vnode_label = mac_mls_destroy_label,
2829 .mpo_copy_cred_label = mac_mls_copy_label,
2830 .mpo_copy_ifnet_label = mac_mls_copy_label,
2831 .mpo_copy_mbuf_label = mac_mls_copy_label,
2832 .mpo_copy_pipe_label = mac_mls_copy_label,
2833 .mpo_copy_socket_label = mac_mls_copy_label,
2834 .mpo_copy_vnode_label = mac_mls_copy_label,
2835 .mpo_externalize_cred_label = mac_mls_externalize_label,
2836 .mpo_externalize_ifnet_label = mac_mls_externalize_label,
2837 .mpo_externalize_pipe_label = mac_mls_externalize_label,
2838 .mpo_externalize_socket_label = mac_mls_externalize_label,
2839 .mpo_externalize_socket_peer_label = mac_mls_externalize_label,
2840 .mpo_externalize_vnode_label = mac_mls_externalize_label,
2841 .mpo_internalize_cred_label = mac_mls_internalize_label,
2842 .mpo_internalize_ifnet_label = mac_mls_internalize_label,
2843 .mpo_internalize_pipe_label = mac_mls_internalize_label,
2844 .mpo_internalize_socket_label = mac_mls_internalize_label,
2845 .mpo_internalize_vnode_label = mac_mls_internalize_label,
2846 .mpo_create_devfs_device = mac_mls_create_devfs_device,
2847 .mpo_create_devfs_directory = mac_mls_create_devfs_directory,
2848 .mpo_create_devfs_symlink = mac_mls_create_devfs_symlink,
2849 .mpo_create_mount = mac_mls_create_mount,
2850 .mpo_relabel_vnode = mac_mls_relabel_vnode,
2851 .mpo_update_devfsdirent = mac_mls_update_devfsdirent,
2852 .mpo_associate_vnode_devfs = mac_mls_associate_vnode_devfs,
2853 .mpo_associate_vnode_extattr = mac_mls_associate_vnode_extattr,
2854 .mpo_associate_vnode_singlelabel = mac_mls_associate_vnode_singlelabel,
2855 .mpo_create_vnode_extattr = mac_mls_create_vnode_extattr,
2856 .mpo_setlabel_vnode_extattr = mac_mls_setlabel_vnode_extattr,
2857 .mpo_create_mbuf_from_socket = mac_mls_create_mbuf_from_socket,
2858 .mpo_create_pipe = mac_mls_create_pipe,
2859 .mpo_create_posix_sem = mac_mls_create_posix_sem,
2860 .mpo_create_socket = mac_mls_create_socket,
2861 .mpo_create_socket_from_socket = mac_mls_create_socket_from_socket,
2862 .mpo_relabel_pipe = mac_mls_relabel_pipe,
2863 .mpo_relabel_socket = mac_mls_relabel_socket,
2864 .mpo_set_socket_peer_from_mbuf = mac_mls_set_socket_peer_from_mbuf,
2865 .mpo_set_socket_peer_from_socket = mac_mls_set_socket_peer_from_socket,
2866 .mpo_create_bpfdesc = mac_mls_create_bpfdesc,
2867 .mpo_create_datagram_from_ipq = mac_mls_create_datagram_from_ipq,
2868 .mpo_create_fragment = mac_mls_create_fragment,
2869 .mpo_create_ifnet = mac_mls_create_ifnet,
2870 .mpo_create_inpcb_from_socket = mac_mls_create_inpcb_from_socket,
2871 .mpo_create_ipq = mac_mls_create_ipq,
2872 .mpo_create_sysv_msgmsg = mac_mls_create_sysv_msgmsg,
2873 .mpo_create_sysv_msgqueue = mac_mls_create_sysv_msgqueue,
2874 .mpo_create_sysv_sem = mac_mls_create_sysv_sem,
2875 .mpo_create_sysv_shm = mac_mls_create_sysv_shm,
2876 .mpo_create_mbuf_from_inpcb = mac_mls_create_mbuf_from_inpcb,
2877 .mpo_create_mbuf_linklayer = mac_mls_create_mbuf_linklayer,
2878 .mpo_create_mbuf_from_bpfdesc = mac_mls_create_mbuf_from_bpfdesc,
2879 .mpo_create_mbuf_from_ifnet = mac_mls_create_mbuf_from_ifnet,
2880 .mpo_create_mbuf_multicast_encap = mac_mls_create_mbuf_multicast_encap,
2881 .mpo_create_mbuf_netlayer = mac_mls_create_mbuf_netlayer,
2882 .mpo_fragment_match = mac_mls_fragment_match,
2883 .mpo_relabel_ifnet = mac_mls_relabel_ifnet,
2884 .mpo_update_ipq = mac_mls_update_ipq,
2885 .mpo_inpcb_sosetlabel = mac_mls_inpcb_sosetlabel,
2886 .mpo_create_proc0 = mac_mls_create_proc0,
2887 .mpo_create_proc1 = mac_mls_create_proc1,
2888 .mpo_relabel_cred = mac_mls_relabel_cred,
2889 .mpo_cleanup_sysv_msgmsg = mac_mls_cleanup_sysv_msgmsg,
2890 .mpo_cleanup_sysv_msgqueue = mac_mls_cleanup_sysv_msgqueue,
2891 .mpo_cleanup_sysv_sem = mac_mls_cleanup_sysv_sem,
2892 .mpo_cleanup_sysv_shm = mac_mls_cleanup_sysv_shm,
2893 .mpo_check_bpfdesc_receive = mac_mls_check_bpfdesc_receive,
2894 .mpo_check_cred_relabel = mac_mls_check_cred_relabel,
2895 .mpo_check_cred_visible = mac_mls_check_cred_visible,
2896 .mpo_check_ifnet_relabel = mac_mls_check_ifnet_relabel,
2897 .mpo_check_ifnet_transmit = mac_mls_check_ifnet_transmit,
2898 .mpo_check_inpcb_deliver = mac_mls_check_inpcb_deliver,
2899 .mpo_check_sysv_msgrcv = mac_mls_check_sysv_msgrcv,
2900 .mpo_check_sysv_msgrmid = mac_mls_check_sysv_msgrmid,
2901 .mpo_check_sysv_msqget = mac_mls_check_sysv_msqget,
2902 .mpo_check_sysv_msqsnd = mac_mls_check_sysv_msqsnd,
2903 .mpo_check_sysv_msqrcv = mac_mls_check_sysv_msqrcv,
2904 .mpo_check_sysv_msqctl = mac_mls_check_sysv_msqctl,
2905 .mpo_check_sysv_semctl = mac_mls_check_sysv_semctl,
2906 .mpo_check_sysv_semget = mac_mls_check_sysv_semget,
2907 .mpo_check_sysv_semop = mac_mls_check_sysv_semop,
2908 .mpo_check_sysv_shmat = mac_mls_check_sysv_shmat,
2909 .mpo_check_sysv_shmctl = mac_mls_check_sysv_shmctl,
2910 .mpo_check_sysv_shmget = mac_mls_check_sysv_shmget,
2911 .mpo_check_mount_stat = mac_mls_check_mount_stat,
2912 .mpo_check_pipe_ioctl = mac_mls_check_pipe_ioctl,
2913 .mpo_check_pipe_poll = mac_mls_check_pipe_poll,
2914 .mpo_check_pipe_read = mac_mls_check_pipe_read,
2915 .mpo_check_pipe_relabel = mac_mls_check_pipe_relabel,
2916 .mpo_check_pipe_stat = mac_mls_check_pipe_stat,
2917 .mpo_check_pipe_write = mac_mls_check_pipe_write,
2918 .mpo_check_posix_sem_destroy = mac_mls_check_posix_sem_write,
2919 .mpo_check_posix_sem_getvalue = mac_mls_check_posix_sem_rdonly,
2920 .mpo_check_posix_sem_open = mac_mls_check_posix_sem_write,
2921 .mpo_check_posix_sem_post = mac_mls_check_posix_sem_write,
2922 .mpo_check_posix_sem_unlink = mac_mls_check_posix_sem_write,
2923 .mpo_check_posix_sem_wait = mac_mls_check_posix_sem_write,
2924 .mpo_check_proc_debug = mac_mls_check_proc_debug,
2925 .mpo_check_proc_sched = mac_mls_check_proc_sched,
2926 .mpo_check_proc_signal = mac_mls_check_proc_signal,
2927 .mpo_check_socket_deliver = mac_mls_check_socket_deliver,
2928 .mpo_check_socket_relabel = mac_mls_check_socket_relabel,
2929 .mpo_check_socket_visible = mac_mls_check_socket_visible,
2930 .mpo_check_system_swapon = mac_mls_check_system_swapon,
2931 .mpo_check_vnode_access = mac_mls_check_vnode_open,
2932 .mpo_check_vnode_chdir = mac_mls_check_vnode_chdir,
2933 .mpo_check_vnode_chroot = mac_mls_check_vnode_chroot,
2934 .mpo_check_vnode_create = mac_mls_check_vnode_create,
2935 .mpo_check_vnode_delete = mac_mls_check_vnode_delete,
2936 .mpo_check_vnode_deleteacl = mac_mls_check_vnode_deleteacl,
2937 .mpo_check_vnode_deleteextattr = mac_mls_check_vnode_deleteextattr,
2938 .mpo_check_vnode_exec = mac_mls_check_vnode_exec,
2939 .mpo_check_vnode_getacl = mac_mls_check_vnode_getacl,
2940 .mpo_check_vnode_getextattr = mac_mls_check_vnode_getextattr,
2941 .mpo_check_vnode_link = mac_mls_check_vnode_link,
2942 .mpo_check_vnode_listextattr = mac_mls_check_vnode_listextattr,
2943 .mpo_check_vnode_lookup = mac_mls_check_vnode_lookup,
2944 .mpo_check_vnode_mmap = mac_mls_check_vnode_mmap,
2945 .mpo_check_vnode_open = mac_mls_check_vnode_open,
2946 .mpo_check_vnode_poll = mac_mls_check_vnode_poll,
2947 .mpo_check_vnode_read = mac_mls_check_vnode_read,
2948 .mpo_check_vnode_readdir = mac_mls_check_vnode_readdir,
2949 .mpo_check_vnode_readlink = mac_mls_check_vnode_readlink,
2950 .mpo_check_vnode_relabel = mac_mls_check_vnode_relabel,
2951 .mpo_check_vnode_rename_from = mac_mls_check_vnode_rename_from,
2952 .mpo_check_vnode_rename_to = mac_mls_check_vnode_rename_to,
2953 .mpo_check_vnode_revoke = mac_mls_check_vnode_revoke,
2954 .mpo_check_vnode_setacl = mac_mls_check_vnode_setacl,
2955 .mpo_check_vnode_setextattr = mac_mls_check_vnode_setextattr,
2956 .mpo_check_vnode_setflags = mac_mls_check_vnode_setflags,
2957 .mpo_check_vnode_setmode = mac_mls_check_vnode_setmode,
2958 .mpo_check_vnode_setowner = mac_mls_check_vnode_setowner,
2959 .mpo_check_vnode_setutimes = mac_mls_check_vnode_setutimes,
2960 .mpo_check_vnode_stat = mac_mls_check_vnode_stat,
2961 .mpo_check_vnode_write = mac_mls_check_vnode_write,
2964 MAC_POLICY_SET(&mac_mls_ops, mac_mls, "TrustedBSD MAC/MLS",
2965 MPC_LOADTIME_FLAG_NOTLATE | MPC_LOADTIME_FLAG_LABELMBUFS, &mac_mls_slot);