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>
64 #include <sys/sysctl.h>
69 #include <posix4/ksem.h>
71 #include <fs/devfs/devfs.h>
73 #include <net/bpfdesc.h>
75 #include <net/if_types.h>
76 #include <net/if_var.h>
78 #include <netinet/in.h>
79 #include <netinet/in_pcb.h>
80 #include <netinet/ip_var.h>
85 #include <sys/mac_policy.h>
87 #include <security/mac_mls/mac_mls.h>
89 SYSCTL_DECL(_security_mac);
91 SYSCTL_NODE(_security_mac, OID_AUTO, mls, CTLFLAG_RW, 0,
92 "TrustedBSD mac_mls policy controls");
94 static int mac_mls_label_size = sizeof(struct mac_mls);
95 SYSCTL_INT(_security_mac_mls, OID_AUTO, label_size, CTLFLAG_RD,
96 &mac_mls_label_size, 0, "Size of struct mac_mls");
98 static int mac_mls_enabled = 1;
99 SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RW,
100 &mac_mls_enabled, 0, "Enforce MAC/MLS policy");
101 TUNABLE_INT("security.mac.mls.enabled", &mac_mls_enabled);
103 static int destroyed_not_inited;
104 SYSCTL_INT(_security_mac_mls, OID_AUTO, destroyed_not_inited, CTLFLAG_RD,
105 &destroyed_not_inited, 0, "Count of labels destroyed but not inited");
107 static int ptys_equal = 0;
108 SYSCTL_INT(_security_mac_mls, OID_AUTO, ptys_equal, CTLFLAG_RW,
109 &ptys_equal, 0, "Label pty devices as mls/equal on create");
110 TUNABLE_INT("security.mac.mls.ptys_equal", &ptys_equal);
112 static int revocation_enabled = 0;
113 SYSCTL_INT(_security_mac_mls, OID_AUTO, revocation_enabled, CTLFLAG_RW,
114 &revocation_enabled, 0, "Revoke access to objects on relabel");
115 TUNABLE_INT("security.mac.mls.revocation_enabled", &revocation_enabled);
117 static int max_compartments = MAC_MLS_MAX_COMPARTMENTS;
118 SYSCTL_INT(_security_mac_mls, OID_AUTO, max_compartments, CTLFLAG_RD,
119 &max_compartments, 0, "Maximum compartments the policy supports");
121 static int mac_mls_slot;
122 #define SLOT(l) ((struct mac_mls *)LABEL_TO_SLOT((l), mac_mls_slot).l_ptr)
123 #define SLOT_SET(l, val) (LABEL_TO_SLOT((l), mac_mls_slot).l_ptr = (val))
125 static uma_zone_t zone_mls;
128 mls_bit_set_empty(u_char *set) {
131 for (i = 0; i < MAC_MLS_MAX_COMPARTMENTS >> 3; i++)
137 static struct mac_mls *
141 return (uma_zalloc(zone_mls, flag | M_ZERO));
145 mls_free(struct mac_mls *mac_mls)
149 uma_zfree(zone_mls, mac_mls);
151 atomic_add_int(&destroyed_not_inited, 1);
155 mls_atmostflags(struct mac_mls *mac_mls, int flags)
158 if ((mac_mls->mm_flags & flags) != mac_mls->mm_flags)
164 mac_mls_dominate_element(struct mac_mls_element *a,
165 struct mac_mls_element *b)
169 switch (a->mme_type) {
170 case MAC_MLS_TYPE_EQUAL:
171 case MAC_MLS_TYPE_HIGH:
174 case MAC_MLS_TYPE_LOW:
175 switch (b->mme_type) {
176 case MAC_MLS_TYPE_LEVEL:
177 case MAC_MLS_TYPE_HIGH:
180 case MAC_MLS_TYPE_EQUAL:
181 case MAC_MLS_TYPE_LOW:
185 panic("mac_mls_dominate_element: b->mme_type invalid");
188 case MAC_MLS_TYPE_LEVEL:
189 switch (b->mme_type) {
190 case MAC_MLS_TYPE_EQUAL:
191 case MAC_MLS_TYPE_LOW:
194 case MAC_MLS_TYPE_HIGH:
197 case MAC_MLS_TYPE_LEVEL:
198 for (bit = 1; bit <= MAC_MLS_MAX_COMPARTMENTS; bit++)
199 if (!MAC_MLS_BIT_TEST(bit,
200 a->mme_compartments) &&
201 MAC_MLS_BIT_TEST(bit, b->mme_compartments))
203 return (a->mme_level >= b->mme_level);
206 panic("mac_mls_dominate_element: b->mme_type invalid");
210 panic("mac_mls_dominate_element: a->mme_type invalid");
217 mac_mls_range_in_range(struct mac_mls *rangea, struct mac_mls *rangeb)
220 return (mac_mls_dominate_element(&rangeb->mm_rangehigh,
221 &rangea->mm_rangehigh) &&
222 mac_mls_dominate_element(&rangea->mm_rangelow,
223 &rangeb->mm_rangelow));
227 mac_mls_effective_in_range(struct mac_mls *effective, struct mac_mls *range)
230 KASSERT((effective->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
231 ("mac_mls_effective_in_range: a not effective"));
232 KASSERT((range->mm_flags & MAC_MLS_FLAG_RANGE) != 0,
233 ("mac_mls_effective_in_range: b not range"));
235 return (mac_mls_dominate_element(&range->mm_rangehigh,
236 &effective->mm_effective) &&
237 mac_mls_dominate_element(&effective->mm_effective,
238 &range->mm_rangelow));
244 mac_mls_dominate_effective(struct mac_mls *a, struct mac_mls *b)
246 KASSERT((a->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
247 ("mac_mls_dominate_effective: a not effective"));
248 KASSERT((b->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
249 ("mac_mls_dominate_effective: b not effective"));
251 return (mac_mls_dominate_element(&a->mm_effective, &b->mm_effective));
255 mac_mls_equal_element(struct mac_mls_element *a, struct mac_mls_element *b)
258 if (a->mme_type == MAC_MLS_TYPE_EQUAL ||
259 b->mme_type == MAC_MLS_TYPE_EQUAL)
262 return (a->mme_type == b->mme_type && a->mme_level == b->mme_level);
266 mac_mls_equal_effective(struct mac_mls *a, struct mac_mls *b)
269 KASSERT((a->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
270 ("mac_mls_equal_effective: a not effective"));
271 KASSERT((b->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
272 ("mac_mls_equal_effective: b not effective"));
274 return (mac_mls_equal_element(&a->mm_effective, &b->mm_effective));
278 mac_mls_contains_equal(struct mac_mls *mac_mls)
281 if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE)
282 if (mac_mls->mm_effective.mme_type == MAC_MLS_TYPE_EQUAL)
285 if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) {
286 if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_EQUAL)
288 if (mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_EQUAL)
296 mac_mls_subject_privileged(struct mac_mls *mac_mls)
299 KASSERT((mac_mls->mm_flags & MAC_MLS_FLAGS_BOTH) ==
301 ("mac_mls_subject_privileged: subject doesn't have both labels"));
303 /* If the effective is EQUAL, it's ok. */
304 if (mac_mls->mm_effective.mme_type == MAC_MLS_TYPE_EQUAL)
307 /* If either range endpoint is EQUAL, it's ok. */
308 if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_EQUAL ||
309 mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_EQUAL)
312 /* If the range is low-high, it's ok. */
313 if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_LOW &&
314 mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_HIGH)
322 mac_mls_valid(struct mac_mls *mac_mls)
325 if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
326 switch (mac_mls->mm_effective.mme_type) {
327 case MAC_MLS_TYPE_LEVEL:
330 case MAC_MLS_TYPE_EQUAL:
331 case MAC_MLS_TYPE_HIGH:
332 case MAC_MLS_TYPE_LOW:
333 if (mac_mls->mm_effective.mme_level != 0 ||
334 !MAC_MLS_BIT_SET_EMPTY(
335 mac_mls->mm_effective.mme_compartments))
343 if (mac_mls->mm_effective.mme_type != MAC_MLS_TYPE_UNDEF)
347 if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) {
348 switch (mac_mls->mm_rangelow.mme_type) {
349 case MAC_MLS_TYPE_LEVEL:
352 case MAC_MLS_TYPE_EQUAL:
353 case MAC_MLS_TYPE_HIGH:
354 case MAC_MLS_TYPE_LOW:
355 if (mac_mls->mm_rangelow.mme_level != 0 ||
356 !MAC_MLS_BIT_SET_EMPTY(
357 mac_mls->mm_rangelow.mme_compartments))
365 switch (mac_mls->mm_rangehigh.mme_type) {
366 case MAC_MLS_TYPE_LEVEL:
369 case MAC_MLS_TYPE_EQUAL:
370 case MAC_MLS_TYPE_HIGH:
371 case MAC_MLS_TYPE_LOW:
372 if (mac_mls->mm_rangehigh.mme_level != 0 ||
373 !MAC_MLS_BIT_SET_EMPTY(
374 mac_mls->mm_rangehigh.mme_compartments))
381 if (!mac_mls_dominate_element(&mac_mls->mm_rangehigh,
382 &mac_mls->mm_rangelow))
385 if (mac_mls->mm_rangelow.mme_type != MAC_MLS_TYPE_UNDEF ||
386 mac_mls->mm_rangehigh.mme_type != MAC_MLS_TYPE_UNDEF)
394 mac_mls_set_range(struct mac_mls *mac_mls, u_short typelow,
395 u_short levellow, u_char *compartmentslow, u_short typehigh,
396 u_short levelhigh, u_char *compartmentshigh)
399 mac_mls->mm_rangelow.mme_type = typelow;
400 mac_mls->mm_rangelow.mme_level = levellow;
401 if (compartmentslow != NULL)
402 memcpy(mac_mls->mm_rangelow.mme_compartments,
404 sizeof(mac_mls->mm_rangelow.mme_compartments));
405 mac_mls->mm_rangehigh.mme_type = typehigh;
406 mac_mls->mm_rangehigh.mme_level = levelhigh;
407 if (compartmentshigh != NULL)
408 memcpy(mac_mls->mm_rangehigh.mme_compartments,
410 sizeof(mac_mls->mm_rangehigh.mme_compartments));
411 mac_mls->mm_flags |= MAC_MLS_FLAG_RANGE;
415 mac_mls_set_effective(struct mac_mls *mac_mls, u_short type, u_short level,
416 u_char *compartments)
419 mac_mls->mm_effective.mme_type = type;
420 mac_mls->mm_effective.mme_level = level;
421 if (compartments != NULL)
422 memcpy(mac_mls->mm_effective.mme_compartments, compartments,
423 sizeof(mac_mls->mm_effective.mme_compartments));
424 mac_mls->mm_flags |= MAC_MLS_FLAG_EFFECTIVE;
428 mac_mls_copy_range(struct mac_mls *labelfrom, struct mac_mls *labelto)
431 KASSERT((labelfrom->mm_flags & MAC_MLS_FLAG_RANGE) != 0,
432 ("mac_mls_copy_range: labelfrom not range"));
434 labelto->mm_rangelow = labelfrom->mm_rangelow;
435 labelto->mm_rangehigh = labelfrom->mm_rangehigh;
436 labelto->mm_flags |= MAC_MLS_FLAG_RANGE;
440 mac_mls_copy_effective(struct mac_mls *labelfrom, struct mac_mls *labelto)
443 KASSERT((labelfrom->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0,
444 ("mac_mls_copy_effective: labelfrom not effective"));
446 labelto->mm_effective = labelfrom->mm_effective;
447 labelto->mm_flags |= MAC_MLS_FLAG_EFFECTIVE;
451 mac_mls_copy(struct mac_mls *source, struct mac_mls *dest)
454 if (source->mm_flags & MAC_MLS_FLAG_EFFECTIVE)
455 mac_mls_copy_effective(source, dest);
456 if (source->mm_flags & MAC_MLS_FLAG_RANGE)
457 mac_mls_copy_range(source, dest);
461 * Policy module operations.
464 mac_mls_init(struct mac_policy_conf *conf)
467 zone_mls = uma_zcreate("mac_mls", sizeof(struct mac_mls), NULL,
468 NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
475 mac_mls_init_label(struct label *label)
478 SLOT_SET(label, mls_alloc(M_WAITOK));
482 mac_mls_init_label_waitcheck(struct label *label, int flag)
485 SLOT_SET(label, mls_alloc(flag));
486 if (SLOT(label) == NULL)
493 mac_mls_destroy_label(struct label *label)
496 mls_free(SLOT(label));
497 SLOT_SET(label, NULL);
501 * mac_mls_element_to_string() accepts an sbuf and MLS element. It
502 * converts the MLS element to a string and stores the result in the
503 * sbuf; if there isn't space in the sbuf, -1 is returned.
506 mac_mls_element_to_string(struct sbuf *sb, struct mac_mls_element *element)
510 switch (element->mme_type) {
511 case MAC_MLS_TYPE_HIGH:
512 return (sbuf_printf(sb, "high"));
514 case MAC_MLS_TYPE_LOW:
515 return (sbuf_printf(sb, "low"));
517 case MAC_MLS_TYPE_EQUAL:
518 return (sbuf_printf(sb, "equal"));
520 case MAC_MLS_TYPE_LEVEL:
521 if (sbuf_printf(sb, "%d", element->mme_level) == -1)
525 for (i = 1; i <= MAC_MLS_MAX_COMPARTMENTS; i++) {
526 if (MAC_MLS_BIT_TEST(i, element->mme_compartments)) {
528 if (sbuf_putc(sb, ':') == -1)
530 if (sbuf_printf(sb, "%d", i) == -1)
534 if (sbuf_printf(sb, "+%d", i) == -1)
542 panic("mac_mls_element_to_string: invalid type (%d)",
548 * mac_mls_to_string() converts an MLS label to a string, and places
549 * the results in the passed sbuf. It returns 0 on success, or EINVAL
550 * if there isn't room in the sbuf. Note: the sbuf will be modified
551 * even in a failure case, so the caller may need to revert the sbuf
552 * by restoring the offset if that's undesired.
555 mac_mls_to_string(struct sbuf *sb, struct mac_mls *mac_mls)
558 if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
559 if (mac_mls_element_to_string(sb, &mac_mls->mm_effective)
564 if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) {
565 if (sbuf_putc(sb, '(') == -1)
568 if (mac_mls_element_to_string(sb, &mac_mls->mm_rangelow)
572 if (sbuf_putc(sb, '-') == -1)
575 if (mac_mls_element_to_string(sb, &mac_mls->mm_rangehigh)
579 if (sbuf_putc(sb, ')') == -1)
587 mac_mls_externalize_label(struct label *label, char *element_name,
588 struct sbuf *sb, int *claimed)
590 struct mac_mls *mac_mls;
592 if (strcmp(MAC_MLS_LABEL_NAME, element_name) != 0)
597 mac_mls = SLOT(label);
599 return (mac_mls_to_string(sb, mac_mls));
603 mac_mls_parse_element(struct mac_mls_element *element, char *string)
605 char *compartment, *end, *level;
608 if (strcmp(string, "high") == 0 ||
609 strcmp(string, "hi") == 0) {
610 element->mme_type = MAC_MLS_TYPE_HIGH;
611 element->mme_level = MAC_MLS_TYPE_UNDEF;
612 } else if (strcmp(string, "low") == 0 ||
613 strcmp(string, "lo") == 0) {
614 element->mme_type = MAC_MLS_TYPE_LOW;
615 element->mme_level = MAC_MLS_TYPE_UNDEF;
616 } else if (strcmp(string, "equal") == 0 ||
617 strcmp(string, "eq") == 0) {
618 element->mme_type = MAC_MLS_TYPE_EQUAL;
619 element->mme_level = MAC_MLS_TYPE_UNDEF;
621 element->mme_type = MAC_MLS_TYPE_LEVEL;
624 * Numeric level piece of the element.
626 level = strsep(&string, ":");
627 value = strtol(level, &end, 10);
628 if (end == level || *end != '\0')
630 if (value < 0 || value > 65535)
632 element->mme_level = value;
635 * Optional compartment piece of the element. If none
636 * are included, we assume that the label has no
644 while ((compartment = strsep(&string, "+")) != NULL) {
645 value = strtol(compartment, &end, 10);
646 if (compartment == end || *end != '\0')
648 if (value < 1 || value > MAC_MLS_MAX_COMPARTMENTS)
650 MAC_MLS_BIT_SET(value, element->mme_compartments);
658 * Note: destructively consumes the string, make a local copy before
659 * calling if that's a problem.
662 mac_mls_parse(struct mac_mls *mac_mls, char *string)
664 char *rangehigh, *rangelow, *effective;
667 effective = strsep(&string, "(");
668 if (*effective == '\0')
671 if (string != NULL) {
672 rangelow = strsep(&string, "-");
675 rangehigh = strsep(&string, ")");
685 KASSERT((rangelow != NULL && rangehigh != NULL) ||
686 (rangelow == NULL && rangehigh == NULL),
687 ("mac_mls_parse: range mismatch"));
689 bzero(mac_mls, sizeof(*mac_mls));
690 if (effective != NULL) {
691 error = mac_mls_parse_element(&mac_mls->mm_effective, effective);
694 mac_mls->mm_flags |= MAC_MLS_FLAG_EFFECTIVE;
697 if (rangelow != NULL) {
698 error = mac_mls_parse_element(&mac_mls->mm_rangelow,
702 error = mac_mls_parse_element(&mac_mls->mm_rangehigh,
706 mac_mls->mm_flags |= MAC_MLS_FLAG_RANGE;
709 error = mac_mls_valid(mac_mls);
717 mac_mls_internalize_label(struct label *label, char *element_name,
718 char *element_data, int *claimed)
720 struct mac_mls *mac_mls, mac_mls_temp;
723 if (strcmp(MAC_MLS_LABEL_NAME, element_name) != 0)
728 error = mac_mls_parse(&mac_mls_temp, element_data);
732 mac_mls = SLOT(label);
733 *mac_mls = mac_mls_temp;
739 mac_mls_copy_label(struct label *src, struct label *dest)
742 *SLOT(dest) = *SLOT(src);
746 * Labeling event operations: file system objects, and things that look
747 * a lot like file system objects.
750 mac_mls_create_devfs_device(struct ucred *cred, struct mount *mp,
751 struct cdev *dev, struct devfs_dirent *devfs_dirent, struct label *label)
753 struct mac_mls *mac_mls;
756 mac_mls = SLOT(label);
757 if (strcmp(dev->si_name, "null") == 0 ||
758 strcmp(dev->si_name, "zero") == 0 ||
759 strcmp(dev->si_name, "random") == 0 ||
760 strncmp(dev->si_name, "fd/", strlen("fd/")) == 0)
761 mls_type = MAC_MLS_TYPE_EQUAL;
762 else if (strcmp(dev->si_name, "kmem") == 0 ||
763 strcmp(dev->si_name, "mem") == 0)
764 mls_type = MAC_MLS_TYPE_HIGH;
765 else if (ptys_equal &&
766 (strncmp(dev->si_name, "ttyp", strlen("ttyp")) == 0 ||
767 strncmp(dev->si_name, "ptyp", strlen("ptyp")) == 0))
768 mls_type = MAC_MLS_TYPE_EQUAL;
770 mls_type = MAC_MLS_TYPE_LOW;
771 mac_mls_set_effective(mac_mls, mls_type, 0, NULL);
775 mac_mls_create_devfs_directory(struct mount *mp, char *dirname,
776 int dirnamelen, struct devfs_dirent *devfs_dirent, struct label *label)
778 struct mac_mls *mac_mls;
780 mac_mls = SLOT(label);
781 mac_mls_set_effective(mac_mls, MAC_MLS_TYPE_LOW, 0, NULL);
785 mac_mls_create_devfs_symlink(struct ucred *cred, struct mount *mp,
786 struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de,
787 struct label *delabel)
789 struct mac_mls *source, *dest;
791 source = SLOT(cred->cr_label);
792 dest = SLOT(delabel);
794 mac_mls_copy_effective(source, dest);
798 mac_mls_create_mount(struct ucred *cred, struct mount *mp,
799 struct label *mntlabel, struct label *fslabel)
801 struct mac_mls *source, *dest;
803 source = SLOT(cred->cr_label);
804 dest = SLOT(mntlabel);
805 mac_mls_copy_effective(source, dest);
806 dest = SLOT(fslabel);
807 mac_mls_copy_effective(source, dest);
811 mac_mls_relabel_vnode(struct ucred *cred, struct vnode *vp,
812 struct label *vnodelabel, struct label *label)
814 struct mac_mls *source, *dest;
816 source = SLOT(label);
817 dest = SLOT(vnodelabel);
819 mac_mls_copy(source, dest);
823 mac_mls_update_devfsdirent(struct mount *mp,
824 struct devfs_dirent *devfs_dirent, struct label *direntlabel,
825 struct vnode *vp, struct label *vnodelabel)
827 struct mac_mls *source, *dest;
829 source = SLOT(vnodelabel);
830 dest = SLOT(direntlabel);
832 mac_mls_copy_effective(source, dest);
836 mac_mls_associate_vnode_devfs(struct mount *mp, struct label *fslabel,
837 struct devfs_dirent *de, struct label *delabel, struct vnode *vp,
838 struct label *vlabel)
840 struct mac_mls *source, *dest;
842 source = SLOT(delabel);
845 mac_mls_copy_effective(source, dest);
849 mac_mls_associate_vnode_extattr(struct mount *mp, struct label *fslabel,
850 struct vnode *vp, struct label *vlabel)
852 struct mac_mls temp, *source, *dest;
855 source = SLOT(fslabel);
858 buflen = sizeof(temp);
859 bzero(&temp, buflen);
861 error = vn_extattr_get(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE,
862 MAC_MLS_EXTATTR_NAME, &buflen, (char *) &temp, curthread);
863 if (error == ENOATTR || error == EOPNOTSUPP) {
864 /* Fall back to the fslabel. */
865 mac_mls_copy_effective(source, dest);
870 if (buflen != sizeof(temp)) {
871 printf("mac_mls_associate_vnode_extattr: bad size %d\n",
875 if (mac_mls_valid(&temp) != 0) {
876 printf("mac_mls_associate_vnode_extattr: invalid\n");
879 if ((temp.mm_flags & MAC_MLS_FLAGS_BOTH) != MAC_MLS_FLAG_EFFECTIVE) {
880 printf("mac_mls_associated_vnode_extattr: not effective\n");
884 mac_mls_copy_effective(&temp, dest);
889 mac_mls_associate_vnode_singlelabel(struct mount *mp,
890 struct label *fslabel, struct vnode *vp, struct label *vlabel)
892 struct mac_mls *source, *dest;
894 source = SLOT(fslabel);
897 mac_mls_copy_effective(source, dest);
901 mac_mls_create_vnode_extattr(struct ucred *cred, struct mount *mp,
902 struct label *fslabel, struct vnode *dvp, struct label *dlabel,
903 struct vnode *vp, struct label *vlabel, struct componentname *cnp)
905 struct mac_mls *source, *dest, temp;
909 buflen = sizeof(temp);
910 bzero(&temp, buflen);
912 source = SLOT(cred->cr_label);
914 mac_mls_copy_effective(source, &temp);
916 error = vn_extattr_set(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE,
917 MAC_MLS_EXTATTR_NAME, buflen, (char *) &temp, curthread);
919 mac_mls_copy_effective(source, dest);
924 mac_mls_setlabel_vnode_extattr(struct ucred *cred, struct vnode *vp,
925 struct label *vlabel, struct label *intlabel)
927 struct mac_mls *source, temp;
931 buflen = sizeof(temp);
932 bzero(&temp, buflen);
934 source = SLOT(intlabel);
935 if ((source->mm_flags & MAC_MLS_FLAG_EFFECTIVE) == 0)
938 mac_mls_copy_effective(source, &temp);
940 error = vn_extattr_set(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE,
941 MAC_MLS_EXTATTR_NAME, buflen, (char *) &temp, curthread);
946 * Labeling event operations: IPC object.
949 mac_mls_create_inpcb_from_socket(struct socket *so, struct label *solabel,
950 struct inpcb *inp, struct label *inplabel)
952 struct mac_mls *source, *dest;
954 source = SLOT(solabel);
955 dest = SLOT(inplabel);
957 mac_mls_copy_effective(source, dest);
961 mac_mls_create_mbuf_from_socket(struct socket *so, struct label *socketlabel,
962 struct mbuf *m, struct label *mbuflabel)
964 struct mac_mls *source, *dest;
966 source = SLOT(socketlabel);
967 dest = SLOT(mbuflabel);
969 mac_mls_copy_effective(source, dest);
973 mac_mls_create_socket(struct ucred *cred, struct socket *socket,
974 struct label *socketlabel)
976 struct mac_mls *source, *dest;
978 source = SLOT(cred->cr_label);
979 dest = SLOT(socketlabel);
981 mac_mls_copy_effective(source, dest);
985 mac_mls_create_pipe(struct ucred *cred, struct pipepair *pp,
986 struct label *pipelabel)
988 struct mac_mls *source, *dest;
990 source = SLOT(cred->cr_label);
991 dest = SLOT(pipelabel);
993 mac_mls_copy_effective(source, dest);
997 mac_mls_create_posix_sem(struct ucred *cred, struct ksem *ksemptr,
998 struct label *ks_label)
1000 struct mac_mls *source, *dest;
1002 source = SLOT(cred->cr_label);
1003 dest = SLOT(ks_label);
1005 mac_mls_copy_effective(source, dest);
1009 mac_mls_create_socket_from_socket(struct socket *oldsocket,
1010 struct label *oldsocketlabel, struct socket *newsocket,
1011 struct label *newsocketlabel)
1013 struct mac_mls *source, *dest;
1015 source = SLOT(oldsocketlabel);
1016 dest = SLOT(newsocketlabel);
1018 mac_mls_copy_effective(source, dest);
1022 mac_mls_relabel_socket(struct ucred *cred, struct socket *socket,
1023 struct label *socketlabel, struct label *newlabel)
1025 struct mac_mls *source, *dest;
1027 source = SLOT(newlabel);
1028 dest = SLOT(socketlabel);
1030 mac_mls_copy(source, dest);
1034 mac_mls_relabel_pipe(struct ucred *cred, struct pipepair *pp,
1035 struct label *pipelabel, struct label *newlabel)
1037 struct mac_mls *source, *dest;
1039 source = SLOT(newlabel);
1040 dest = SLOT(pipelabel);
1042 mac_mls_copy(source, dest);
1046 mac_mls_set_socket_peer_from_mbuf(struct mbuf *mbuf, struct label *mbuflabel,
1047 struct socket *socket, struct label *socketpeerlabel)
1049 struct mac_mls *source, *dest;
1051 source = SLOT(mbuflabel);
1052 dest = SLOT(socketpeerlabel);
1054 mac_mls_copy_effective(source, dest);
1058 * Labeling event operations: System V IPC objects.
1062 mac_mls_create_sysv_msgmsg(struct ucred *cred, struct msqid_kernel *msqkptr,
1063 struct label *msqlabel, struct msg *msgptr, struct label *msglabel)
1065 struct mac_mls *source, *dest;
1067 /* Ignore the msgq label */
1068 source = SLOT(cred->cr_label);
1069 dest = SLOT(msglabel);
1071 mac_mls_copy_effective(source, dest);
1075 mac_mls_create_sysv_msgqueue(struct ucred *cred, struct msqid_kernel *msqkptr,
1076 struct label *msqlabel)
1078 struct mac_mls *source, *dest;
1080 source = SLOT(cred->cr_label);
1081 dest = SLOT(msqlabel);
1083 mac_mls_copy_effective(source, dest);
1087 mac_mls_create_sysv_sem(struct ucred *cred, struct semid_kernel *semakptr,
1088 struct label *semalabel)
1090 struct mac_mls *source, *dest;
1092 source = SLOT(cred->cr_label);
1093 dest = SLOT(semalabel);
1095 mac_mls_copy_effective(source, dest);
1099 mac_mls_create_sysv_shm(struct ucred *cred, struct shmid_kernel *shmsegptr,
1100 struct label *shmlabel)
1102 struct mac_mls *source, *dest;
1104 source = SLOT(cred->cr_label);
1105 dest = SLOT(shmlabel);
1107 mac_mls_copy_effective(source, dest);
1111 * Labeling event operations: network objects.
1114 mac_mls_set_socket_peer_from_socket(struct socket *oldsocket,
1115 struct label *oldsocketlabel, struct socket *newsocket,
1116 struct label *newsocketpeerlabel)
1118 struct mac_mls *source, *dest;
1120 source = SLOT(oldsocketlabel);
1121 dest = SLOT(newsocketpeerlabel);
1123 mac_mls_copy_effective(source, dest);
1127 mac_mls_create_bpfdesc(struct ucred *cred, struct bpf_d *bpf_d,
1128 struct label *bpflabel)
1130 struct mac_mls *source, *dest;
1132 source = SLOT(cred->cr_label);
1133 dest = SLOT(bpflabel);
1135 mac_mls_copy_effective(source, dest);
1139 mac_mls_create_ifnet(struct ifnet *ifnet, struct label *ifnetlabel)
1141 struct mac_mls *dest;
1144 dest = SLOT(ifnetlabel);
1146 if (ifnet->if_type == IFT_LOOP)
1147 type = MAC_MLS_TYPE_EQUAL;
1149 type = MAC_MLS_TYPE_LOW;
1151 mac_mls_set_effective(dest, type, 0, NULL);
1152 mac_mls_set_range(dest, type, 0, NULL, type, 0, NULL);
1156 mac_mls_create_ipq(struct mbuf *fragment, struct label *fragmentlabel,
1157 struct ipq *ipq, struct label *ipqlabel)
1159 struct mac_mls *source, *dest;
1161 source = SLOT(fragmentlabel);
1162 dest = SLOT(ipqlabel);
1164 mac_mls_copy_effective(source, dest);
1168 mac_mls_create_datagram_from_ipq(struct ipq *ipq, struct label *ipqlabel,
1169 struct mbuf *datagram, struct label *datagramlabel)
1171 struct mac_mls *source, *dest;
1173 source = SLOT(ipqlabel);
1174 dest = SLOT(datagramlabel);
1176 /* Just use the head, since we require them all to match. */
1177 mac_mls_copy_effective(source, dest);
1181 mac_mls_create_fragment(struct mbuf *datagram, struct label *datagramlabel,
1182 struct mbuf *fragment, struct label *fragmentlabel)
1184 struct mac_mls *source, *dest;
1186 source = SLOT(datagramlabel);
1187 dest = SLOT(fragmentlabel);
1189 mac_mls_copy_effective(source, dest);
1193 mac_mls_create_mbuf_from_inpcb(struct inpcb *inp, struct label *inplabel,
1194 struct mbuf *m, struct label *mlabel)
1196 struct mac_mls *source, *dest;
1198 source = SLOT(inplabel);
1199 dest = SLOT(mlabel);
1201 mac_mls_copy_effective(source, dest);
1205 mac_mls_create_mbuf_linklayer(struct ifnet *ifnet, struct label *ifnetlabel,
1206 struct mbuf *mbuf, struct label *mbuflabel)
1208 struct mac_mls *dest;
1210 dest = SLOT(mbuflabel);
1212 mac_mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL);
1216 mac_mls_create_mbuf_from_bpfdesc(struct bpf_d *bpf_d, struct label *bpflabel,
1217 struct mbuf *mbuf, struct label *mbuflabel)
1219 struct mac_mls *source, *dest;
1221 source = SLOT(bpflabel);
1222 dest = SLOT(mbuflabel);
1224 mac_mls_copy_effective(source, dest);
1228 mac_mls_create_mbuf_from_ifnet(struct ifnet *ifnet, struct label *ifnetlabel,
1229 struct mbuf *m, struct label *mbuflabel)
1231 struct mac_mls *source, *dest;
1233 source = SLOT(ifnetlabel);
1234 dest = SLOT(mbuflabel);
1236 mac_mls_copy_effective(source, dest);
1240 mac_mls_create_mbuf_multicast_encap(struct mbuf *oldmbuf,
1241 struct label *oldmbuflabel, struct ifnet *ifnet, struct label *ifnetlabel,
1242 struct mbuf *newmbuf, struct label *newmbuflabel)
1244 struct mac_mls *source, *dest;
1246 source = SLOT(oldmbuflabel);
1247 dest = SLOT(newmbuflabel);
1249 mac_mls_copy_effective(source, dest);
1253 mac_mls_create_mbuf_netlayer(struct mbuf *oldmbuf, struct label *oldmbuflabel,
1254 struct mbuf *newmbuf, struct label *newmbuflabel)
1256 struct mac_mls *source, *dest;
1258 source = SLOT(oldmbuflabel);
1259 dest = SLOT(newmbuflabel);
1261 mac_mls_copy_effective(source, dest);
1265 mac_mls_fragment_match(struct mbuf *fragment, struct label *fragmentlabel,
1266 struct ipq *ipq, struct label *ipqlabel)
1268 struct mac_mls *a, *b;
1271 b = SLOT(fragmentlabel);
1273 return (mac_mls_equal_effective(a, b));
1277 mac_mls_relabel_ifnet(struct ucred *cred, struct ifnet *ifnet,
1278 struct label *ifnetlabel, struct label *newlabel)
1280 struct mac_mls *source, *dest;
1282 source = SLOT(newlabel);
1283 dest = SLOT(ifnetlabel);
1285 mac_mls_copy(source, dest);
1289 mac_mls_update_ipq(struct mbuf *fragment, struct label *fragmentlabel,
1290 struct ipq *ipq, struct label *ipqlabel)
1293 /* NOOP: we only accept matching labels, so no need to update */
1297 mac_mls_inpcb_sosetlabel(struct socket *so, struct label *solabel,
1298 struct inpcb *inp, struct label *inplabel)
1300 struct mac_mls *source, *dest;
1302 source = SLOT(solabel);
1303 dest = SLOT(inplabel);
1305 mac_mls_copy(source, dest);
1309 * Labeling event operations: processes.
1312 mac_mls_create_proc0(struct ucred *cred)
1314 struct mac_mls *dest;
1316 dest = SLOT(cred->cr_label);
1318 mac_mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL);
1319 mac_mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH,
1324 mac_mls_create_proc1(struct ucred *cred)
1326 struct mac_mls *dest;
1328 dest = SLOT(cred->cr_label);
1330 mac_mls_set_effective(dest, MAC_MLS_TYPE_LOW, 0, NULL);
1331 mac_mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH,
1336 mac_mls_relabel_cred(struct ucred *cred, struct label *newlabel)
1338 struct mac_mls *source, *dest;
1340 source = SLOT(newlabel);
1341 dest = SLOT(cred->cr_label);
1343 mac_mls_copy(source, dest);
1347 * Label cleanup/flush operations.
1350 mac_mls_cleanup_sysv_msgmsg(struct label *msglabel)
1353 bzero(SLOT(msglabel), sizeof(struct mac_mls));
1357 mac_mls_cleanup_sysv_msgqueue(struct label *msqlabel)
1360 bzero(SLOT(msqlabel), sizeof(struct mac_mls));
1364 mac_mls_cleanup_sysv_sem(struct label *semalabel)
1367 bzero(SLOT(semalabel), sizeof(struct mac_mls));
1371 mac_mls_cleanup_sysv_shm(struct label *shmlabel)
1374 bzero(SLOT(shmlabel), sizeof(struct mac_mls));
1378 * Access control checks.
1381 mac_mls_check_bpfdesc_receive(struct bpf_d *bpf_d, struct label *bpflabel,
1382 struct ifnet *ifnet, struct label *ifnetlabel)
1384 struct mac_mls *a, *b;
1386 if (!mac_mls_enabled)
1390 b = SLOT(ifnetlabel);
1392 if (mac_mls_equal_effective(a, b))
1398 mac_mls_check_cred_relabel(struct ucred *cred, struct label *newlabel)
1400 struct mac_mls *subj, *new;
1403 subj = SLOT(cred->cr_label);
1404 new = SLOT(newlabel);
1407 * If there is an MLS label update for the credential, it may be
1408 * an update of effective, range, or both.
1410 error = mls_atmostflags(new, MAC_MLS_FLAGS_BOTH);
1415 * If the MLS label is to be changed, authorize as appropriate.
1417 if (new->mm_flags & MAC_MLS_FLAGS_BOTH) {
1419 * If the change request modifies both the MLS label effective
1420 * and range, check that the new effective will be in the
1423 if ((new->mm_flags & MAC_MLS_FLAGS_BOTH) ==
1424 MAC_MLS_FLAGS_BOTH &&
1425 !mac_mls_effective_in_range(new, new))
1429 * To change the MLS effective label on a credential, the
1430 * new effective label must be in the current range.
1432 if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE &&
1433 !mac_mls_effective_in_range(new, subj))
1437 * To change the MLS range label on a credential, the
1438 * new range must be in the current range.
1440 if (new->mm_flags & MAC_MLS_FLAG_RANGE &&
1441 !mac_mls_range_in_range(new, subj))
1445 * To have EQUAL in any component of the new credential
1446 * MLS label, the subject must already have EQUAL in
1449 if (mac_mls_contains_equal(new)) {
1450 error = mac_mls_subject_privileged(subj);
1460 mac_mls_check_cred_visible(struct ucred *u1, struct ucred *u2)
1462 struct mac_mls *subj, *obj;
1464 if (!mac_mls_enabled)
1467 subj = SLOT(u1->cr_label);
1468 obj = SLOT(u2->cr_label);
1471 if (!mac_mls_dominate_effective(subj, obj))
1478 mac_mls_check_ifnet_relabel(struct ucred *cred, struct ifnet *ifnet,
1479 struct label *ifnetlabel, struct label *newlabel)
1481 struct mac_mls *subj, *new;
1484 subj = SLOT(cred->cr_label);
1485 new = SLOT(newlabel);
1488 * If there is an MLS label update for the interface, it may
1489 * be an update of effective, range, or both.
1491 error = mls_atmostflags(new, MAC_MLS_FLAGS_BOTH);
1496 * Relabeling network interfaces requires MLS privilege.
1498 error = mac_mls_subject_privileged(subj);
1504 mac_mls_check_ifnet_transmit(struct ifnet *ifnet, struct label *ifnetlabel,
1505 struct mbuf *m, struct label *mbuflabel)
1507 struct mac_mls *p, *i;
1509 if (!mac_mls_enabled)
1512 p = SLOT(mbuflabel);
1513 i = SLOT(ifnetlabel);
1515 return (mac_mls_effective_in_range(p, i) ? 0 : EACCES);
1519 mac_mls_check_inpcb_deliver(struct inpcb *inp, struct label *inplabel,
1520 struct mbuf *m, struct label *mlabel)
1522 struct mac_mls *p, *i;
1524 if (!mac_mls_enabled)
1530 return (mac_mls_equal_effective(p, i) ? 0 : EACCES);
1534 mac_mls_check_sysv_msgrcv(struct ucred *cred, struct msg *msgptr,
1535 struct label *msglabel)
1537 struct mac_mls *subj, *obj;
1539 if (!mac_mls_enabled)
1542 subj = SLOT(cred->cr_label);
1543 obj = SLOT(msglabel);
1545 if (!mac_mls_dominate_effective(subj, obj))
1552 mac_mls_check_sysv_msgrmid(struct ucred *cred, struct msg *msgptr,
1553 struct label *msglabel)
1555 struct mac_mls *subj, *obj;
1557 if (!mac_mls_enabled)
1560 subj = SLOT(cred->cr_label);
1561 obj = SLOT(msglabel);
1563 if (!mac_mls_dominate_effective(obj, subj))
1570 mac_mls_check_sysv_msqget(struct ucred *cred, struct msqid_kernel *msqkptr,
1571 struct label *msqklabel)
1573 struct mac_mls *subj, *obj;
1575 if (!mac_mls_enabled)
1578 subj = SLOT(cred->cr_label);
1579 obj = SLOT(msqklabel);
1581 if (!mac_mls_dominate_effective(subj, obj))
1588 mac_mls_check_sysv_msqsnd(struct ucred *cred, struct msqid_kernel *msqkptr,
1589 struct label *msqklabel)
1591 struct mac_mls *subj, *obj;
1593 if (!mac_mls_enabled)
1596 subj = SLOT(cred->cr_label);
1597 obj = SLOT(msqklabel);
1599 if (!mac_mls_dominate_effective(obj, subj))
1606 mac_mls_check_sysv_msqrcv(struct ucred *cred, struct msqid_kernel *msqkptr,
1607 struct label *msqklabel)
1609 struct mac_mls *subj, *obj;
1611 if (!mac_mls_enabled)
1614 subj = SLOT(cred->cr_label);
1615 obj = SLOT(msqklabel);
1617 if (!mac_mls_dominate_effective(subj, obj))
1624 mac_mls_check_sysv_msqctl(struct ucred *cred, struct msqid_kernel *msqkptr,
1625 struct label *msqklabel, int cmd)
1627 struct mac_mls *subj, *obj;
1629 if (!mac_mls_enabled)
1632 subj = SLOT(cred->cr_label);
1633 obj = SLOT(msqklabel);
1638 if (!mac_mls_dominate_effective(obj, subj))
1643 if (!mac_mls_dominate_effective(subj, obj))
1655 mac_mls_check_sysv_semctl(struct ucred *cred, struct semid_kernel *semakptr,
1656 struct label *semaklabel, int cmd)
1658 struct mac_mls *subj, *obj;
1660 if (!mac_mls_enabled)
1663 subj = SLOT(cred->cr_label);
1664 obj = SLOT(semaklabel);
1671 if (!mac_mls_dominate_effective(obj, subj))
1681 if (!mac_mls_dominate_effective(subj, obj))
1693 mac_mls_check_sysv_semget(struct ucred *cred, struct semid_kernel *semakptr,
1694 struct label *semaklabel)
1696 struct mac_mls *subj, *obj;
1698 if (!mac_mls_enabled)
1701 subj = SLOT(cred->cr_label);
1702 obj = SLOT(semaklabel);
1704 if (!mac_mls_dominate_effective(subj, obj))
1711 mac_mls_check_sysv_semop(struct ucred *cred, struct semid_kernel *semakptr,
1712 struct label *semaklabel, size_t accesstype)
1714 struct mac_mls *subj, *obj;
1716 if (!mac_mls_enabled)
1719 subj = SLOT(cred->cr_label);
1720 obj = SLOT(semaklabel);
1722 if( accesstype & SEM_R )
1723 if (!mac_mls_dominate_effective(subj, obj))
1726 if( accesstype & SEM_A )
1727 if (!mac_mls_dominate_effective(obj, subj))
1734 mac_mls_check_sysv_shmat(struct ucred *cred, struct shmid_kernel *shmsegptr,
1735 struct label *shmseglabel, int shmflg)
1737 struct mac_mls *subj, *obj;
1739 if (!mac_mls_enabled)
1742 subj = SLOT(cred->cr_label);
1743 obj = SLOT(shmseglabel);
1745 if (!mac_mls_dominate_effective(subj, obj))
1747 if ((shmflg & SHM_RDONLY) == 0)
1748 if (!mac_mls_dominate_effective(obj, subj))
1755 mac_mls_check_sysv_shmctl(struct ucred *cred, struct shmid_kernel *shmsegptr,
1756 struct label *shmseglabel, int cmd)
1758 struct mac_mls *subj, *obj;
1760 if (!mac_mls_enabled)
1763 subj = SLOT(cred->cr_label);
1764 obj = SLOT(shmseglabel);
1769 if (!mac_mls_dominate_effective(obj, subj))
1775 if (!mac_mls_dominate_effective(subj, obj))
1787 mac_mls_check_sysv_shmget(struct ucred *cred, struct shmid_kernel *shmsegptr,
1788 struct label *shmseglabel, int shmflg)
1790 struct mac_mls *subj, *obj;
1792 if (!mac_mls_enabled)
1795 subj = SLOT(cred->cr_label);
1796 obj = SLOT(shmseglabel);
1798 if (!mac_mls_dominate_effective(obj, subj))
1805 mac_mls_check_mount_stat(struct ucred *cred, struct mount *mp,
1806 struct label *mntlabel)
1808 struct mac_mls *subj, *obj;
1810 if (!mac_mls_enabled)
1813 subj = SLOT(cred->cr_label);
1814 obj = SLOT(mntlabel);
1816 if (!mac_mls_dominate_effective(subj, obj))
1823 mac_mls_check_pipe_ioctl(struct ucred *cred, struct pipepair *pp,
1824 struct label *pipelabel, unsigned long cmd, void /* caddr_t */ *data)
1827 if(!mac_mls_enabled)
1830 /* XXX: This will be implemented soon... */
1836 mac_mls_check_pipe_poll(struct ucred *cred, struct pipepair *pp,
1837 struct label *pipelabel)
1839 struct mac_mls *subj, *obj;
1841 if (!mac_mls_enabled)
1844 subj = SLOT(cred->cr_label);
1845 obj = SLOT((pipelabel));
1847 if (!mac_mls_dominate_effective(subj, obj))
1854 mac_mls_check_pipe_read(struct ucred *cred, struct pipepair *pp,
1855 struct label *pipelabel)
1857 struct mac_mls *subj, *obj;
1859 if (!mac_mls_enabled)
1862 subj = SLOT(cred->cr_label);
1863 obj = SLOT((pipelabel));
1865 if (!mac_mls_dominate_effective(subj, obj))
1872 mac_mls_check_pipe_relabel(struct ucred *cred, struct pipepair *pp,
1873 struct label *pipelabel, struct label *newlabel)
1875 struct mac_mls *subj, *obj, *new;
1878 new = SLOT(newlabel);
1879 subj = SLOT(cred->cr_label);
1880 obj = SLOT(pipelabel);
1883 * If there is an MLS label update for a pipe, it must be a
1886 error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE);
1891 * To perform a relabel of a pipe (MLS label or not), MLS must
1892 * authorize the relabel.
1894 if (!mac_mls_effective_in_range(obj, subj))
1898 * If the MLS label is to be changed, authorize as appropriate.
1900 if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
1902 * To change the MLS label on a pipe, the new pipe label
1903 * must be in the subject range.
1905 if (!mac_mls_effective_in_range(new, subj))
1909 * To change the MLS label on a pipe to be EQUAL, the
1910 * subject must have appropriate privilege.
1912 if (mac_mls_contains_equal(new)) {
1913 error = mac_mls_subject_privileged(subj);
1923 mac_mls_check_pipe_stat(struct ucred *cred, struct pipepair *pp,
1924 struct label *pipelabel)
1926 struct mac_mls *subj, *obj;
1928 if (!mac_mls_enabled)
1931 subj = SLOT(cred->cr_label);
1932 obj = SLOT((pipelabel));
1934 if (!mac_mls_dominate_effective(subj, obj))
1941 mac_mls_check_pipe_write(struct ucred *cred, struct pipepair *pp,
1942 struct label *pipelabel)
1944 struct mac_mls *subj, *obj;
1946 if (!mac_mls_enabled)
1949 subj = SLOT(cred->cr_label);
1950 obj = SLOT((pipelabel));
1952 if (!mac_mls_dominate_effective(obj, subj))
1959 mac_mls_check_posix_sem_write(struct ucred *cred, struct ksem *ksemptr,
1960 struct label *ks_label)
1962 struct mac_mls *subj, *obj;
1964 if (!mac_mls_enabled)
1967 subj = SLOT(cred->cr_label);
1968 obj = SLOT(ks_label);
1970 if (!mac_mls_dominate_effective(obj, subj))
1977 mac_mls_check_posix_sem_rdonly(struct ucred *cred, struct ksem *ksemptr,
1978 struct label *ks_label)
1980 struct mac_mls *subj, *obj;
1982 if (!mac_mls_enabled)
1985 subj = SLOT(cred->cr_label);
1986 obj = SLOT(ks_label);
1988 if (!mac_mls_dominate_effective(subj, obj))
1995 mac_mls_check_proc_debug(struct ucred *cred, struct proc *proc)
1997 struct mac_mls *subj, *obj;
1999 if (!mac_mls_enabled)
2002 subj = SLOT(cred->cr_label);
2003 obj = SLOT(proc->p_ucred->cr_label);
2005 /* XXX: range checks */
2006 if (!mac_mls_dominate_effective(subj, obj))
2008 if (!mac_mls_dominate_effective(obj, subj))
2015 mac_mls_check_proc_sched(struct ucred *cred, struct proc *proc)
2017 struct mac_mls *subj, *obj;
2019 if (!mac_mls_enabled)
2022 subj = SLOT(cred->cr_label);
2023 obj = SLOT(proc->p_ucred->cr_label);
2025 /* XXX: range checks */
2026 if (!mac_mls_dominate_effective(subj, obj))
2028 if (!mac_mls_dominate_effective(obj, subj))
2035 mac_mls_check_proc_signal(struct ucred *cred, struct proc *proc, int signum)
2037 struct mac_mls *subj, *obj;
2039 if (!mac_mls_enabled)
2042 subj = SLOT(cred->cr_label);
2043 obj = SLOT(proc->p_ucred->cr_label);
2045 /* XXX: range checks */
2046 if (!mac_mls_dominate_effective(subj, obj))
2048 if (!mac_mls_dominate_effective(obj, subj))
2055 mac_mls_check_socket_deliver(struct socket *so, struct label *socketlabel,
2056 struct mbuf *m, struct label *mbuflabel)
2058 struct mac_mls *p, *s;
2060 if (!mac_mls_enabled)
2063 p = SLOT(mbuflabel);
2064 s = SLOT(socketlabel);
2066 return (mac_mls_equal_effective(p, s) ? 0 : EACCES);
2070 mac_mls_check_socket_relabel(struct ucred *cred, struct socket *socket,
2071 struct label *socketlabel, struct label *newlabel)
2073 struct mac_mls *subj, *obj, *new;
2076 new = SLOT(newlabel);
2077 subj = SLOT(cred->cr_label);
2078 obj = SLOT(socketlabel);
2081 * If there is an MLS label update for the socket, it may be
2082 * an update of effective.
2084 error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE);
2089 * To relabel a socket, the old socket effective must be in the subject
2092 if (!mac_mls_effective_in_range(obj, subj))
2096 * If the MLS label is to be changed, authorize as appropriate.
2098 if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
2100 * To relabel a socket, the new socket effective must be in
2101 * the subject range.
2103 if (!mac_mls_effective_in_range(new, subj))
2107 * To change the MLS label on the socket to contain EQUAL,
2108 * the subject must have appropriate privilege.
2110 if (mac_mls_contains_equal(new)) {
2111 error = mac_mls_subject_privileged(subj);
2121 mac_mls_check_socket_visible(struct ucred *cred, struct socket *socket,
2122 struct label *socketlabel)
2124 struct mac_mls *subj, *obj;
2126 if (!mac_mls_enabled)
2129 subj = SLOT(cred->cr_label);
2130 obj = SLOT(socketlabel);
2132 if (!mac_mls_dominate_effective(subj, obj))
2139 mac_mls_check_system_swapon(struct ucred *cred, struct vnode *vp,
2140 struct label *label)
2142 struct mac_mls *subj, *obj;
2144 if (!mac_mls_enabled)
2147 subj = SLOT(cred->cr_label);
2150 if (!mac_mls_dominate_effective(obj, subj) ||
2151 !mac_mls_dominate_effective(subj, obj))
2158 mac_mls_check_vnode_chdir(struct ucred *cred, struct vnode *dvp,
2159 struct label *dlabel)
2161 struct mac_mls *subj, *obj;
2163 if (!mac_mls_enabled)
2166 subj = SLOT(cred->cr_label);
2169 if (!mac_mls_dominate_effective(subj, obj))
2176 mac_mls_check_vnode_chroot(struct ucred *cred, struct vnode *dvp,
2177 struct label *dlabel)
2179 struct mac_mls *subj, *obj;
2181 if (!mac_mls_enabled)
2184 subj = SLOT(cred->cr_label);
2187 if (!mac_mls_dominate_effective(subj, obj))
2194 mac_mls_check_vnode_create(struct ucred *cred, struct vnode *dvp,
2195 struct label *dlabel, struct componentname *cnp, struct vattr *vap)
2197 struct mac_mls *subj, *obj;
2199 if (!mac_mls_enabled)
2202 subj = SLOT(cred->cr_label);
2205 if (!mac_mls_dominate_effective(obj, subj))
2212 mac_mls_check_vnode_delete(struct ucred *cred, struct vnode *dvp,
2213 struct label *dlabel, struct vnode *vp, struct label *label,
2214 struct componentname *cnp)
2216 struct mac_mls *subj, *obj;
2218 if (!mac_mls_enabled)
2221 subj = SLOT(cred->cr_label);
2224 if (!mac_mls_dominate_effective(obj, subj))
2229 if (!mac_mls_dominate_effective(obj, subj))
2236 mac_mls_check_vnode_deleteacl(struct ucred *cred, struct vnode *vp,
2237 struct label *label, acl_type_t type)
2239 struct mac_mls *subj, *obj;
2241 if (!mac_mls_enabled)
2244 subj = SLOT(cred->cr_label);
2247 if (!mac_mls_dominate_effective(obj, subj))
2254 mac_mls_check_vnode_deleteextattr(struct ucred *cred, struct vnode *vp,
2255 struct label *label, int attrnamespace, const char *name)
2257 struct mac_mls *subj, *obj;
2259 if (!mac_mls_enabled)
2262 subj = SLOT(cred->cr_label);
2265 if (!mac_mls_dominate_effective(obj, subj))
2272 mac_mls_check_vnode_exec(struct ucred *cred, struct vnode *vp,
2273 struct label *label, struct image_params *imgp,
2274 struct label *execlabel)
2276 struct mac_mls *subj, *obj, *exec;
2279 if (execlabel != NULL) {
2281 * We currently don't permit labels to be changed at
2282 * exec-time as part of MLS, so disallow non-NULL
2283 * MLS label elements in the execlabel.
2285 exec = SLOT(execlabel);
2286 error = mls_atmostflags(exec, 0);
2291 if (!mac_mls_enabled)
2294 subj = SLOT(cred->cr_label);
2297 if (!mac_mls_dominate_effective(subj, obj))
2304 mac_mls_check_vnode_getacl(struct ucred *cred, struct vnode *vp,
2305 struct label *label, acl_type_t type)
2307 struct mac_mls *subj, *obj;
2309 if (!mac_mls_enabled)
2312 subj = SLOT(cred->cr_label);
2315 if (!mac_mls_dominate_effective(subj, obj))
2322 mac_mls_check_vnode_getextattr(struct ucred *cred, struct vnode *vp,
2323 struct label *label, int attrnamespace, const char *name, struct uio *uio)
2325 struct mac_mls *subj, *obj;
2327 if (!mac_mls_enabled)
2330 subj = SLOT(cred->cr_label);
2333 if (!mac_mls_dominate_effective(subj, obj))
2340 mac_mls_check_vnode_link(struct ucred *cred, struct vnode *dvp,
2341 struct label *dlabel, struct vnode *vp, struct label *label,
2342 struct componentname *cnp)
2344 struct mac_mls *subj, *obj;
2346 if (!mac_mls_enabled)
2349 subj = SLOT(cred->cr_label);
2352 if (!mac_mls_dominate_effective(obj, subj))
2356 if (!mac_mls_dominate_effective(obj, subj))
2363 mac_mls_check_vnode_listextattr(struct ucred *cred, struct vnode *vp,
2364 struct label *label, int attrnamespace)
2367 struct mac_mls *subj, *obj;
2369 if (!mac_mls_enabled)
2372 subj = SLOT(cred->cr_label);
2375 if (!mac_mls_dominate_effective(subj, obj))
2382 mac_mls_check_vnode_lookup(struct ucred *cred, struct vnode *dvp,
2383 struct label *dlabel, struct componentname *cnp)
2385 struct mac_mls *subj, *obj;
2387 if (!mac_mls_enabled)
2390 subj = SLOT(cred->cr_label);
2393 if (!mac_mls_dominate_effective(subj, obj))
2400 mac_mls_check_vnode_mmap(struct ucred *cred, struct vnode *vp,
2401 struct label *label, int prot, int flags)
2403 struct mac_mls *subj, *obj;
2406 * Rely on the use of open()-time protections to handle
2407 * non-revocation cases.
2409 if (!mac_mls_enabled || !revocation_enabled)
2412 subj = SLOT(cred->cr_label);
2415 if (prot & (VM_PROT_READ | VM_PROT_EXECUTE)) {
2416 if (!mac_mls_dominate_effective(subj, obj))
2419 if (((prot & VM_PROT_WRITE) != 0) && ((flags & MAP_SHARED) != 0)) {
2420 if (!mac_mls_dominate_effective(obj, subj))
2428 mac_mls_check_vnode_open(struct ucred *cred, struct vnode *vp,
2429 struct label *vnodelabel, int acc_mode)
2431 struct mac_mls *subj, *obj;
2433 if (!mac_mls_enabled)
2436 subj = SLOT(cred->cr_label);
2437 obj = SLOT(vnodelabel);
2439 /* XXX privilege override for admin? */
2440 if (acc_mode & (VREAD | VEXEC | VSTAT)) {
2441 if (!mac_mls_dominate_effective(subj, obj))
2444 if (acc_mode & (VWRITE | VAPPEND | VADMIN)) {
2445 if (!mac_mls_dominate_effective(obj, subj))
2453 mac_mls_check_vnode_poll(struct ucred *active_cred, struct ucred *file_cred,
2454 struct vnode *vp, struct label *label)
2456 struct mac_mls *subj, *obj;
2458 if (!mac_mls_enabled || !revocation_enabled)
2461 subj = SLOT(active_cred->cr_label);
2464 if (!mac_mls_dominate_effective(subj, obj))
2471 mac_mls_check_vnode_read(struct ucred *active_cred, struct ucred *file_cred,
2472 struct vnode *vp, struct label *label)
2474 struct mac_mls *subj, *obj;
2476 if (!mac_mls_enabled || !revocation_enabled)
2479 subj = SLOT(active_cred->cr_label);
2482 if (!mac_mls_dominate_effective(subj, obj))
2489 mac_mls_check_vnode_readdir(struct ucred *cred, struct vnode *dvp,
2490 struct label *dlabel)
2492 struct mac_mls *subj, *obj;
2494 if (!mac_mls_enabled)
2497 subj = SLOT(cred->cr_label);
2500 if (!mac_mls_dominate_effective(subj, obj))
2507 mac_mls_check_vnode_readlink(struct ucred *cred, struct vnode *vp,
2508 struct label *vnodelabel)
2510 struct mac_mls *subj, *obj;
2512 if (!mac_mls_enabled)
2515 subj = SLOT(cred->cr_label);
2516 obj = SLOT(vnodelabel);
2518 if (!mac_mls_dominate_effective(subj, obj))
2525 mac_mls_check_vnode_relabel(struct ucred *cred, struct vnode *vp,
2526 struct label *vnodelabel, struct label *newlabel)
2528 struct mac_mls *old, *new, *subj;
2531 old = SLOT(vnodelabel);
2532 new = SLOT(newlabel);
2533 subj = SLOT(cred->cr_label);
2536 * If there is an MLS label update for the vnode, it must be a
2539 error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE);
2544 * To perform a relabel of the vnode (MLS label or not), MLS must
2545 * authorize the relabel.
2547 if (!mac_mls_effective_in_range(old, subj))
2551 * If the MLS label is to be changed, authorize as appropriate.
2553 if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) {
2555 * To change the MLS label on a vnode, the new vnode label
2556 * must be in the subject range.
2558 if (!mac_mls_effective_in_range(new, subj))
2562 * To change the MLS label on the vnode to be EQUAL,
2563 * the subject must have appropriate privilege.
2565 if (mac_mls_contains_equal(new)) {
2566 error = mac_mls_subject_privileged(subj);
2577 mac_mls_check_vnode_rename_from(struct ucred *cred, struct vnode *dvp,
2578 struct label *dlabel, struct vnode *vp, struct label *label,
2579 struct componentname *cnp)
2581 struct mac_mls *subj, *obj;
2583 if (!mac_mls_enabled)
2586 subj = SLOT(cred->cr_label);
2589 if (!mac_mls_dominate_effective(obj, subj))
2594 if (!mac_mls_dominate_effective(obj, subj))
2601 mac_mls_check_vnode_rename_to(struct ucred *cred, struct vnode *dvp,
2602 struct label *dlabel, struct vnode *vp, struct label *label, int samedir,
2603 struct componentname *cnp)
2605 struct mac_mls *subj, *obj;
2607 if (!mac_mls_enabled)
2610 subj = SLOT(cred->cr_label);
2613 if (!mac_mls_dominate_effective(obj, subj))
2619 if (!mac_mls_dominate_effective(obj, subj))
2627 mac_mls_check_vnode_revoke(struct ucred *cred, struct vnode *vp,
2628 struct label *label)
2630 struct mac_mls *subj, *obj;
2632 if (!mac_mls_enabled)
2635 subj = SLOT(cred->cr_label);
2638 if (!mac_mls_dominate_effective(obj, subj))
2645 mac_mls_check_vnode_setacl(struct ucred *cred, struct vnode *vp,
2646 struct label *label, acl_type_t type, struct acl *acl)
2648 struct mac_mls *subj, *obj;
2650 if (!mac_mls_enabled)
2653 subj = SLOT(cred->cr_label);
2656 if (!mac_mls_dominate_effective(obj, subj))
2663 mac_mls_check_vnode_setextattr(struct ucred *cred, struct vnode *vp,
2664 struct label *vnodelabel, int attrnamespace, const char *name,
2667 struct mac_mls *subj, *obj;
2669 if (!mac_mls_enabled)
2672 subj = SLOT(cred->cr_label);
2673 obj = SLOT(vnodelabel);
2675 if (!mac_mls_dominate_effective(obj, subj))
2678 /* XXX: protect the MAC EA in a special way? */
2684 mac_mls_check_vnode_setflags(struct ucred *cred, struct vnode *vp,
2685 struct label *vnodelabel, u_long flags)
2687 struct mac_mls *subj, *obj;
2689 if (!mac_mls_enabled)
2692 subj = SLOT(cred->cr_label);
2693 obj = SLOT(vnodelabel);
2695 if (!mac_mls_dominate_effective(obj, subj))
2702 mac_mls_check_vnode_setmode(struct ucred *cred, struct vnode *vp,
2703 struct label *vnodelabel, mode_t mode)
2705 struct mac_mls *subj, *obj;
2707 if (!mac_mls_enabled)
2710 subj = SLOT(cred->cr_label);
2711 obj = SLOT(vnodelabel);
2713 if (!mac_mls_dominate_effective(obj, subj))
2720 mac_mls_check_vnode_setowner(struct ucred *cred, struct vnode *vp,
2721 struct label *vnodelabel, uid_t uid, gid_t gid)
2723 struct mac_mls *subj, *obj;
2725 if (!mac_mls_enabled)
2728 subj = SLOT(cred->cr_label);
2729 obj = SLOT(vnodelabel);
2731 if (!mac_mls_dominate_effective(obj, subj))
2738 mac_mls_check_vnode_setutimes(struct ucred *cred, struct vnode *vp,
2739 struct label *vnodelabel, struct timespec atime, struct timespec mtime)
2741 struct mac_mls *subj, *obj;
2743 if (!mac_mls_enabled)
2746 subj = SLOT(cred->cr_label);
2747 obj = SLOT(vnodelabel);
2749 if (!mac_mls_dominate_effective(obj, subj))
2756 mac_mls_check_vnode_stat(struct ucred *active_cred, struct ucred *file_cred,
2757 struct vnode *vp, struct label *vnodelabel)
2759 struct mac_mls *subj, *obj;
2761 if (!mac_mls_enabled)
2764 subj = SLOT(active_cred->cr_label);
2765 obj = SLOT(vnodelabel);
2767 if (!mac_mls_dominate_effective(subj, obj))
2774 mac_mls_check_vnode_write(struct ucred *active_cred, struct ucred *file_cred,
2775 struct vnode *vp, struct label *label)
2777 struct mac_mls *subj, *obj;
2779 if (!mac_mls_enabled || !revocation_enabled)
2782 subj = SLOT(active_cred->cr_label);
2785 if (!mac_mls_dominate_effective(obj, subj))
2792 mac_mls_associate_nfsd_label(struct ucred *cred)
2794 struct mac_mls *label;
2796 label = SLOT(cred->cr_label);
2797 mac_mls_set_effective(label, MAC_MLS_TYPE_LOW, 0, NULL);
2798 mac_mls_set_range(label, MAC_MLS_TYPE_LOW, 0, NULL,
2799 MAC_MLS_TYPE_HIGH, 0, NULL);
2802 static struct mac_policy_ops mac_mls_ops =
2804 .mpo_init = mac_mls_init,
2805 .mpo_init_bpfdesc_label = mac_mls_init_label,
2806 .mpo_init_cred_label = mac_mls_init_label,
2807 .mpo_init_devfsdirent_label = mac_mls_init_label,
2808 .mpo_init_ifnet_label = mac_mls_init_label,
2809 .mpo_init_inpcb_label = mac_mls_init_label_waitcheck,
2810 .mpo_init_sysv_msgmsg_label = mac_mls_init_label,
2811 .mpo_init_sysv_msgqueue_label = mac_mls_init_label,
2812 .mpo_init_sysv_sem_label = mac_mls_init_label,
2813 .mpo_init_sysv_shm_label = mac_mls_init_label,
2814 .mpo_init_ipq_label = mac_mls_init_label_waitcheck,
2815 .mpo_init_mbuf_label = mac_mls_init_label_waitcheck,
2816 .mpo_init_mount_label = mac_mls_init_label,
2817 .mpo_init_mount_fs_label = mac_mls_init_label,
2818 .mpo_init_pipe_label = mac_mls_init_label,
2819 .mpo_init_posix_sem_label = mac_mls_init_label,
2820 .mpo_init_socket_label = mac_mls_init_label_waitcheck,
2821 .mpo_init_socket_peer_label = mac_mls_init_label_waitcheck,
2822 .mpo_init_vnode_label = mac_mls_init_label,
2823 .mpo_destroy_bpfdesc_label = mac_mls_destroy_label,
2824 .mpo_destroy_cred_label = mac_mls_destroy_label,
2825 .mpo_destroy_devfsdirent_label = mac_mls_destroy_label,
2826 .mpo_destroy_ifnet_label = mac_mls_destroy_label,
2827 .mpo_destroy_inpcb_label = mac_mls_destroy_label,
2828 .mpo_destroy_sysv_msgmsg_label = mac_mls_destroy_label,
2829 .mpo_destroy_sysv_msgqueue_label = mac_mls_destroy_label,
2830 .mpo_destroy_sysv_sem_label = mac_mls_destroy_label,
2831 .mpo_destroy_sysv_shm_label = mac_mls_destroy_label,
2832 .mpo_destroy_ipq_label = mac_mls_destroy_label,
2833 .mpo_destroy_mbuf_label = mac_mls_destroy_label,
2834 .mpo_destroy_mount_label = mac_mls_destroy_label,
2835 .mpo_destroy_mount_fs_label = mac_mls_destroy_label,
2836 .mpo_destroy_pipe_label = mac_mls_destroy_label,
2837 .mpo_destroy_posix_sem_label = mac_mls_destroy_label,
2838 .mpo_destroy_socket_label = mac_mls_destroy_label,
2839 .mpo_destroy_socket_peer_label = mac_mls_destroy_label,
2840 .mpo_destroy_vnode_label = mac_mls_destroy_label,
2841 .mpo_copy_cred_label = mac_mls_copy_label,
2842 .mpo_copy_ifnet_label = mac_mls_copy_label,
2843 .mpo_copy_mbuf_label = mac_mls_copy_label,
2844 .mpo_copy_pipe_label = mac_mls_copy_label,
2845 .mpo_copy_socket_label = mac_mls_copy_label,
2846 .mpo_copy_vnode_label = mac_mls_copy_label,
2847 .mpo_externalize_cred_label = mac_mls_externalize_label,
2848 .mpo_externalize_ifnet_label = mac_mls_externalize_label,
2849 .mpo_externalize_pipe_label = mac_mls_externalize_label,
2850 .mpo_externalize_socket_label = mac_mls_externalize_label,
2851 .mpo_externalize_socket_peer_label = mac_mls_externalize_label,
2852 .mpo_externalize_vnode_label = mac_mls_externalize_label,
2853 .mpo_internalize_cred_label = mac_mls_internalize_label,
2854 .mpo_internalize_ifnet_label = mac_mls_internalize_label,
2855 .mpo_internalize_pipe_label = mac_mls_internalize_label,
2856 .mpo_internalize_socket_label = mac_mls_internalize_label,
2857 .mpo_internalize_vnode_label = mac_mls_internalize_label,
2858 .mpo_create_devfs_device = mac_mls_create_devfs_device,
2859 .mpo_create_devfs_directory = mac_mls_create_devfs_directory,
2860 .mpo_create_devfs_symlink = mac_mls_create_devfs_symlink,
2861 .mpo_create_mount = mac_mls_create_mount,
2862 .mpo_relabel_vnode = mac_mls_relabel_vnode,
2863 .mpo_update_devfsdirent = mac_mls_update_devfsdirent,
2864 .mpo_associate_vnode_devfs = mac_mls_associate_vnode_devfs,
2865 .mpo_associate_vnode_extattr = mac_mls_associate_vnode_extattr,
2866 .mpo_associate_vnode_singlelabel = mac_mls_associate_vnode_singlelabel,
2867 .mpo_create_vnode_extattr = mac_mls_create_vnode_extattr,
2868 .mpo_setlabel_vnode_extattr = mac_mls_setlabel_vnode_extattr,
2869 .mpo_create_mbuf_from_socket = mac_mls_create_mbuf_from_socket,
2870 .mpo_create_pipe = mac_mls_create_pipe,
2871 .mpo_create_posix_sem = mac_mls_create_posix_sem,
2872 .mpo_create_socket = mac_mls_create_socket,
2873 .mpo_create_socket_from_socket = mac_mls_create_socket_from_socket,
2874 .mpo_relabel_pipe = mac_mls_relabel_pipe,
2875 .mpo_relabel_socket = mac_mls_relabel_socket,
2876 .mpo_set_socket_peer_from_mbuf = mac_mls_set_socket_peer_from_mbuf,
2877 .mpo_set_socket_peer_from_socket = mac_mls_set_socket_peer_from_socket,
2878 .mpo_create_bpfdesc = mac_mls_create_bpfdesc,
2879 .mpo_create_datagram_from_ipq = mac_mls_create_datagram_from_ipq,
2880 .mpo_create_fragment = mac_mls_create_fragment,
2881 .mpo_create_ifnet = mac_mls_create_ifnet,
2882 .mpo_create_inpcb_from_socket = mac_mls_create_inpcb_from_socket,
2883 .mpo_create_ipq = mac_mls_create_ipq,
2884 .mpo_create_sysv_msgmsg = mac_mls_create_sysv_msgmsg,
2885 .mpo_create_sysv_msgqueue = mac_mls_create_sysv_msgqueue,
2886 .mpo_create_sysv_sem = mac_mls_create_sysv_sem,
2887 .mpo_create_sysv_shm = mac_mls_create_sysv_shm,
2888 .mpo_create_mbuf_from_inpcb = mac_mls_create_mbuf_from_inpcb,
2889 .mpo_create_mbuf_linklayer = mac_mls_create_mbuf_linklayer,
2890 .mpo_create_mbuf_from_bpfdesc = mac_mls_create_mbuf_from_bpfdesc,
2891 .mpo_create_mbuf_from_ifnet = mac_mls_create_mbuf_from_ifnet,
2892 .mpo_create_mbuf_multicast_encap = mac_mls_create_mbuf_multicast_encap,
2893 .mpo_create_mbuf_netlayer = mac_mls_create_mbuf_netlayer,
2894 .mpo_fragment_match = mac_mls_fragment_match,
2895 .mpo_relabel_ifnet = mac_mls_relabel_ifnet,
2896 .mpo_update_ipq = mac_mls_update_ipq,
2897 .mpo_inpcb_sosetlabel = mac_mls_inpcb_sosetlabel,
2898 .mpo_create_proc0 = mac_mls_create_proc0,
2899 .mpo_create_proc1 = mac_mls_create_proc1,
2900 .mpo_relabel_cred = mac_mls_relabel_cred,
2901 .mpo_cleanup_sysv_msgmsg = mac_mls_cleanup_sysv_msgmsg,
2902 .mpo_cleanup_sysv_msgqueue = mac_mls_cleanup_sysv_msgqueue,
2903 .mpo_cleanup_sysv_sem = mac_mls_cleanup_sysv_sem,
2904 .mpo_cleanup_sysv_shm = mac_mls_cleanup_sysv_shm,
2905 .mpo_check_bpfdesc_receive = mac_mls_check_bpfdesc_receive,
2906 .mpo_check_cred_relabel = mac_mls_check_cred_relabel,
2907 .mpo_check_cred_visible = mac_mls_check_cred_visible,
2908 .mpo_check_ifnet_relabel = mac_mls_check_ifnet_relabel,
2909 .mpo_check_ifnet_transmit = mac_mls_check_ifnet_transmit,
2910 .mpo_check_inpcb_deliver = mac_mls_check_inpcb_deliver,
2911 .mpo_check_sysv_msgrcv = mac_mls_check_sysv_msgrcv,
2912 .mpo_check_sysv_msgrmid = mac_mls_check_sysv_msgrmid,
2913 .mpo_check_sysv_msqget = mac_mls_check_sysv_msqget,
2914 .mpo_check_sysv_msqsnd = mac_mls_check_sysv_msqsnd,
2915 .mpo_check_sysv_msqrcv = mac_mls_check_sysv_msqrcv,
2916 .mpo_check_sysv_msqctl = mac_mls_check_sysv_msqctl,
2917 .mpo_check_sysv_semctl = mac_mls_check_sysv_semctl,
2918 .mpo_check_sysv_semget = mac_mls_check_sysv_semget,
2919 .mpo_check_sysv_semop = mac_mls_check_sysv_semop,
2920 .mpo_check_sysv_shmat = mac_mls_check_sysv_shmat,
2921 .mpo_check_sysv_shmctl = mac_mls_check_sysv_shmctl,
2922 .mpo_check_sysv_shmget = mac_mls_check_sysv_shmget,
2923 .mpo_check_mount_stat = mac_mls_check_mount_stat,
2924 .mpo_check_pipe_ioctl = mac_mls_check_pipe_ioctl,
2925 .mpo_check_pipe_poll = mac_mls_check_pipe_poll,
2926 .mpo_check_pipe_read = mac_mls_check_pipe_read,
2927 .mpo_check_pipe_relabel = mac_mls_check_pipe_relabel,
2928 .mpo_check_pipe_stat = mac_mls_check_pipe_stat,
2929 .mpo_check_pipe_write = mac_mls_check_pipe_write,
2930 .mpo_check_posix_sem_destroy = mac_mls_check_posix_sem_write,
2931 .mpo_check_posix_sem_getvalue = mac_mls_check_posix_sem_rdonly,
2932 .mpo_check_posix_sem_open = mac_mls_check_posix_sem_write,
2933 .mpo_check_posix_sem_post = mac_mls_check_posix_sem_write,
2934 .mpo_check_posix_sem_unlink = mac_mls_check_posix_sem_write,
2935 .mpo_check_posix_sem_wait = mac_mls_check_posix_sem_write,
2936 .mpo_check_proc_debug = mac_mls_check_proc_debug,
2937 .mpo_check_proc_sched = mac_mls_check_proc_sched,
2938 .mpo_check_proc_signal = mac_mls_check_proc_signal,
2939 .mpo_check_socket_deliver = mac_mls_check_socket_deliver,
2940 .mpo_check_socket_relabel = mac_mls_check_socket_relabel,
2941 .mpo_check_socket_visible = mac_mls_check_socket_visible,
2942 .mpo_check_system_swapon = mac_mls_check_system_swapon,
2943 .mpo_check_vnode_access = mac_mls_check_vnode_open,
2944 .mpo_check_vnode_chdir = mac_mls_check_vnode_chdir,
2945 .mpo_check_vnode_chroot = mac_mls_check_vnode_chroot,
2946 .mpo_check_vnode_create = mac_mls_check_vnode_create,
2947 .mpo_check_vnode_delete = mac_mls_check_vnode_delete,
2948 .mpo_check_vnode_deleteacl = mac_mls_check_vnode_deleteacl,
2949 .mpo_check_vnode_deleteextattr = mac_mls_check_vnode_deleteextattr,
2950 .mpo_check_vnode_exec = mac_mls_check_vnode_exec,
2951 .mpo_check_vnode_getacl = mac_mls_check_vnode_getacl,
2952 .mpo_check_vnode_getextattr = mac_mls_check_vnode_getextattr,
2953 .mpo_check_vnode_link = mac_mls_check_vnode_link,
2954 .mpo_check_vnode_listextattr = mac_mls_check_vnode_listextattr,
2955 .mpo_check_vnode_lookup = mac_mls_check_vnode_lookup,
2956 .mpo_check_vnode_mmap = mac_mls_check_vnode_mmap,
2957 .mpo_check_vnode_open = mac_mls_check_vnode_open,
2958 .mpo_check_vnode_poll = mac_mls_check_vnode_poll,
2959 .mpo_check_vnode_read = mac_mls_check_vnode_read,
2960 .mpo_check_vnode_readdir = mac_mls_check_vnode_readdir,
2961 .mpo_check_vnode_readlink = mac_mls_check_vnode_readlink,
2962 .mpo_check_vnode_relabel = mac_mls_check_vnode_relabel,
2963 .mpo_check_vnode_rename_from = mac_mls_check_vnode_rename_from,
2964 .mpo_check_vnode_rename_to = mac_mls_check_vnode_rename_to,
2965 .mpo_check_vnode_revoke = mac_mls_check_vnode_revoke,
2966 .mpo_check_vnode_setacl = mac_mls_check_vnode_setacl,
2967 .mpo_check_vnode_setextattr = mac_mls_check_vnode_setextattr,
2968 .mpo_check_vnode_setflags = mac_mls_check_vnode_setflags,
2969 .mpo_check_vnode_setmode = mac_mls_check_vnode_setmode,
2970 .mpo_check_vnode_setowner = mac_mls_check_vnode_setowner,
2971 .mpo_check_vnode_setutimes = mac_mls_check_vnode_setutimes,
2972 .mpo_check_vnode_stat = mac_mls_check_vnode_stat,
2973 .mpo_check_vnode_write = mac_mls_check_vnode_write,
2974 .mpo_associate_nfsd_label = mac_mls_associate_nfsd_label,
2977 MAC_POLICY_SET(&mac_mls_ops, mac_mls, "TrustedBSD MAC/MLS",
2978 MPC_LOADTIME_FLAG_NOTLATE | MPC_LOADTIME_FLAG_LABELMBUFS, &mac_mls_slot);