diff options
author | rwatson <rwatson@FreeBSD.org> | 2007-10-25 11:31:11 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2007-10-25 11:31:11 +0000 |
commit | 2fd98af619b989e0cb105bb5b81e41d895fd8e20 (patch) | |
tree | 61b4f64bfe3a4b94291e8d7bf90db127671545c7 | |
parent | 9d167f82e426b3c6481ebd3bcdba5afbae063a7d (diff) | |
download | FreeBSD-src-2fd98af619b989e0cb105bb5b81e41d895fd8e20.zip FreeBSD-src-2fd98af619b989e0cb105bb5b81e41d895fd8e20.tar.gz |
Consistently name functions for mac_<policy> as <policy>_whatever rather
than mac_<policy>_whatever, as this shortens the names and makes the code
a bit easier to read.
When dealing with label structures, name variables 'mb', 'ml', 'mm rather
than the longer 'mac_biba', 'mac_lomac', and 'mac_mls', likewise making
the code a little easier to read.
Obtained from: TrustedBSD Project
-rw-r--r-- | sys/security/mac_biba/mac_biba.c | 1462 | ||||
-rw-r--r-- | sys/security/mac_bsdextended/mac_bsdextended.c | 264 | ||||
-rw-r--r-- | sys/security/mac_ifoff/mac_ifoff.c | 59 | ||||
-rw-r--r-- | sys/security/mac_lomac/mac_lomac.c | 1248 | ||||
-rw-r--r-- | sys/security/mac_mls/mac_mls.c | 1449 | ||||
-rw-r--r-- | sys/security/mac_none/mac_none.c | 4 | ||||
-rw-r--r-- | sys/security/mac_partition/mac_partition.c | 71 | ||||
-rw-r--r-- | sys/security/mac_portacl/mac_portacl.c | 52 | ||||
-rw-r--r-- | sys/security/mac_seeotheruids/mac_seeotheruids.c | 42 | ||||
-rw-r--r-- | sys/security/mac_stub/mac_stub.c | 4 | ||||
-rw-r--r-- | sys/security/mac_test/mac_test.c | 828 |
11 files changed, 2722 insertions, 2761 deletions
diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c index 2b66972..80c81ec 100644 --- a/sys/security/mac_biba/mac_biba.c +++ b/sys/security/mac_biba/mac_biba.c @@ -92,14 +92,14 @@ SYSCTL_DECL(_security_mac); SYSCTL_NODE(_security_mac, OID_AUTO, biba, CTLFLAG_RW, 0, "TrustedBSD mac_biba policy controls"); -static int mac_biba_label_size = sizeof(struct mac_biba); +static int biba_label_size = sizeof(struct mac_biba); SYSCTL_INT(_security_mac_biba, OID_AUTO, label_size, CTLFLAG_RD, - &mac_biba_label_size, 0, "Size of struct mac_biba"); + &biba_label_size, 0, "Size of struct mac_biba"); -static int mac_biba_enabled = 1; -SYSCTL_INT(_security_mac_biba, OID_AUTO, enabled, CTLFLAG_RW, - &mac_biba_enabled, 0, "Enforce MAC/Biba policy"); -TUNABLE_INT("security.mac.biba.enabled", &mac_biba_enabled); +static int biba_enabled = 1; +SYSCTL_INT(_security_mac_biba, OID_AUTO, enabled, CTLFLAG_RW, &biba_enabled, + 0, "Enforce MAC/Biba policy"); +TUNABLE_INT("security.mac.biba.enabled", &biba_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_biba, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, @@ -135,9 +135,9 @@ SYSCTL_INT(_security_mac_biba, OID_AUTO, revocation_enabled, CTLFLAG_RW, &revocation_enabled, 0, "Revoke access to objects on relabel"); TUNABLE_INT("security.mac.biba.revocation_enabled", &revocation_enabled); -static int mac_biba_slot; -#define SLOT(l) ((struct mac_biba *)mac_label_get((l), mac_biba_slot)) -#define SLOT_SET(l, val) mac_label_set((l), mac_biba_slot, (uintptr_t)(val)) +static int biba_slot; +#define SLOT(l) ((struct mac_biba *)mac_label_get((l), biba_slot)) +#define SLOT_SET(l, val) mac_label_set((l), biba_slot, (uintptr_t)(val)) static uma_zone_t zone_biba; @@ -159,27 +159,26 @@ biba_alloc(int flag) } static void -biba_free(struct mac_biba *mac_biba) +biba_free(struct mac_biba *mb) { - if (mac_biba != NULL) - uma_zfree(zone_biba, mac_biba); + if (mb != NULL) + uma_zfree(zone_biba, mb); else atomic_add_int(&destroyed_not_inited, 1); } static int -biba_atmostflags(struct mac_biba *mac_biba, int flags) +biba_atmostflags(struct mac_biba *mb, int flags) { - if ((mac_biba->mb_flags & flags) != mac_biba->mb_flags) + if ((mb->mb_flags & flags) != mb->mb_flags) return (EINVAL); return (0); } static int -mac_biba_dominate_element(struct mac_biba_element *a, - struct mac_biba_element *b) +biba_dominate_element(struct mac_biba_element *a, struct mac_biba_element *b) { int bit; @@ -199,7 +198,7 @@ mac_biba_dominate_element(struct mac_biba_element *a, return (1); default: - panic("mac_biba_dominate_element: b->mbe_type invalid"); + panic("biba_dominate_element: b->mbe_type invalid"); } case MAC_BIBA_TYPE_GRADE: @@ -220,70 +219,69 @@ mac_biba_dominate_element(struct mac_biba_element *a, return (a->mbe_grade >= b->mbe_grade); default: - panic("mac_biba_dominate_element: b->mbe_type invalid"); + panic("biba_dominate_element: b->mbe_type invalid"); } default: - panic("mac_biba_dominate_element: a->mbe_type invalid"); + panic("biba_dominate_element: a->mbe_type invalid"); } return (0); } static int -mac_biba_subject_dominate_high(struct mac_biba *mac_biba) +biba_subject_dominate_high(struct mac_biba *mb) { struct mac_biba_element *element; - KASSERT((mac_biba->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, - ("mac_biba_effective_in_range: mac_biba not effective")); - element = &mac_biba->mb_effective; + KASSERT((mb->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, + ("biba_effective_in_range: mb not effective")); + element = &mb->mb_effective; return (element->mbe_type == MAC_BIBA_TYPE_EQUAL || element->mbe_type == MAC_BIBA_TYPE_HIGH); } static int -mac_biba_range_in_range(struct mac_biba *rangea, struct mac_biba *rangeb) +biba_range_in_range(struct mac_biba *rangea, struct mac_biba *rangeb) { - return (mac_biba_dominate_element(&rangeb->mb_rangehigh, + return (biba_dominate_element(&rangeb->mb_rangehigh, &rangea->mb_rangehigh) && - mac_biba_dominate_element(&rangea->mb_rangelow, + biba_dominate_element(&rangea->mb_rangelow, &rangeb->mb_rangelow)); } static int -mac_biba_effective_in_range(struct mac_biba *effective, - struct mac_biba *range) +biba_effective_in_range(struct mac_biba *effective, struct mac_biba *range) { KASSERT((effective->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, - ("mac_biba_effective_in_range: a not effective")); + ("biba_effective_in_range: a not effective")); KASSERT((range->mb_flags & MAC_BIBA_FLAG_RANGE) != 0, - ("mac_biba_effective_in_range: b not range")); + ("biba_effective_in_range: b not range")); - return (mac_biba_dominate_element(&range->mb_rangehigh, + return (biba_dominate_element(&range->mb_rangehigh, &effective->mb_effective) && - mac_biba_dominate_element(&effective->mb_effective, + biba_dominate_element(&effective->mb_effective, &range->mb_rangelow)); return (1); } static int -mac_biba_dominate_effective(struct mac_biba *a, struct mac_biba *b) +biba_dominate_effective(struct mac_biba *a, struct mac_biba *b) { KASSERT((a->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, - ("mac_biba_dominate_effective: a not effective")); + ("biba_dominate_effective: a not effective")); KASSERT((b->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, - ("mac_biba_dominate_effective: b not effective")); + ("biba_dominate_effective: b not effective")); - return (mac_biba_dominate_element(&a->mb_effective, &b->mb_effective)); + return (biba_dominate_element(&a->mb_effective, &b->mb_effective)); } static int -mac_biba_equal_element(struct mac_biba_element *a, struct mac_biba_element *b) +biba_equal_element(struct mac_biba_element *a, struct mac_biba_element *b) { if (a->mbe_type == MAC_BIBA_TYPE_EQUAL || @@ -294,29 +292,30 @@ mac_biba_equal_element(struct mac_biba_element *a, struct mac_biba_element *b) } static int -mac_biba_equal_effective(struct mac_biba *a, struct mac_biba *b) +biba_equal_effective(struct mac_biba *a, struct mac_biba *b) { KASSERT((a->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, - ("mac_biba_equal_effective: a not effective")); + ("biba_equal_effective: a not effective")); KASSERT((b->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, - ("mac_biba_equal_effective: b not effective")); + ("biba_equal_effective: b not effective")); - return (mac_biba_equal_element(&a->mb_effective, &b->mb_effective)); + return (biba_equal_element(&a->mb_effective, &b->mb_effective)); } static int -mac_biba_contains_equal(struct mac_biba *mac_biba) +biba_contains_equal(struct mac_biba *mb) { - if (mac_biba->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) - if (mac_biba->mb_effective.mbe_type == MAC_BIBA_TYPE_EQUAL) + if (mb->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) { + if (mb->mb_effective.mbe_type == MAC_BIBA_TYPE_EQUAL) return (1); + } - if (mac_biba->mb_flags & MAC_BIBA_FLAG_RANGE) { - if (mac_biba->mb_rangelow.mbe_type == MAC_BIBA_TYPE_EQUAL) + if (mb->mb_flags & MAC_BIBA_FLAG_RANGE) { + if (mb->mb_rangelow.mbe_type == MAC_BIBA_TYPE_EQUAL) return (1); - if (mac_biba->mb_rangehigh.mbe_type == MAC_BIBA_TYPE_EQUAL) + if (mb->mb_rangehigh.mbe_type == MAC_BIBA_TYPE_EQUAL) return (1); } @@ -324,25 +323,24 @@ mac_biba_contains_equal(struct mac_biba *mac_biba) } static int -mac_biba_subject_privileged(struct mac_biba *mac_biba) +biba_subject_privileged(struct mac_biba *mb) { - KASSERT((mac_biba->mb_flags & MAC_BIBA_FLAGS_BOTH) == - MAC_BIBA_FLAGS_BOTH, - ("mac_biba_subject_privileged: subject doesn't have both labels")); + KASSERT((mb->mb_flags & MAC_BIBA_FLAGS_BOTH) == MAC_BIBA_FLAGS_BOTH, + ("biba_subject_privileged: subject doesn't have both labels")); /* If the effective is EQUAL, it's ok. */ - if (mac_biba->mb_effective.mbe_type == MAC_BIBA_TYPE_EQUAL) + if (mb->mb_effective.mbe_type == MAC_BIBA_TYPE_EQUAL) return (0); /* If either range endpoint is EQUAL, it's ok. */ - if (mac_biba->mb_rangelow.mbe_type == MAC_BIBA_TYPE_EQUAL || - mac_biba->mb_rangehigh.mbe_type == MAC_BIBA_TYPE_EQUAL) + if (mb->mb_rangelow.mbe_type == MAC_BIBA_TYPE_EQUAL || + mb->mb_rangehigh.mbe_type == MAC_BIBA_TYPE_EQUAL) return (0); /* If the range is low-high, it's ok. */ - if (mac_biba->mb_rangelow.mbe_type == MAC_BIBA_TYPE_LOW && - mac_biba->mb_rangehigh.mbe_type == MAC_BIBA_TYPE_HIGH) + if (mb->mb_rangelow.mbe_type == MAC_BIBA_TYPE_LOW && + mb->mb_rangehigh.mbe_type == MAC_BIBA_TYPE_HIGH) return (0); /* It's not ok. */ @@ -350,30 +348,30 @@ mac_biba_subject_privileged(struct mac_biba *mac_biba) } static int -mac_biba_high_effective(struct mac_biba *mac_biba) +biba_high_effective(struct mac_biba *mb) { - KASSERT((mac_biba->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, - ("mac_biba_equal_effective: mac_biba not effective")); + KASSERT((mb->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, + ("biba_equal_effective: mb not effective")); - return (mac_biba->mb_effective.mbe_type == MAC_BIBA_TYPE_HIGH); + return (mb->mb_effective.mbe_type == MAC_BIBA_TYPE_HIGH); } static int -mac_biba_valid(struct mac_biba *mac_biba) +biba_valid(struct mac_biba *mb) { - if (mac_biba->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) { - switch (mac_biba->mb_effective.mbe_type) { + if (mb->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) { + switch (mb->mb_effective.mbe_type) { case MAC_BIBA_TYPE_GRADE: break; case MAC_BIBA_TYPE_EQUAL: case MAC_BIBA_TYPE_HIGH: case MAC_BIBA_TYPE_LOW: - if (mac_biba->mb_effective.mbe_grade != 0 || + if (mb->mb_effective.mbe_grade != 0 || !MAC_BIBA_BIT_SET_EMPTY( - mac_biba->mb_effective.mbe_compartments)) + mb->mb_effective.mbe_compartments)) return (EINVAL); break; @@ -381,21 +379,21 @@ mac_biba_valid(struct mac_biba *mac_biba) return (EINVAL); } } else { - if (mac_biba->mb_effective.mbe_type != MAC_BIBA_TYPE_UNDEF) + if (mb->mb_effective.mbe_type != MAC_BIBA_TYPE_UNDEF) return (EINVAL); } - if (mac_biba->mb_flags & MAC_BIBA_FLAG_RANGE) { - switch (mac_biba->mb_rangelow.mbe_type) { + if (mb->mb_flags & MAC_BIBA_FLAG_RANGE) { + switch (mb->mb_rangelow.mbe_type) { case MAC_BIBA_TYPE_GRADE: break; case MAC_BIBA_TYPE_EQUAL: case MAC_BIBA_TYPE_HIGH: case MAC_BIBA_TYPE_LOW: - if (mac_biba->mb_rangelow.mbe_grade != 0 || + if (mb->mb_rangelow.mbe_grade != 0 || !MAC_BIBA_BIT_SET_EMPTY( - mac_biba->mb_rangelow.mbe_compartments)) + mb->mb_rangelow.mbe_compartments)) return (EINVAL); break; @@ -403,28 +401,28 @@ mac_biba_valid(struct mac_biba *mac_biba) return (EINVAL); } - switch (mac_biba->mb_rangehigh.mbe_type) { + switch (mb->mb_rangehigh.mbe_type) { case MAC_BIBA_TYPE_GRADE: break; case MAC_BIBA_TYPE_EQUAL: case MAC_BIBA_TYPE_HIGH: case MAC_BIBA_TYPE_LOW: - if (mac_biba->mb_rangehigh.mbe_grade != 0 || + if (mb->mb_rangehigh.mbe_grade != 0 || !MAC_BIBA_BIT_SET_EMPTY( - mac_biba->mb_rangehigh.mbe_compartments)) + mb->mb_rangehigh.mbe_compartments)) return (EINVAL); break; default: return (EINVAL); } - if (!mac_biba_dominate_element(&mac_biba->mb_rangehigh, - &mac_biba->mb_rangelow)) + if (!biba_dominate_element(&mb->mb_rangehigh, + &mb->mb_rangelow)) return (EINVAL); } else { - if (mac_biba->mb_rangelow.mbe_type != MAC_BIBA_TYPE_UNDEF || - mac_biba->mb_rangehigh.mbe_type != MAC_BIBA_TYPE_UNDEF) + if (mb->mb_rangelow.mbe_type != MAC_BIBA_TYPE_UNDEF || + mb->mb_rangehigh.mbe_type != MAC_BIBA_TYPE_UNDEF) return (EINVAL); } @@ -432,45 +430,43 @@ mac_biba_valid(struct mac_biba *mac_biba) } static void -mac_biba_set_range(struct mac_biba *mac_biba, u_short typelow, - u_short gradelow, u_char *compartmentslow, u_short typehigh, - u_short gradehigh, u_char *compartmentshigh) +biba_set_range(struct mac_biba *mb, u_short typelow, u_short gradelow, + u_char *compartmentslow, u_short typehigh, u_short gradehigh, + u_char *compartmentshigh) { - mac_biba->mb_rangelow.mbe_type = typelow; - mac_biba->mb_rangelow.mbe_grade = gradelow; + mb->mb_rangelow.mbe_type = typelow; + mb->mb_rangelow.mbe_grade = gradelow; if (compartmentslow != NULL) - memcpy(mac_biba->mb_rangelow.mbe_compartments, - compartmentslow, - sizeof(mac_biba->mb_rangelow.mbe_compartments)); - mac_biba->mb_rangehigh.mbe_type = typehigh; - mac_biba->mb_rangehigh.mbe_grade = gradehigh; + memcpy(mb->mb_rangelow.mbe_compartments, compartmentslow, + sizeof(mb->mb_rangelow.mbe_compartments)); + mb->mb_rangehigh.mbe_type = typehigh; + mb->mb_rangehigh.mbe_grade = gradehigh; if (compartmentshigh != NULL) - memcpy(mac_biba->mb_rangehigh.mbe_compartments, - compartmentshigh, - sizeof(mac_biba->mb_rangehigh.mbe_compartments)); - mac_biba->mb_flags |= MAC_BIBA_FLAG_RANGE; + memcpy(mb->mb_rangehigh.mbe_compartments, compartmentshigh, + sizeof(mb->mb_rangehigh.mbe_compartments)); + mb->mb_flags |= MAC_BIBA_FLAG_RANGE; } static void -mac_biba_set_effective(struct mac_biba *mac_biba, u_short type, u_short grade, +biba_set_effective(struct mac_biba *mb, u_short type, u_short grade, u_char *compartments) { - mac_biba->mb_effective.mbe_type = type; - mac_biba->mb_effective.mbe_grade = grade; + mb->mb_effective.mbe_type = type; + mb->mb_effective.mbe_grade = grade; if (compartments != NULL) - memcpy(mac_biba->mb_effective.mbe_compartments, compartments, - sizeof(mac_biba->mb_effective.mbe_compartments)); - mac_biba->mb_flags |= MAC_BIBA_FLAG_EFFECTIVE; + memcpy(mb->mb_effective.mbe_compartments, compartments, + sizeof(mb->mb_effective.mbe_compartments)); + mb->mb_flags |= MAC_BIBA_FLAG_EFFECTIVE; } static void -mac_biba_copy_range(struct mac_biba *labelfrom, struct mac_biba *labelto) +biba_copy_range(struct mac_biba *labelfrom, struct mac_biba *labelto) { KASSERT((labelfrom->mb_flags & MAC_BIBA_FLAG_RANGE) != 0, - ("mac_biba_copy_range: labelfrom not range")); + ("biba_copy_range: labelfrom not range")); labelto->mb_rangelow = labelfrom->mb_rangelow; labelto->mb_rangehigh = labelfrom->mb_rangehigh; @@ -478,31 +474,31 @@ mac_biba_copy_range(struct mac_biba *labelfrom, struct mac_biba *labelto) } static void -mac_biba_copy_effective(struct mac_biba *labelfrom, struct mac_biba *labelto) +biba_copy_effective(struct mac_biba *labelfrom, struct mac_biba *labelto) { KASSERT((labelfrom->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) != 0, - ("mac_biba_copy_effective: labelfrom not effective")); + ("biba_copy_effective: labelfrom not effective")); labelto->mb_effective = labelfrom->mb_effective; labelto->mb_flags |= MAC_BIBA_FLAG_EFFECTIVE; } static void -mac_biba_copy(struct mac_biba *source, struct mac_biba *dest) +biba_copy(struct mac_biba *source, struct mac_biba *dest) { if (source->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); if (source->mb_flags & MAC_BIBA_FLAG_RANGE) - mac_biba_copy_range(source, dest); + biba_copy_range(source, dest); } /* * Policy module operations. */ static void -mac_biba_init(struct mac_policy_conf *conf) +biba_init(struct mac_policy_conf *conf) { zone_biba = uma_zcreate("mac_biba", sizeof(struct mac_biba), NULL, @@ -513,14 +509,14 @@ mac_biba_init(struct mac_policy_conf *conf) * Label operations. */ static void -mac_biba_init_label(struct label *label) +biba_init_label(struct label *label) { SLOT_SET(label, biba_alloc(M_WAITOK)); } static int -mac_biba_init_label_waitcheck(struct label *label, int flag) +biba_init_label_waitcheck(struct label *label, int flag) { SLOT_SET(label, biba_alloc(flag)); @@ -531,7 +527,7 @@ mac_biba_init_label_waitcheck(struct label *label, int flag) } static void -mac_biba_destroy_label(struct label *label) +biba_destroy_label(struct label *label) { biba_free(SLOT(label)); @@ -539,12 +535,12 @@ mac_biba_destroy_label(struct label *label) } /* - * mac_biba_element_to_string() accepts an sbuf and Biba element. It - * converts the Biba element to a string and stores the result in the - * sbuf; if there isn't space in the sbuf, -1 is returned. + * biba_element_to_string() accepts an sbuf and Biba element. It converts + * the Biba element to a string and stores the result in the sbuf; if there + * isn't space in the sbuf, -1 is returned. */ static int -mac_biba_element_to_string(struct sbuf *sb, struct mac_biba_element *element) +biba_element_to_string(struct sbuf *sb, struct mac_biba_element *element) { int i, first; @@ -580,41 +576,38 @@ mac_biba_element_to_string(struct sbuf *sb, struct mac_biba_element *element) return (0); default: - panic("mac_biba_element_to_string: invalid type (%d)", + panic("biba_element_to_string: invalid type (%d)", element->mbe_type); } } /* - * mac_biba_to_string() converts a Biba label to a string, and places - * the results in the passed sbuf. It returns 0 on success, or EINVAL - * if there isn't room in the sbuf. Note: the sbuf will be modified - * even in a failure case, so the caller may need to revert the sbuf - * by restoring the offset if that's undesired. + * biba_to_string() converts a Biba label to a string, and places the results + * in the passed sbuf. It returns 0 on success, or EINVAL if there isn't + * room in the sbuf. Note: the sbuf will be modified even in a failure case, + * so the caller may need to revert the sbuf by restoring the offset if + * that's undesired. */ static int -mac_biba_to_string(struct sbuf *sb, struct mac_biba *mac_biba) +biba_to_string(struct sbuf *sb, struct mac_biba *mb) { - if (mac_biba->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) { - if (mac_biba_element_to_string(sb, &mac_biba->mb_effective) - == -1) + if (mb->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) { + if (biba_element_to_string(sb, &mb->mb_effective) == -1) return (EINVAL); } - if (mac_biba->mb_flags & MAC_BIBA_FLAG_RANGE) { + if (mb->mb_flags & MAC_BIBA_FLAG_RANGE) { if (sbuf_putc(sb, '(') == -1) return (EINVAL); - if (mac_biba_element_to_string(sb, &mac_biba->mb_rangelow) - == -1) + if (biba_element_to_string(sb, &mb->mb_rangelow) == -1) return (EINVAL); if (sbuf_putc(sb, '-') == -1) return (EINVAL); - if (mac_biba_element_to_string(sb, &mac_biba->mb_rangehigh) - == -1) + if (biba_element_to_string(sb, &mb->mb_rangehigh) == -1) return (EINVAL); if (sbuf_putc(sb, ')') == -1) @@ -625,22 +618,22 @@ mac_biba_to_string(struct sbuf *sb, struct mac_biba *mac_biba) } static int -mac_biba_externalize_label(struct label *label, char *element_name, +biba_externalize_label(struct label *label, char *element_name, struct sbuf *sb, int *claimed) { - struct mac_biba *mac_biba; + struct mac_biba *mb; if (strcmp(MAC_BIBA_LABEL_NAME, element_name) != 0) return (0); (*claimed)++; - mac_biba = SLOT(label); - return (mac_biba_to_string(sb, mac_biba)); + mb = SLOT(label); + return (biba_to_string(sb, mb)); } static int -mac_biba_parse_element(struct mac_biba_element *element, char *string) +biba_parse_element(struct mac_biba_element *element, char *string) { char *compartment, *end, *grade; int value; @@ -699,7 +692,7 @@ mac_biba_parse_element(struct mac_biba_element *element, char *string) * calling if that's a problem. */ static int -mac_biba_parse(struct mac_biba *mac_biba, char *string) +biba_parse(struct mac_biba *mb, char *string) { char *rangehigh, *rangelow, *effective; int error; @@ -724,29 +717,27 @@ mac_biba_parse(struct mac_biba *mac_biba, char *string) KASSERT((rangelow != NULL && rangehigh != NULL) || (rangelow == NULL && rangehigh == NULL), - ("mac_biba_parse: range mismatch")); + ("biba_parse: range mismatch")); - bzero(mac_biba, sizeof(*mac_biba)); + bzero(mb, sizeof(*mb)); if (effective != NULL) { - error = mac_biba_parse_element(&mac_biba->mb_effective, effective); + error = biba_parse_element(&mb->mb_effective, effective); if (error) return (error); - mac_biba->mb_flags |= MAC_BIBA_FLAG_EFFECTIVE; + mb->mb_flags |= MAC_BIBA_FLAG_EFFECTIVE; } if (rangelow != NULL) { - error = mac_biba_parse_element(&mac_biba->mb_rangelow, - rangelow); + error = biba_parse_element(&mb->mb_rangelow, rangelow); if (error) return (error); - error = mac_biba_parse_element(&mac_biba->mb_rangehigh, - rangehigh); + error = biba_parse_element(&mb->mb_rangehigh, rangehigh); if (error) return (error); - mac_biba->mb_flags |= MAC_BIBA_FLAG_RANGE; + mb->mb_flags |= MAC_BIBA_FLAG_RANGE; } - error = mac_biba_valid(mac_biba); + error = biba_valid(mb); if (error) return (error); @@ -754,10 +745,10 @@ mac_biba_parse(struct mac_biba *mac_biba, char *string) } static int -mac_biba_internalize_label(struct label *label, char *element_name, +biba_internalize_label(struct label *label, char *element_name, char *element_data, int *claimed) { - struct mac_biba *mac_biba, mac_biba_temp; + struct mac_biba *mb, mb_temp; int error; if (strcmp(MAC_BIBA_LABEL_NAME, element_name) != 0) @@ -765,35 +756,35 @@ mac_biba_internalize_label(struct label *label, char *element_name, (*claimed)++; - error = mac_biba_parse(&mac_biba_temp, element_data); + error = biba_parse(&mb_temp, element_data); if (error) return (error); - mac_biba = SLOT(label); - *mac_biba = mac_biba_temp; + mb = SLOT(label); + *mb = mb_temp; return (0); } static void -mac_biba_copy_label(struct label *src, struct label *dest) +biba_copy_label(struct label *src, struct label *dest) { *SLOT(dest) = *SLOT(src); } /* - * Labeling event operations: file system objects, and things that look - * a lot like file system objects. + * Labeling event operations: file system objects, and things that look a lot + * like file system objects. */ static void -mac_biba_devfs_create_device(struct ucred *cred, struct mount *mp, +biba_devfs_create_device(struct ucred *cred, struct mount *mp, struct cdev *dev, struct devfs_dirent *de, struct label *delabel) { - struct mac_biba *mac_biba; + struct mac_biba *mb; int biba_type; - mac_biba = SLOT(delabel); + mb = SLOT(delabel); if (strcmp(dev->si_name, "null") == 0 || strcmp(dev->si_name, "zero") == 0 || strcmp(dev->si_name, "random") == 0 || @@ -805,21 +796,22 @@ mac_biba_devfs_create_device(struct ucred *cred, struct mount *mp, biba_type = MAC_BIBA_TYPE_EQUAL; else biba_type = MAC_BIBA_TYPE_HIGH; - mac_biba_set_effective(mac_biba, biba_type, 0, NULL); + biba_set_effective(mb, biba_type, 0, NULL); } static void -mac_biba_devfs_create_directory(struct mount *mp, char *dirname, - int dirnamelen, struct devfs_dirent *de, struct label *delabel) +biba_devfs_create_directory(struct mount *mp, char *dirname, int dirnamelen, + struct devfs_dirent *de, struct label *delabel) { - struct mac_biba *mac_biba; + struct mac_biba *mb; + + mb = SLOT(delabel); - mac_biba = SLOT(delabel); - mac_biba_set_effective(mac_biba, MAC_BIBA_TYPE_HIGH, 0, NULL); + biba_set_effective(mb, MAC_BIBA_TYPE_HIGH, 0, NULL); } static void -mac_biba_devfs_create_symlink(struct ucred *cred, struct mount *mp, +biba_devfs_create_symlink(struct ucred *cred, struct mount *mp, struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de, struct label *delabel) { @@ -828,22 +820,23 @@ mac_biba_devfs_create_symlink(struct ucred *cred, struct mount *mp, source = SLOT(cred->cr_label); dest = SLOT(delabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_mount_create(struct ucred *cred, struct mount *mp, +biba_mount_create(struct ucred *cred, struct mount *mp, struct label *mplabel) { struct mac_biba *source, *dest; source = SLOT(cred->cr_label); dest = SLOT(mplabel); - mac_biba_copy_effective(source, dest); + + biba_copy_effective(source, dest); } static void -mac_biba_vnode_relabel(struct ucred *cred, struct vnode *vp, +biba_vnode_relabel(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *newlabel) { struct mac_biba *source, *dest; @@ -851,11 +844,11 @@ mac_biba_vnode_relabel(struct ucred *cred, struct vnode *vp, source = SLOT(newlabel); dest = SLOT(vplabel); - mac_biba_copy(source, dest); + biba_copy(source, dest); } static void -mac_biba_devfs_update(struct mount *mp, struct devfs_dirent *de, +biba_devfs_update(struct mount *mp, struct devfs_dirent *de, struct label *delabel, struct vnode *vp, struct label *vplabel) { struct mac_biba *source, *dest; @@ -863,11 +856,11 @@ mac_biba_devfs_update(struct mount *mp, struct devfs_dirent *de, source = SLOT(vplabel); dest = SLOT(delabel); - mac_biba_copy(source, dest); + biba_copy(source, dest); } static void -mac_biba_devfs_vnode_associate(struct mount *mp, struct label *mntlabel, +biba_devfs_vnode_associate(struct mount *mp, struct label *mntlabel, struct devfs_dirent *de, struct label *delabel, struct vnode *vp, struct label *vplabel) { @@ -876,103 +869,104 @@ mac_biba_devfs_vnode_associate(struct mount *mp, struct label *mntlabel, source = SLOT(delabel); dest = SLOT(vplabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static int -mac_biba_vnode_associate_extattr(struct mount *mp, struct label *mplabel, +biba_vnode_associate_extattr(struct mount *mp, struct label *mplabel, struct vnode *vp, struct label *vplabel) { - struct mac_biba temp, *source, *dest; + struct mac_biba mb_temp, *source, *dest; int buflen, error; source = SLOT(mplabel); dest = SLOT(vplabel); - buflen = sizeof(temp); - bzero(&temp, buflen); + buflen = sizeof(mb_temp); + bzero(&mb_temp, buflen); error = vn_extattr_get(vp, IO_NODELOCKED, MAC_BIBA_EXTATTR_NAMESPACE, - MAC_BIBA_EXTATTR_NAME, &buflen, (char *) &temp, curthread); + MAC_BIBA_EXTATTR_NAME, &buflen, (char *) &mb_temp, curthread); if (error == ENOATTR || error == EOPNOTSUPP) { /* Fall back to the mntlabel. */ - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); return (0); } else if (error) return (error); - if (buflen != sizeof(temp)) { - printf("mac_biba_vnode_associate_extattr: bad size %d\n", + if (buflen != sizeof(mb_temp)) { + printf("biba_vnode_associate_extattr: bad size %d\n", buflen); return (EPERM); } - if (mac_biba_valid(&temp) != 0) { - printf("mac_biba_vnode_associate_extattr: invalid\n"); + if (biba_valid(&mb_temp) != 0) { + printf("biba_vnode_associate_extattr: invalid\n"); return (EPERM); } - if ((temp.mb_flags & MAC_BIBA_FLAGS_BOTH) != MAC_BIBA_FLAG_EFFECTIVE) { - printf("mac_biba_vnode_associate_extattr: not effective\n"); + if ((mb_temp.mb_flags & MAC_BIBA_FLAGS_BOTH) != + MAC_BIBA_FLAG_EFFECTIVE) { + printf("biba_vnode_associate_extattr: not effective\n"); return (EPERM); } - mac_biba_copy_effective(&temp, dest); + biba_copy_effective(&mb_temp, dest); return (0); } static void -mac_biba_vnode_associate_singlelabel(struct mount *mp, - struct label *mplabel, struct vnode *vp, struct label *vplabel) +biba_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, + struct vnode *vp, struct label *vplabel) { struct mac_biba *source, *dest; source = SLOT(mplabel); dest = SLOT(vplabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static int -mac_biba_vnode_create_extattr(struct ucred *cred, struct mount *mp, +biba_vnode_create_extattr(struct ucred *cred, struct mount *mp, struct label *mplabel, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { - struct mac_biba *source, *dest, temp; + struct mac_biba *source, *dest, mb_temp; size_t buflen; int error; - buflen = sizeof(temp); - bzero(&temp, buflen); + buflen = sizeof(mb_temp); + bzero(&mb_temp, buflen); source = SLOT(cred->cr_label); dest = SLOT(vplabel); - mac_biba_copy_effective(source, &temp); + biba_copy_effective(source, &mb_temp); error = vn_extattr_set(vp, IO_NODELOCKED, MAC_BIBA_EXTATTR_NAMESPACE, - MAC_BIBA_EXTATTR_NAME, buflen, (char *) &temp, curthread); + MAC_BIBA_EXTATTR_NAME, buflen, (char *) &mb_temp, curthread); if (error == 0) - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); return (error); } static int -mac_biba_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, +biba_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *intlabel) { - struct mac_biba *source, temp; + struct mac_biba *source, mb_temp; size_t buflen; int error; - buflen = sizeof(temp); - bzero(&temp, buflen); + buflen = sizeof(mb_temp); + bzero(&mb_temp, buflen); source = SLOT(intlabel); if ((source->mb_flags & MAC_BIBA_FLAG_EFFECTIVE) == 0) return (0); - mac_biba_copy_effective(source, &temp); + biba_copy_effective(source, &mb_temp); error = vn_extattr_set(vp, IO_NODELOCKED, MAC_BIBA_EXTATTR_NAMESPACE, - MAC_BIBA_EXTATTR_NAME, buflen, (char *) &temp, curthread); + MAC_BIBA_EXTATTR_NAME, buflen, (char *) &mb_temp, curthread); return (error); } @@ -980,7 +974,7 @@ mac_biba_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, * Labeling event operations: IPC object. */ static void -mac_biba_inpcb_create(struct socket *so, struct label *solabel, +biba_inpcb_create(struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel) { struct mac_biba *source, *dest; @@ -988,11 +982,11 @@ mac_biba_inpcb_create(struct socket *so, struct label *solabel, source = SLOT(solabel); dest = SLOT(inplabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_socket_create_mbuf(struct socket *so, struct label *solabel, +biba_socket_create_mbuf(struct socket *so, struct label *solabel, struct mbuf *m, struct label *mlabel) { struct mac_biba *source, *dest; @@ -1000,11 +994,11 @@ mac_biba_socket_create_mbuf(struct socket *so, struct label *solabel, source = SLOT(solabel); dest = SLOT(mlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_socket_create(struct ucred *cred, struct socket *so, +biba_socket_create(struct ucred *cred, struct socket *so, struct label *solabel) { struct mac_biba *source, *dest; @@ -1012,11 +1006,11 @@ mac_biba_socket_create(struct ucred *cred, struct socket *so, source = SLOT(cred->cr_label); dest = SLOT(solabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_pipe_create(struct ucred *cred, struct pipepair *pp, +biba_pipe_create(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_biba *source, *dest; @@ -1024,11 +1018,11 @@ mac_biba_pipe_create(struct ucred *cred, struct pipepair *pp, source = SLOT(cred->cr_label); dest = SLOT(pplabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_posixsem_create(struct ucred *cred, struct ksem *ks, +biba_posixsem_create(struct ucred *cred, struct ksem *ks, struct label *kslabel) { struct mac_biba *source, *dest; @@ -1036,11 +1030,11 @@ mac_biba_posixsem_create(struct ucred *cred, struct ksem *ks, source = SLOT(cred->cr_label); dest = SLOT(kslabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_socket_newconn(struct socket *oldso, struct label *oldsolabel, +biba_socket_newconn(struct socket *oldso, struct label *oldsolabel, struct socket *newso, struct label *newsolabel) { struct mac_biba *source, *dest; @@ -1048,11 +1042,11 @@ mac_biba_socket_newconn(struct socket *oldso, struct label *oldsolabel, source = SLOT(oldsolabel); dest = SLOT(newsolabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_socket_relabel(struct ucred *cred, struct socket *so, +biba_socket_relabel(struct ucred *cred, struct socket *so, struct label *solabel, struct label *newlabel) { struct mac_biba *source, *dest; @@ -1060,11 +1054,11 @@ mac_biba_socket_relabel(struct ucred *cred, struct socket *so, source = SLOT(newlabel); dest = SLOT(solabel); - mac_biba_copy(source, dest); + biba_copy(source, dest); } static void -mac_biba_pipe_relabel(struct ucred *cred, struct pipepair *pp, +biba_pipe_relabel(struct ucred *cred, struct pipepair *pp, struct label *pplabel, struct label *newlabel) { struct mac_biba *source, *dest; @@ -1072,11 +1066,11 @@ mac_biba_pipe_relabel(struct ucred *cred, struct pipepair *pp, source = SLOT(newlabel); dest = SLOT(pplabel); - mac_biba_copy(source, dest); + biba_copy(source, dest); } static void -mac_biba_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, +biba_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, struct socket *so, struct label *sopeerlabel) { struct mac_biba *source, *dest; @@ -1084,14 +1078,14 @@ mac_biba_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(sopeerlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } /* * Labeling event operations: System V IPC objects. */ static void -mac_biba_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, +biba_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqlabel, struct msg *msgptr, struct label *msglabel) { struct mac_biba *source, *dest; @@ -1100,23 +1094,23 @@ mac_biba_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, source = SLOT(cred->cr_label); dest = SLOT(msglabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_sysvmsq_create(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqlabel) +biba_sysvmsq_create(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqlabel) { struct mac_biba *source, *dest; source = SLOT(cred->cr_label); dest = SLOT(msqlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, +biba_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, struct label *semalabel) { struct mac_biba *source, *dest; @@ -1124,11 +1118,11 @@ mac_biba_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, source = SLOT(cred->cr_label); dest = SLOT(semalabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, +biba_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, struct label *shmlabel) { struct mac_biba *source, *dest; @@ -1136,14 +1130,14 @@ mac_biba_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, source = SLOT(cred->cr_label); dest = SLOT(shmlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } /* * Labeling event operations: network objects. */ static void -mac_biba_socketpeer_set_from_socket(struct socket *oldso, +biba_socketpeer_set_from_socket(struct socket *oldso, struct label *oldsolabel, struct socket *newso, struct label *newsopeerlabel) { @@ -1152,11 +1146,11 @@ mac_biba_socketpeer_set_from_socket(struct socket *oldso, source = SLOT(oldsolabel); dest = SLOT(newsopeerlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_bpfdesc_create(struct ucred *cred, struct bpf_d *d, +biba_bpfdesc_create(struct ucred *cred, struct bpf_d *d, struct label *dlabel) { struct mac_biba *source, *dest; @@ -1164,11 +1158,11 @@ mac_biba_bpfdesc_create(struct ucred *cred, struct bpf_d *d, source = SLOT(cred->cr_label); dest = SLOT(dlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_ifnet_create(struct ifnet *ifp, struct label *ifplabel) +biba_ifnet_create(struct ifnet *ifp, struct label *ifplabel) { char tifname[IFNAMSIZ], *p, *q; char tiflist[sizeof(trusted_interfaces)]; @@ -1220,12 +1214,12 @@ mac_biba_ifnet_create(struct ifnet *ifp, struct label *ifplabel) } } set: - mac_biba_set_effective(dest, type, 0, NULL); - mac_biba_set_range(dest, type, 0, NULL, type, 0, NULL); + biba_set_effective(dest, type, 0, NULL); + biba_set_range(dest, type, 0, NULL, type, 0, NULL); } static void -mac_biba_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +biba_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { struct mac_biba *source, *dest; @@ -1233,12 +1227,12 @@ mac_biba_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, source = SLOT(mlabel); dest = SLOT(ipqlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, - struct mbuf *m, struct label *mlabel) +biba_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, struct mbuf *m, + struct label *mlabel) { struct mac_biba *source, *dest; @@ -1246,11 +1240,11 @@ mac_biba_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, dest = SLOT(mlabel); /* Just use the head, since we require them all to match. */ - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_netinet_fragment(struct mbuf *m, struct label *mlabel, +biba_netinet_fragment(struct mbuf *m, struct label *mlabel, struct mbuf *frag, struct label *fraglabel) { struct mac_biba *source, *dest; @@ -1258,11 +1252,11 @@ mac_biba_netinet_fragment(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(fraglabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, +biba_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { struct mac_biba *source, *dest; @@ -1270,22 +1264,22 @@ mac_biba_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, source = SLOT(inplabel); dest = SLOT(mlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, +biba_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_biba *dest; dest = SLOT(mlabel); - mac_biba_set_effective(dest, MAC_BIBA_TYPE_EQUAL, 0, NULL); + biba_set_effective(dest, MAC_BIBA_TYPE_EQUAL, 0, NULL); } static void -mac_biba_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, +biba_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, struct mbuf *m, struct label *mlabel) { struct mac_biba *source, *dest; @@ -1293,11 +1287,11 @@ mac_biba_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, source = SLOT(dlabel); dest = SLOT(mlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, +biba_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_biba *source, *dest; @@ -1305,11 +1299,11 @@ mac_biba_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, source = SLOT(ifplabel); dest = SLOT(mlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, +biba_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, struct ifnet *ifp, struct label *ifplabel, struct mbuf *mnew, struct label *mnewlabel) { @@ -1318,11 +1312,11 @@ mac_biba_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(mnewlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, +biba_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, struct mbuf *newm, struct label *mnewlabel) { struct mac_biba *source, *dest; @@ -1330,11 +1324,11 @@ mac_biba_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(mnewlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static int -mac_biba_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +biba_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { struct mac_biba *a, *b; @@ -1342,11 +1336,11 @@ mac_biba_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, a = SLOT(ipqlabel); b = SLOT(mlabel); - return (mac_biba_equal_effective(a, b)); + return (biba_equal_effective(a, b)); } static void -mac_biba_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, +biba_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, struct label *ifplabel, struct label *newlabel) { struct mac_biba *source, *dest; @@ -1354,11 +1348,11 @@ mac_biba_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, source = SLOT(newlabel); dest = SLOT(ifplabel); - mac_biba_copy(source, dest); + biba_copy(source, dest); } static void -mac_biba_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +biba_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { @@ -1366,7 +1360,7 @@ mac_biba_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, } static void -mac_biba_inpcb_sosetlabel(struct socket *so, struct label *solabel, +biba_inpcb_sosetlabel(struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel) { struct mac_biba *source, *dest; @@ -1374,84 +1368,84 @@ mac_biba_inpcb_sosetlabel(struct socket *so, struct label *solabel, source = SLOT(solabel); dest = SLOT(inplabel); - mac_biba_copy(source, dest); + biba_copy(source, dest); } static void -mac_biba_mbuf_create_from_firewall(struct mbuf *m, struct label *label) +biba_mbuf_create_from_firewall(struct mbuf *m, struct label *label) { struct mac_biba *dest; dest = SLOT(label); /* XXX: where is the label for the firewall really comming from? */ - mac_biba_set_effective(dest, MAC_BIBA_TYPE_EQUAL, 0, NULL); + biba_set_effective(dest, MAC_BIBA_TYPE_EQUAL, 0, NULL); } /* * Labeling event operations: processes. */ static void -mac_biba_proc_create_swapper(struct ucred *cred) +biba_proc_create_swapper(struct ucred *cred) { struct mac_biba *dest; dest = SLOT(cred->cr_label); - mac_biba_set_effective(dest, MAC_BIBA_TYPE_EQUAL, 0, NULL); - mac_biba_set_range(dest, MAC_BIBA_TYPE_LOW, 0, NULL, - MAC_BIBA_TYPE_HIGH, 0, NULL); + biba_set_effective(dest, MAC_BIBA_TYPE_EQUAL, 0, NULL); + biba_set_range(dest, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH, + 0, NULL); } static void -mac_biba_proc_create_init(struct ucred *cred) +biba_proc_create_init(struct ucred *cred) { struct mac_biba *dest; dest = SLOT(cred->cr_label); - mac_biba_set_effective(dest, MAC_BIBA_TYPE_HIGH, 0, NULL); - mac_biba_set_range(dest, MAC_BIBA_TYPE_LOW, 0, NULL, - MAC_BIBA_TYPE_HIGH, 0, NULL); + biba_set_effective(dest, MAC_BIBA_TYPE_HIGH, 0, NULL); + biba_set_range(dest, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH, + 0, NULL); } static void -mac_biba_cred_relabel(struct ucred *cred, struct label *newlabel) +biba_cred_relabel(struct ucred *cred, struct label *newlabel) { struct mac_biba *source, *dest; source = SLOT(newlabel); dest = SLOT(cred->cr_label); - mac_biba_copy(source, dest); + biba_copy(source, dest); } /* * Label cleanup/flush operations */ static void -mac_biba_sysvmsg_cleanup(struct label *msglabel) +biba_sysvmsg_cleanup(struct label *msglabel) { bzero(SLOT(msglabel), sizeof(struct mac_biba)); } static void -mac_biba_sysvmsq_cleanup(struct label *msqlabel) +biba_sysvmsq_cleanup(struct label *msqlabel) { bzero(SLOT(msqlabel), sizeof(struct mac_biba)); } static void -mac_biba_sysvsem_cleanup(struct label *semalabel) +biba_sysvsem_cleanup(struct label *semalabel) { bzero(SLOT(semalabel), sizeof(struct mac_biba)); } static void -mac_biba_sysvshm_cleanup(struct label *shmlabel) +biba_sysvshm_cleanup(struct label *shmlabel) { bzero(SLOT(shmlabel), sizeof(struct mac_biba)); } @@ -1460,24 +1454,24 @@ mac_biba_sysvshm_cleanup(struct label *shmlabel) * Access control checks. */ static int -mac_biba_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, +biba_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, struct ifnet *ifp, struct label *ifplabel) { struct mac_biba *a, *b; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); a = SLOT(dlabel); b = SLOT(ifplabel); - if (mac_biba_equal_effective(a, b)) + if (biba_equal_effective(a, b)) return (0); return (EACCES); } static int -mac_biba_cred_check_relabel(struct ucred *cred, struct label *newlabel) +biba_cred_check_relabel(struct ucred *cred, struct label *newlabel) { struct mac_biba *subj, *new; int error; @@ -1504,7 +1498,7 @@ mac_biba_cred_check_relabel(struct ucred *cred, struct label *newlabel) */ if ((new->mb_flags & MAC_BIBA_FLAGS_BOTH) == MAC_BIBA_FLAGS_BOTH && - !mac_biba_effective_in_range(new, new)) + !biba_effective_in_range(new, new)) return (EINVAL); /* @@ -1512,24 +1506,23 @@ mac_biba_cred_check_relabel(struct ucred *cred, struct label *newlabel) * new effective label must be in the current range. */ if (new->mb_flags & MAC_BIBA_FLAG_EFFECTIVE && - !mac_biba_effective_in_range(new, subj)) + !biba_effective_in_range(new, subj)) return (EPERM); /* - * To change the Biba range on a credential, the new - * range label must be in the current range. + * To change the Biba range on a credential, the new range + * label must be in the current range. */ if (new->mb_flags & MAC_BIBA_FLAG_RANGE && - !mac_biba_range_in_range(new, subj)) + !biba_range_in_range(new, subj)) return (EPERM); /* - * To have EQUAL in any component of the new credential - * Biba label, the subject must already have EQUAL in - * their label. + * To have EQUAL in any component of the new credential Biba + * label, the subject must already have EQUAL in their label. */ - if (mac_biba_contains_equal(new)) { - error = mac_biba_subject_privileged(subj); + if (biba_contains_equal(new)) { + error = biba_subject_privileged(subj); if (error) return (error); } @@ -1539,25 +1532,25 @@ mac_biba_cred_check_relabel(struct ucred *cred, struct label *newlabel) } static int -mac_biba_cred_check_visible(struct ucred *u1, struct ucred *u2) +biba_cred_check_visible(struct ucred *u1, struct ucred *u2) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(u1->cr_label); obj = SLOT(u2->cr_label); /* XXX: range */ - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (ESRCH); return (0); } static int -mac_biba_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, +biba_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, struct label *ifplabel, struct label *newlabel) { struct mac_biba *subj, *new; @@ -1567,8 +1560,8 @@ mac_biba_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, new = SLOT(newlabel); /* - * If there is a Biba label update for the interface, it may - * be an update of the effective, range, or both. + * If there is a Biba label update for the interface, it may be an + * update of the effective, range, or both. */ error = biba_atmostflags(new, MAC_BIBA_FLAGS_BOTH); if (error) @@ -1577,7 +1570,7 @@ mac_biba_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, /* * Relabling network interfaces requires Biba privilege. */ - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); @@ -1585,133 +1578,132 @@ mac_biba_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, } static int -mac_biba_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, +biba_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_biba *p, *i; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); p = SLOT(mlabel); i = SLOT(ifplabel); - return (mac_biba_effective_in_range(p, i) ? 0 : EACCES); + return (biba_effective_in_range(p, i) ? 0 : EACCES); } static int -mac_biba_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, +biba_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { struct mac_biba *p, *i; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); p = SLOT(mlabel); i = SLOT(inplabel); - return (mac_biba_equal_effective(p, i) ? 0 : EACCES); + return (biba_equal_effective(p, i) ? 0 : EACCES); } static int -mac_biba_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, +biba_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, struct label *msglabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msglabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, +biba_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, struct label *msglabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msglabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_sysvmsq_check_msqget(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqklabel) +biba_sysvmsq_check_msqget(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqklabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msqklabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_sysvmsq_check_msqsnd(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqklabel) +biba_sysvmsq_check_msqsnd(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqklabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msqklabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_sysvmsq_check_msqrcv(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqklabel) +biba_sysvmsq_check_msqrcv(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqklabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msqklabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } - static int -mac_biba_sysvmsq_check_msqctl(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqklabel, int cmd) +biba_sysvmsq_check_msqctl(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqklabel, int cmd) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); @@ -1720,12 +1712,12 @@ mac_biba_sysvmsq_check_msqctl(struct ucred *cred, switch(cmd) { case IPC_RMID: case IPC_SET: - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); break; case IPC_STAT: - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); break; @@ -1737,12 +1729,12 @@ mac_biba_sysvmsq_check_msqctl(struct ucred *cred, } static int -mac_biba_sysvsem_check_semctl(struct ucred *cred, - struct semid_kernel *semakptr, struct label *semaklabel, int cmd) +biba_sysvsem_check_semctl(struct ucred *cred, struct semid_kernel *semakptr, + struct label *semaklabel, int cmd) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); @@ -1753,7 +1745,7 @@ mac_biba_sysvsem_check_semctl(struct ucred *cred, case IPC_SET: case SETVAL: case SETALL: - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); break; @@ -1763,7 +1755,7 @@ mac_biba_sysvsem_check_semctl(struct ucred *cred, case GETNCNT: case GETZCNT: case GETALL: - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); break; @@ -1775,64 +1767,62 @@ mac_biba_sysvsem_check_semctl(struct ucred *cred, } static int -mac_biba_sysvsem_check_semget(struct ucred *cred, - struct semid_kernel *semakptr, struct label *semaklabel) +biba_sysvsem_check_semget(struct ucred *cred, struct semid_kernel *semakptr, + struct label *semaklabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(semaklabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } - static int -mac_biba_sysvsem_check_semop(struct ucred *cred, - struct semid_kernel *semakptr, struct label *semaklabel, - size_t accesstype) +biba_sysvsem_check_semop(struct ucred *cred, struct semid_kernel *semakptr, + struct label *semaklabel, size_t accesstype) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(semaklabel); if (accesstype & SEM_R) - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); if (accesstype & SEM_A) - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_sysvshm_check_shmat(struct ucred *cred, - struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) +biba_sysvshm_check_shmat(struct ucred *cred, struct shmid_kernel *shmsegptr, + struct label *shmseglabel, int shmflg) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(shmseglabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); if ((shmflg & SHM_RDONLY) == 0) { - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); } @@ -1840,12 +1830,12 @@ mac_biba_sysvshm_check_shmat(struct ucred *cred, } static int -mac_biba_sysvshm_check_shmctl(struct ucred *cred, - struct shmid_kernel *shmsegptr, struct label *shmseglabel, int cmd) +biba_sysvshm_check_shmctl(struct ucred *cred, struct shmid_kernel *shmsegptr, + struct label *shmseglabel, int cmd) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); @@ -1854,13 +1844,13 @@ mac_biba_sysvshm_check_shmctl(struct ucred *cred, switch(cmd) { case IPC_RMID: case IPC_SET: - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); break; case IPC_STAT: case SHM_STAT: - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); break; @@ -1872,70 +1862,70 @@ mac_biba_sysvshm_check_shmctl(struct ucred *cred, } static int -mac_biba_sysvshm_check_shmget(struct ucred *cred, - struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) +biba_sysvshm_check_shmget(struct ucred *cred, struct shmid_kernel *shmsegptr, + struct label *shmseglabel, int shmflg) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(shmseglabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_kld_check_load(struct ucred *cred, struct vnode *vp, +biba_kld_check_load(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; int error; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); obj = SLOT(vplabel); - if (!mac_biba_high_effective(obj)) + if (!biba_high_effective(obj)) return (EACCES); return (0); } static int -mac_biba_mount_check_stat(struct ucred *cred, struct mount *mp, +biba_mount_check_stat(struct ucred *cred, struct mount *mp, struct label *mplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(mplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, +biba_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, struct label *pplabel, unsigned long cmd, void /* caddr_t */ *data) { - if(!mac_biba_enabled) + if(!biba_enabled) return (0); /* XXX: This will be implemented soon... */ @@ -1944,43 +1934,43 @@ mac_biba_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, } static int -mac_biba_pipe_check_poll(struct ucred *cred, struct pipepair *pp, +biba_pipe_check_poll(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_pipe_check_read(struct ucred *cred, struct pipepair *pp, +biba_pipe_check_read(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, +biba_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, struct label *pplabel, struct label *newlabel) { struct mac_biba *subj, *obj, *new; @@ -1991,8 +1981,8 @@ mac_biba_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, obj = SLOT(pplabel); /* - * If there is a Biba label update for a pipe, it must be a - * effective update. + * If there is a Biba label update for a pipe, it must be a effective + * update. */ error = biba_atmostflags(new, MAC_BIBA_FLAG_EFFECTIVE); if (error) @@ -2002,7 +1992,7 @@ mac_biba_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, * To perform a relabel of a pipe (Biba label or not), Biba must * authorize the relabel. */ - if (!mac_biba_effective_in_range(obj, subj)) + if (!biba_effective_in_range(obj, subj)) return (EPERM); /* @@ -2013,15 +2003,15 @@ mac_biba_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, * To change the Biba label on a pipe, the new pipe label * must be in the subject range. */ - if (!mac_biba_effective_in_range(new, subj)) + if (!biba_effective_in_range(new, subj)) return (EPERM); /* * To change the Biba label on a pipe to be EQUAL, the * subject must have appropriate privilege. */ - if (mac_biba_contains_equal(new)) { - error = mac_biba_subject_privileged(subj); + if (biba_contains_equal(new)) { + error = biba_subject_privileged(subj); if (error) return (error); } @@ -2031,154 +2021,154 @@ mac_biba_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, } static int -mac_biba_pipe_check_stat(struct ucred *cred, struct pipepair *pp, +biba_pipe_check_stat(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_pipe_check_write(struct ucred *cred, struct pipepair *pp, +biba_pipe_check_write(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_posixsem_check_write(struct ucred *cred, struct ksem *ks, +biba_posixsem_check_write(struct ucred *cred, struct ksem *ks, struct label *kslabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(kslabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_posixsem_check_rdonly(struct ucred *cred, struct ksem *ks, +biba_posixsem_check_rdonly(struct ucred *cred, struct ksem *ks, struct label *kslabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(kslabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_proc_check_debug(struct ucred *cred, struct proc *p) +biba_proc_check_debug(struct ucred *cred, struct proc *p) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (ESRCH); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_proc_check_sched(struct ucred *cred, struct proc *p) +biba_proc_check_sched(struct ucred *cred, struct proc *p) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (ESRCH); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_proc_check_signal(struct ucred *cred, struct proc *p, int signum) +biba_proc_check_signal(struct ucred *cred, struct proc *p, int signum) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (ESRCH); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_socket_check_deliver(struct socket *so, struct label *solabel, +biba_socket_check_deliver(struct socket *so, struct label *solabel, struct mbuf *m, struct label *mlabel) { struct mac_biba *p, *s; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); p = SLOT(mlabel); s = SLOT(solabel); - return (mac_biba_equal_effective(p, s) ? 0 : EACCES); + return (biba_equal_effective(p, s) ? 0 : EACCES); } static int -mac_biba_socket_check_relabel(struct ucred *cred, struct socket *so, +biba_socket_check_relabel(struct ucred *cred, struct socket *so, struct label *solabel, struct label *newlabel) { struct mac_biba *subj, *obj, *new; @@ -2189,18 +2179,18 @@ mac_biba_socket_check_relabel(struct ucred *cred, struct socket *so, obj = SLOT(solabel); /* - * If there is a Biba label update for the socket, it may be - * an update of effective. + * If there is a Biba label update for the socket, it may be an + * update of effective. */ error = biba_atmostflags(new, MAC_BIBA_FLAG_EFFECTIVE); if (error) return (error); /* - * To relabel a socket, the old socket effective must be in the subject - * range. + * To relabel a socket, the old socket effective must be in the + * subject range. */ - if (!mac_biba_effective_in_range(obj, subj)) + if (!biba_effective_in_range(obj, subj)) return (EPERM); /* @@ -2211,15 +2201,15 @@ mac_biba_socket_check_relabel(struct ucred *cred, struct socket *so, * To relabel a socket, the new socket effective must be in * the subject range. */ - if (!mac_biba_effective_in_range(new, subj)) + if (!biba_effective_in_range(new, subj)) return (EPERM); /* * To change the Biba label on the socket to contain EQUAL, * the subject must have appropriate privilege. */ - if (mac_biba_contains_equal(new)) { - error = mac_biba_subject_privileged(subj); + if (biba_contains_equal(new)) { + error = biba_subject_privileged(subj); if (error) return (error); } @@ -2229,18 +2219,18 @@ mac_biba_socket_check_relabel(struct ucred *cred, struct socket *so, } static int -mac_biba_socket_check_visible(struct ucred *cred, struct socket *so, +biba_socket_check_visible(struct ucred *cred, struct socket *so, struct label *solabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(solabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (ENOENT); return (0); @@ -2252,12 +2242,12 @@ mac_biba_socket_check_visible(struct ucred *cred, struct socket *so, * policy as they might otherwise allow bypassing of the integrity policy. */ static int -mac_biba_priv_check(struct ucred *cred, int priv) +biba_priv_check(struct ucred *cred, int priv) { struct mac_biba *subj; int error; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); /* @@ -2428,7 +2418,7 @@ mac_biba_priv_check(struct ucred *cred, int priv) */ default: subj = SLOT(cred->cr_label); - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); } @@ -2436,18 +2426,18 @@ mac_biba_priv_check(struct ucred *cred, int priv) } static int -mac_biba_system_check_acct(struct ucred *cred, struct vnode *vp, +biba_system_check_acct(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; int error; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); @@ -2455,25 +2445,25 @@ mac_biba_system_check_acct(struct ucred *cred, struct vnode *vp, return (0); obj = SLOT(vplabel); - if (!mac_biba_high_effective(obj)) + if (!biba_high_effective(obj)) return (EACCES); return (0); } static int -mac_biba_system_check_auditctl(struct ucred *cred, struct vnode *vp, +biba_system_check_auditctl(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; int error; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); @@ -2481,24 +2471,24 @@ mac_biba_system_check_auditctl(struct ucred *cred, struct vnode *vp, return (0); obj = SLOT(vplabel); - if (!mac_biba_high_effective(obj)) + if (!biba_high_effective(obj)) return (EACCES); return (0); } static int -mac_biba_system_check_auditon(struct ucred *cred, int cmd) +biba_system_check_auditon(struct ucred *cred, int cmd) { struct mac_biba *subj; int error; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); @@ -2506,41 +2496,41 @@ mac_biba_system_check_auditon(struct ucred *cred, int cmd) } static int -mac_biba_system_check_swapon(struct ucred *cred, struct vnode *vp, +biba_system_check_swapon(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; int error; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); - if (!mac_biba_high_effective(obj)) + if (!biba_high_effective(obj)) return (EACCES); return (0); } static int -mac_biba_system_check_swapoff(struct ucred *cred, struct vnode *vp, +biba_system_check_swapoff(struct ucred *cred, struct vnode *vp, struct label *label) { struct mac_biba *subj; int error; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); @@ -2548,26 +2538,26 @@ mac_biba_system_check_swapoff(struct ucred *cred, struct vnode *vp, } static int -mac_biba_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, +biba_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req) { struct mac_biba *subj; int error; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); /* - * Treat sysctl variables without CTLFLAG_ANYBODY flag as - * biba/high, but also require privilege to change them. + * Treat sysctl variables without CTLFLAG_ANYBODY flag as biba/high, + * but also require privilege to change them. */ if (req->newptr != NULL && (oidp->oid_kind & CTLFLAG_ANYBODY) == 0) { - if (!mac_biba_subject_dominate_high(subj)) + if (!biba_subject_dominate_high(subj)) return (EACCES); - error = mac_biba_subject_privileged(subj); + error = biba_subject_privileged(subj); if (error) return (error); } @@ -2576,97 +2566,97 @@ mac_biba_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, } static int -mac_biba_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_create(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_create(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp, struct vattr *vap) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, +biba_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, +biba_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_exec(struct ucred *cred, struct vnode *vp, +biba_vnode_check_exec(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct image_params *imgp, struct label *execlabel) { @@ -2676,8 +2666,8 @@ mac_biba_vnode_check_exec(struct ucred *cred, struct vnode *vp, if (execlabel != NULL) { /* * We currently don't permit labels to be changed at - * exec-time as part of Biba, so disallow non-NULL - * Biba label elements in the execlabel. + * exec-time as part of Biba, so disallow non-NULL Biba label + * elements in the execlabel. */ exec = SLOT(execlabel); error = biba_atmostflags(exec, 0); @@ -2685,117 +2675,117 @@ mac_biba_vnode_check_exec(struct ucred *cred, struct vnode *vp, return (error); } - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_getacl(struct ucred *cred, struct vnode *vp, +biba_vnode_check_getacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, +biba_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_link(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_link(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, +biba_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_mmap(struct ucred *cred, struct vnode *vp, +biba_vnode_check_mmap(struct ucred *cred, struct vnode *vp, struct label *vplabel, int prot, int flags) { struct mac_biba *subj, *obj; @@ -2804,18 +2794,18 @@ mac_biba_vnode_check_mmap(struct ucred *cred, struct vnode *vp, * Rely on the use of open()-time protections to handle * non-revocation cases. */ - if (!mac_biba_enabled || !revocation_enabled) + if (!biba_enabled || !revocation_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); if (prot & (VM_PROT_READ | VM_PROT_EXECUTE)) { - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); } if (((prot & VM_PROT_WRITE) != 0) && ((flags & MAP_SHARED) != 0)) { - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); } @@ -2823,12 +2813,12 @@ mac_biba_vnode_check_mmap(struct ucred *cred, struct vnode *vp, } static int -mac_biba_vnode_check_open(struct ucred *cred, struct vnode *vp, +biba_vnode_check_open(struct ucred *cred, struct vnode *vp, struct label *vplabel, int acc_mode) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); @@ -2836,11 +2826,11 @@ mac_biba_vnode_check_open(struct ucred *cred, struct vnode *vp, /* XXX privilege override for admin? */ if (acc_mode & (VREAD | VEXEC | VSTAT)) { - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); } if (acc_mode & (VWRITE | VAPPEND | VADMIN)) { - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); } @@ -2848,79 +2838,79 @@ mac_biba_vnode_check_open(struct ucred *cred, struct vnode *vp, } static int -mac_biba_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, +biba_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled || !revocation_enabled) + if (!biba_enabled || !revocation_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, +biba_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled || !revocation_enabled) + if (!biba_enabled || !revocation_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_readlink(struct ucred *cred, struct vnode *vp, +biba_vnode_check_readlink(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_relabel(struct ucred *cred, struct vnode *vp, +biba_vnode_check_relabel(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *newlabel) { struct mac_biba *old, *new, *subj; @@ -2942,7 +2932,7 @@ mac_biba_vnode_check_relabel(struct ucred *cred, struct vnode *vp, * To perform a relabel of the vnode (Biba label or not), Biba must * authorize the relabel. */ - if (!mac_biba_effective_in_range(old, subj)) + if (!biba_effective_in_range(old, subj)) return (EPERM); /* @@ -2953,15 +2943,15 @@ mac_biba_vnode_check_relabel(struct ucred *cred, struct vnode *vp, * To change the Biba label on a vnode, the new vnode label * must be in the subject range. */ - if (!mac_biba_effective_in_range(new, subj)) + if (!biba_effective_in_range(new, subj)) return (EPERM); /* - * To change the Biba label on the vnode to be EQUAL, - * the subject must have appropriate privilege. + * To change the Biba label on the vnode to be EQUAL, the + * subject must have appropriate privilege. */ - if (mac_biba_contains_equal(new)) { - error = mac_biba_subject_privileged(subj); + if (biba_contains_equal(new)) { + error = biba_subject_privileged(subj); if (error) return (error); } @@ -2971,49 +2961,49 @@ mac_biba_vnode_check_relabel(struct ucred *cred, struct vnode *vp, } static int -mac_biba_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, int samedir, struct componentname *cnp) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); if (vp != NULL) { obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); } @@ -3021,55 +3011,55 @@ mac_biba_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, } static int -mac_biba_vnode_check_revoke(struct ucred *cred, struct vnode *vp, +biba_vnode_check_revoke(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_setacl(struct ucred *cred, struct vnode *vp, +biba_vnode_check_setacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type, struct acl *acl) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, +biba_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); /* XXX: protect the MAC EA in a special way? */ @@ -3078,353 +3068,353 @@ mac_biba_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, } static int -mac_biba_vnode_check_setflags(struct ucred *cred, struct vnode *vp, +biba_vnode_check_setflags(struct ucred *cred, struct vnode *vp, struct label *vplabel, u_long flags) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_setmode(struct ucred *cred, struct vnode *vp, +biba_vnode_check_setmode(struct ucred *cred, struct vnode *vp, struct label *vplabel, mode_t mode) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_setowner(struct ucred *cred, struct vnode *vp, +biba_vnode_check_setowner(struct ucred *cred, struct vnode *vp, struct label *vplabel, uid_t uid, gid_t gid) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, +biba_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct timespec atime, struct timespec mtime) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, +biba_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(obj, subj)) + if (!biba_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, +biba_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled) + if (!biba_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_biba_vnode_check_write(struct ucred *active_cred, +biba_vnode_check_write(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_biba *subj, *obj; - if (!mac_biba_enabled || !revocation_enabled) + if (!biba_enabled || !revocation_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_biba_dominate_effective(subj, obj)) + if (!biba_dominate_effective(subj, obj)) return (EACCES); return (0); } static void -mac_biba_associate_nfsd_label(struct ucred *cred) +biba_associate_nfsd_label(struct ucred *cred) { struct mac_biba *label; label = SLOT(cred->cr_label); - mac_biba_set_effective(label, MAC_BIBA_TYPE_LOW, 0, NULL); - mac_biba_set_range(label, MAC_BIBA_TYPE_LOW, 0, NULL, - MAC_BIBA_TYPE_HIGH, 0, NULL); + biba_set_effective(label, MAC_BIBA_TYPE_LOW, 0, NULL); + biba_set_range(label, MAC_BIBA_TYPE_LOW, 0, NULL, MAC_BIBA_TYPE_HIGH, + 0, NULL); } static void -mac_biba_init_syncache_from_inpcb(struct label *label, struct inpcb *inp) +biba_init_syncache_from_inpcb(struct label *label, struct inpcb *inp) { struct mac_biba *source, *dest; source = SLOT(inp->inp_label); dest = SLOT(label); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static void -mac_biba_create_mbuf_from_syncache(struct label *sc_label, struct mbuf *m, +biba_create_mbuf_from_syncache(struct label *sc_label, struct mbuf *m, struct label *mlabel) { struct mac_biba *source, *dest; source = SLOT(sc_label); dest = SLOT(mlabel); - mac_biba_copy_effective(source, dest); + biba_copy_effective(source, dest); } static struct mac_policy_ops mac_biba_ops = { - .mpo_init = mac_biba_init, - .mpo_bpfdesc_init_label = mac_biba_init_label, - .mpo_cred_init_label = mac_biba_init_label, - .mpo_devfs_init_label = mac_biba_init_label, - .mpo_ifnet_init_label = mac_biba_init_label, - .mpo_inpcb_init_label = mac_biba_init_label_waitcheck, - .mpo_init_syncache_label = mac_biba_init_label_waitcheck, - .mpo_sysvmsg_init_label = mac_biba_init_label, - .mpo_sysvmsq_init_label = mac_biba_init_label, - .mpo_sysvsem_init_label = mac_biba_init_label, - .mpo_sysvshm_init_label = mac_biba_init_label, - .mpo_ipq_init_label = mac_biba_init_label_waitcheck, - .mpo_mbuf_init_label = mac_biba_init_label_waitcheck, - .mpo_mount_init_label = mac_biba_init_label, - .mpo_pipe_init_label = mac_biba_init_label, - .mpo_posixsem_init_label = mac_biba_init_label, - .mpo_socket_init_label = mac_biba_init_label_waitcheck, - .mpo_socketpeer_init_label = mac_biba_init_label_waitcheck, - .mpo_init_syncache_from_inpcb = mac_biba_init_syncache_from_inpcb, - .mpo_vnode_init_label = mac_biba_init_label, - .mpo_bpfdesc_destroy_label = mac_biba_destroy_label, - .mpo_cred_destroy_label = mac_biba_destroy_label, - .mpo_devfs_destroy_label = mac_biba_destroy_label, - .mpo_ifnet_destroy_label = mac_biba_destroy_label, - .mpo_inpcb_destroy_label = mac_biba_destroy_label, - .mpo_destroy_syncache_label = mac_biba_destroy_label, - .mpo_sysvmsg_destroy_label = mac_biba_destroy_label, - .mpo_sysvmsq_destroy_label = mac_biba_destroy_label, - .mpo_sysvsem_destroy_label = mac_biba_destroy_label, - .mpo_sysvshm_destroy_label = mac_biba_destroy_label, - .mpo_ipq_destroy_label = mac_biba_destroy_label, - .mpo_mbuf_destroy_label = mac_biba_destroy_label, - .mpo_mount_destroy_label = mac_biba_destroy_label, - .mpo_pipe_destroy_label = mac_biba_destroy_label, - .mpo_posixsem_destroy_label = mac_biba_destroy_label, - .mpo_socket_destroy_label = mac_biba_destroy_label, - .mpo_socketpeer_destroy_label = mac_biba_destroy_label, - .mpo_vnode_destroy_label = mac_biba_destroy_label, - .mpo_cred_copy_label = mac_biba_copy_label, - .mpo_ifnet_copy_label = mac_biba_copy_label, - .mpo_mbuf_copy_label = mac_biba_copy_label, - .mpo_pipe_copy_label = mac_biba_copy_label, - .mpo_socket_copy_label = mac_biba_copy_label, - .mpo_vnode_copy_label = mac_biba_copy_label, - .mpo_cred_externalize_label = mac_biba_externalize_label, - .mpo_ifnet_externalize_label = mac_biba_externalize_label, - .mpo_pipe_externalize_label = mac_biba_externalize_label, - .mpo_socket_externalize_label = mac_biba_externalize_label, - .mpo_socketpeer_externalize_label = mac_biba_externalize_label, - .mpo_vnode_externalize_label = mac_biba_externalize_label, - .mpo_cred_internalize_label = mac_biba_internalize_label, - .mpo_ifnet_internalize_label = mac_biba_internalize_label, - .mpo_pipe_internalize_label = mac_biba_internalize_label, - .mpo_socket_internalize_label = mac_biba_internalize_label, - .mpo_vnode_internalize_label = mac_biba_internalize_label, - .mpo_devfs_create_device = mac_biba_devfs_create_device, - .mpo_devfs_create_directory = mac_biba_devfs_create_directory, - .mpo_devfs_create_symlink = mac_biba_devfs_create_symlink, - .mpo_mount_create = mac_biba_mount_create, - .mpo_vnode_relabel = mac_biba_vnode_relabel, - .mpo_devfs_update = mac_biba_devfs_update, - .mpo_devfs_vnode_associate = mac_biba_devfs_vnode_associate, - .mpo_vnode_associate_extattr = mac_biba_vnode_associate_extattr, - .mpo_vnode_associate_singlelabel = mac_biba_vnode_associate_singlelabel, - .mpo_vnode_create_extattr = mac_biba_vnode_create_extattr, - .mpo_vnode_setlabel_extattr = mac_biba_vnode_setlabel_extattr, - .mpo_socket_create_mbuf = mac_biba_socket_create_mbuf, - .mpo_create_mbuf_from_syncache = mac_biba_create_mbuf_from_syncache, - .mpo_pipe_create = mac_biba_pipe_create, - .mpo_posixsem_create = mac_biba_posixsem_create, - .mpo_socket_create = mac_biba_socket_create, - .mpo_socket_newconn = mac_biba_socket_newconn, - .mpo_pipe_relabel = mac_biba_pipe_relabel, - .mpo_socket_relabel = mac_biba_socket_relabel, - .mpo_socketpeer_set_from_mbuf = mac_biba_socketpeer_set_from_mbuf, - .mpo_socketpeer_set_from_socket = mac_biba_socketpeer_set_from_socket, - .mpo_bpfdesc_create = mac_biba_bpfdesc_create, - .mpo_ipq_reassemble = mac_biba_ipq_reassemble, - .mpo_netinet_fragment = mac_biba_netinet_fragment, - .mpo_ifnet_create = mac_biba_ifnet_create, - .mpo_inpcb_create = mac_biba_inpcb_create, - .mpo_sysvmsg_create = mac_biba_sysvmsg_create, - .mpo_sysvmsq_create = mac_biba_sysvmsq_create, - .mpo_sysvsem_create = mac_biba_sysvsem_create, - .mpo_sysvshm_create = mac_biba_sysvshm_create, - .mpo_ipq_create = mac_biba_ipq_create, - .mpo_inpcb_create_mbuf = mac_biba_inpcb_create_mbuf, - .mpo_create_mbuf_linklayer = mac_biba_create_mbuf_linklayer, - .mpo_bpfdesc_create_mbuf = mac_biba_bpfdesc_create_mbuf, - .mpo_ifnet_create_mbuf = mac_biba_ifnet_create_mbuf, - .mpo_mbuf_create_multicast_encap = mac_biba_mbuf_create_multicast_encap, - .mpo_mbuf_create_netlayer = mac_biba_mbuf_create_netlayer, - .mpo_ipq_match = mac_biba_ipq_match, - .mpo_ifnet_relabel = mac_biba_ifnet_relabel, - .mpo_ipq_update = mac_biba_ipq_update, - .mpo_inpcb_sosetlabel = mac_biba_inpcb_sosetlabel, - .mpo_proc_create_swapper = mac_biba_proc_create_swapper, - .mpo_proc_create_init = mac_biba_proc_create_init, - .mpo_cred_relabel = mac_biba_cred_relabel, - .mpo_sysvmsg_cleanup = mac_biba_sysvmsg_cleanup, - .mpo_sysvmsq_cleanup = mac_biba_sysvmsq_cleanup, - .mpo_sysvsem_cleanup = mac_biba_sysvsem_cleanup, - .mpo_sysvshm_cleanup = mac_biba_sysvshm_cleanup, - .mpo_bpfdesc_check_receive = mac_biba_bpfdesc_check_receive, - .mpo_cred_check_relabel = mac_biba_cred_check_relabel, - .mpo_cred_check_visible = mac_biba_cred_check_visible, - .mpo_ifnet_check_relabel = mac_biba_ifnet_check_relabel, - .mpo_ifnet_check_transmit = mac_biba_ifnet_check_transmit, - .mpo_inpcb_check_deliver = mac_biba_inpcb_check_deliver, - .mpo_sysvmsq_check_msgrcv = mac_biba_sysvmsq_check_msgrcv, - .mpo_sysvmsq_check_msgrmid = mac_biba_sysvmsq_check_msgrmid, - .mpo_sysvmsq_check_msqget = mac_biba_sysvmsq_check_msqget, - .mpo_sysvmsq_check_msqsnd = mac_biba_sysvmsq_check_msqsnd, - .mpo_sysvmsq_check_msqrcv = mac_biba_sysvmsq_check_msqrcv, - .mpo_sysvmsq_check_msqctl = mac_biba_sysvmsq_check_msqctl, - .mpo_sysvsem_check_semctl = mac_biba_sysvsem_check_semctl, - .mpo_sysvsem_check_semget = mac_biba_sysvsem_check_semget, - .mpo_sysvsem_check_semop = mac_biba_sysvsem_check_semop, - .mpo_sysvshm_check_shmat = mac_biba_sysvshm_check_shmat, - .mpo_sysvshm_check_shmctl = mac_biba_sysvshm_check_shmctl, - .mpo_sysvshm_check_shmget = mac_biba_sysvshm_check_shmget, - .mpo_kld_check_load = mac_biba_kld_check_load, - .mpo_mount_check_stat = mac_biba_mount_check_stat, - .mpo_pipe_check_ioctl = mac_biba_pipe_check_ioctl, - .mpo_pipe_check_poll = mac_biba_pipe_check_poll, - .mpo_pipe_check_read = mac_biba_pipe_check_read, - .mpo_pipe_check_relabel = mac_biba_pipe_check_relabel, - .mpo_pipe_check_stat = mac_biba_pipe_check_stat, - .mpo_pipe_check_write = mac_biba_pipe_check_write, - .mpo_posixsem_check_destroy = mac_biba_posixsem_check_write, - .mpo_posixsem_check_getvalue = mac_biba_posixsem_check_rdonly, - .mpo_posixsem_check_open = mac_biba_posixsem_check_write, - .mpo_posixsem_check_post = mac_biba_posixsem_check_write, - .mpo_posixsem_check_unlink = mac_biba_posixsem_check_write, - .mpo_posixsem_check_wait = mac_biba_posixsem_check_write, - .mpo_proc_check_debug = mac_biba_proc_check_debug, - .mpo_proc_check_sched = mac_biba_proc_check_sched, - .mpo_proc_check_signal = mac_biba_proc_check_signal, - .mpo_socket_check_deliver = mac_biba_socket_check_deliver, - .mpo_socket_check_relabel = mac_biba_socket_check_relabel, - .mpo_socket_check_visible = mac_biba_socket_check_visible, - .mpo_system_check_acct = mac_biba_system_check_acct, - .mpo_system_check_auditctl = mac_biba_system_check_auditctl, - .mpo_system_check_auditon = mac_biba_system_check_auditon, - .mpo_system_check_swapon = mac_biba_system_check_swapon, - .mpo_system_check_swapoff = mac_biba_system_check_swapoff, - .mpo_system_check_sysctl = mac_biba_system_check_sysctl, - .mpo_vnode_check_access = mac_biba_vnode_check_open, - .mpo_vnode_check_chdir = mac_biba_vnode_check_chdir, - .mpo_vnode_check_chroot = mac_biba_vnode_check_chroot, - .mpo_vnode_check_create = mac_biba_vnode_check_create, - .mpo_vnode_check_deleteacl = mac_biba_vnode_check_deleteacl, - .mpo_vnode_check_deleteextattr = mac_biba_vnode_check_deleteextattr, - .mpo_vnode_check_exec = mac_biba_vnode_check_exec, - .mpo_vnode_check_getacl = mac_biba_vnode_check_getacl, - .mpo_vnode_check_getextattr = mac_biba_vnode_check_getextattr, - .mpo_vnode_check_link = mac_biba_vnode_check_link, - .mpo_vnode_check_listextattr = mac_biba_vnode_check_listextattr, - .mpo_vnode_check_lookup = mac_biba_vnode_check_lookup, - .mpo_vnode_check_mmap = mac_biba_vnode_check_mmap, - .mpo_vnode_check_open = mac_biba_vnode_check_open, - .mpo_vnode_check_poll = mac_biba_vnode_check_poll, - .mpo_vnode_check_read = mac_biba_vnode_check_read, - .mpo_vnode_check_readdir = mac_biba_vnode_check_readdir, - .mpo_vnode_check_readlink = mac_biba_vnode_check_readlink, - .mpo_vnode_check_relabel = mac_biba_vnode_check_relabel, - .mpo_vnode_check_rename_from = mac_biba_vnode_check_rename_from, - .mpo_vnode_check_rename_to = mac_biba_vnode_check_rename_to, - .mpo_vnode_check_revoke = mac_biba_vnode_check_revoke, - .mpo_vnode_check_setacl = mac_biba_vnode_check_setacl, - .mpo_vnode_check_setextattr = mac_biba_vnode_check_setextattr, - .mpo_vnode_check_setflags = mac_biba_vnode_check_setflags, - .mpo_vnode_check_setmode = mac_biba_vnode_check_setmode, - .mpo_vnode_check_setowner = mac_biba_vnode_check_setowner, - .mpo_vnode_check_setutimes = mac_biba_vnode_check_setutimes, - .mpo_vnode_check_stat = mac_biba_vnode_check_stat, - .mpo_vnode_check_unlink = mac_biba_vnode_check_unlink, - .mpo_vnode_check_write = mac_biba_vnode_check_write, - .mpo_associate_nfsd_label = mac_biba_associate_nfsd_label, - .mpo_mbuf_create_from_firewall = mac_biba_mbuf_create_from_firewall, - .mpo_priv_check = mac_biba_priv_check, + .mpo_init = biba_init, + .mpo_bpfdesc_init_label = biba_init_label, + .mpo_cred_init_label = biba_init_label, + .mpo_devfs_init_label = biba_init_label, + .mpo_ifnet_init_label = biba_init_label, + .mpo_inpcb_init_label = biba_init_label_waitcheck, + .mpo_init_syncache_label = biba_init_label_waitcheck, + .mpo_sysvmsg_init_label = biba_init_label, + .mpo_sysvmsq_init_label = biba_init_label, + .mpo_sysvsem_init_label = biba_init_label, + .mpo_sysvshm_init_label = biba_init_label, + .mpo_ipq_init_label = biba_init_label_waitcheck, + .mpo_mbuf_init_label = biba_init_label_waitcheck, + .mpo_mount_init_label = biba_init_label, + .mpo_pipe_init_label = biba_init_label, + .mpo_posixsem_init_label = biba_init_label, + .mpo_socket_init_label = biba_init_label_waitcheck, + .mpo_socketpeer_init_label = biba_init_label_waitcheck, + .mpo_init_syncache_from_inpcb = biba_init_syncache_from_inpcb, + .mpo_vnode_init_label = biba_init_label, + .mpo_bpfdesc_destroy_label = biba_destroy_label, + .mpo_cred_destroy_label = biba_destroy_label, + .mpo_devfs_destroy_label = biba_destroy_label, + .mpo_ifnet_destroy_label = biba_destroy_label, + .mpo_inpcb_destroy_label = biba_destroy_label, + .mpo_destroy_syncache_label = biba_destroy_label, + .mpo_sysvmsg_destroy_label = biba_destroy_label, + .mpo_sysvmsq_destroy_label = biba_destroy_label, + .mpo_sysvsem_destroy_label = biba_destroy_label, + .mpo_sysvshm_destroy_label = biba_destroy_label, + .mpo_ipq_destroy_label = biba_destroy_label, + .mpo_mbuf_destroy_label = biba_destroy_label, + .mpo_mount_destroy_label = biba_destroy_label, + .mpo_pipe_destroy_label = biba_destroy_label, + .mpo_posixsem_destroy_label = biba_destroy_label, + .mpo_socket_destroy_label = biba_destroy_label, + .mpo_socketpeer_destroy_label = biba_destroy_label, + .mpo_vnode_destroy_label = biba_destroy_label, + .mpo_cred_copy_label = biba_copy_label, + .mpo_ifnet_copy_label = biba_copy_label, + .mpo_mbuf_copy_label = biba_copy_label, + .mpo_pipe_copy_label = biba_copy_label, + .mpo_socket_copy_label = biba_copy_label, + .mpo_vnode_copy_label = biba_copy_label, + .mpo_cred_externalize_label = biba_externalize_label, + .mpo_ifnet_externalize_label = biba_externalize_label, + .mpo_pipe_externalize_label = biba_externalize_label, + .mpo_socket_externalize_label = biba_externalize_label, + .mpo_socketpeer_externalize_label = biba_externalize_label, + .mpo_vnode_externalize_label = biba_externalize_label, + .mpo_cred_internalize_label = biba_internalize_label, + .mpo_ifnet_internalize_label = biba_internalize_label, + .mpo_pipe_internalize_label = biba_internalize_label, + .mpo_socket_internalize_label = biba_internalize_label, + .mpo_vnode_internalize_label = biba_internalize_label, + .mpo_devfs_create_device = biba_devfs_create_device, + .mpo_devfs_create_directory = biba_devfs_create_directory, + .mpo_devfs_create_symlink = biba_devfs_create_symlink, + .mpo_mount_create = biba_mount_create, + .mpo_vnode_relabel = biba_vnode_relabel, + .mpo_devfs_update = biba_devfs_update, + .mpo_devfs_vnode_associate = biba_devfs_vnode_associate, + .mpo_vnode_associate_extattr = biba_vnode_associate_extattr, + .mpo_vnode_associate_singlelabel = biba_vnode_associate_singlelabel, + .mpo_vnode_create_extattr = biba_vnode_create_extattr, + .mpo_vnode_setlabel_extattr = biba_vnode_setlabel_extattr, + .mpo_socket_create_mbuf = biba_socket_create_mbuf, + .mpo_create_mbuf_from_syncache = biba_create_mbuf_from_syncache, + .mpo_pipe_create = biba_pipe_create, + .mpo_posixsem_create = biba_posixsem_create, + .mpo_socket_create = biba_socket_create, + .mpo_socket_newconn = biba_socket_newconn, + .mpo_pipe_relabel = biba_pipe_relabel, + .mpo_socket_relabel = biba_socket_relabel, + .mpo_socketpeer_set_from_mbuf = biba_socketpeer_set_from_mbuf, + .mpo_socketpeer_set_from_socket = biba_socketpeer_set_from_socket, + .mpo_bpfdesc_create = biba_bpfdesc_create, + .mpo_ipq_reassemble = biba_ipq_reassemble, + .mpo_netinet_fragment = biba_netinet_fragment, + .mpo_ifnet_create = biba_ifnet_create, + .mpo_inpcb_create = biba_inpcb_create, + .mpo_sysvmsg_create = biba_sysvmsg_create, + .mpo_sysvmsq_create = biba_sysvmsq_create, + .mpo_sysvsem_create = biba_sysvsem_create, + .mpo_sysvshm_create = biba_sysvshm_create, + .mpo_ipq_create = biba_ipq_create, + .mpo_inpcb_create_mbuf = biba_inpcb_create_mbuf, + .mpo_create_mbuf_linklayer = biba_create_mbuf_linklayer, + .mpo_bpfdesc_create_mbuf = biba_bpfdesc_create_mbuf, + .mpo_ifnet_create_mbuf = biba_ifnet_create_mbuf, + .mpo_mbuf_create_multicast_encap = biba_mbuf_create_multicast_encap, + .mpo_mbuf_create_netlayer = biba_mbuf_create_netlayer, + .mpo_ipq_match = biba_ipq_match, + .mpo_ifnet_relabel = biba_ifnet_relabel, + .mpo_ipq_update = biba_ipq_update, + .mpo_inpcb_sosetlabel = biba_inpcb_sosetlabel, + .mpo_proc_create_swapper = biba_proc_create_swapper, + .mpo_proc_create_init = biba_proc_create_init, + .mpo_cred_relabel = biba_cred_relabel, + .mpo_sysvmsg_cleanup = biba_sysvmsg_cleanup, + .mpo_sysvmsq_cleanup = biba_sysvmsq_cleanup, + .mpo_sysvsem_cleanup = biba_sysvsem_cleanup, + .mpo_sysvshm_cleanup = biba_sysvshm_cleanup, + .mpo_bpfdesc_check_receive = biba_bpfdesc_check_receive, + .mpo_cred_check_relabel = biba_cred_check_relabel, + .mpo_cred_check_visible = biba_cred_check_visible, + .mpo_ifnet_check_relabel = biba_ifnet_check_relabel, + .mpo_ifnet_check_transmit = biba_ifnet_check_transmit, + .mpo_inpcb_check_deliver = biba_inpcb_check_deliver, + .mpo_sysvmsq_check_msgrcv = biba_sysvmsq_check_msgrcv, + .mpo_sysvmsq_check_msgrmid = biba_sysvmsq_check_msgrmid, + .mpo_sysvmsq_check_msqget = biba_sysvmsq_check_msqget, + .mpo_sysvmsq_check_msqsnd = biba_sysvmsq_check_msqsnd, + .mpo_sysvmsq_check_msqrcv = biba_sysvmsq_check_msqrcv, + .mpo_sysvmsq_check_msqctl = biba_sysvmsq_check_msqctl, + .mpo_sysvsem_check_semctl = biba_sysvsem_check_semctl, + .mpo_sysvsem_check_semget = biba_sysvsem_check_semget, + .mpo_sysvsem_check_semop = biba_sysvsem_check_semop, + .mpo_sysvshm_check_shmat = biba_sysvshm_check_shmat, + .mpo_sysvshm_check_shmctl = biba_sysvshm_check_shmctl, + .mpo_sysvshm_check_shmget = biba_sysvshm_check_shmget, + .mpo_kld_check_load = biba_kld_check_load, + .mpo_mount_check_stat = biba_mount_check_stat, + .mpo_pipe_check_ioctl = biba_pipe_check_ioctl, + .mpo_pipe_check_poll = biba_pipe_check_poll, + .mpo_pipe_check_read = biba_pipe_check_read, + .mpo_pipe_check_relabel = biba_pipe_check_relabel, + .mpo_pipe_check_stat = biba_pipe_check_stat, + .mpo_pipe_check_write = biba_pipe_check_write, + .mpo_posixsem_check_destroy = biba_posixsem_check_write, + .mpo_posixsem_check_getvalue = biba_posixsem_check_rdonly, + .mpo_posixsem_check_open = biba_posixsem_check_write, + .mpo_posixsem_check_post = biba_posixsem_check_write, + .mpo_posixsem_check_unlink = biba_posixsem_check_write, + .mpo_posixsem_check_wait = biba_posixsem_check_write, + .mpo_proc_check_debug = biba_proc_check_debug, + .mpo_proc_check_sched = biba_proc_check_sched, + .mpo_proc_check_signal = biba_proc_check_signal, + .mpo_socket_check_deliver = biba_socket_check_deliver, + .mpo_socket_check_relabel = biba_socket_check_relabel, + .mpo_socket_check_visible = biba_socket_check_visible, + .mpo_system_check_acct = biba_system_check_acct, + .mpo_system_check_auditctl = biba_system_check_auditctl, + .mpo_system_check_auditon = biba_system_check_auditon, + .mpo_system_check_swapon = biba_system_check_swapon, + .mpo_system_check_swapoff = biba_system_check_swapoff, + .mpo_system_check_sysctl = biba_system_check_sysctl, + .mpo_vnode_check_access = biba_vnode_check_open, + .mpo_vnode_check_chdir = biba_vnode_check_chdir, + .mpo_vnode_check_chroot = biba_vnode_check_chroot, + .mpo_vnode_check_create = biba_vnode_check_create, + .mpo_vnode_check_deleteacl = biba_vnode_check_deleteacl, + .mpo_vnode_check_deleteextattr = biba_vnode_check_deleteextattr, + .mpo_vnode_check_exec = biba_vnode_check_exec, + .mpo_vnode_check_getacl = biba_vnode_check_getacl, + .mpo_vnode_check_getextattr = biba_vnode_check_getextattr, + .mpo_vnode_check_link = biba_vnode_check_link, + .mpo_vnode_check_listextattr = biba_vnode_check_listextattr, + .mpo_vnode_check_lookup = biba_vnode_check_lookup, + .mpo_vnode_check_mmap = biba_vnode_check_mmap, + .mpo_vnode_check_open = biba_vnode_check_open, + .mpo_vnode_check_poll = biba_vnode_check_poll, + .mpo_vnode_check_read = biba_vnode_check_read, + .mpo_vnode_check_readdir = biba_vnode_check_readdir, + .mpo_vnode_check_readlink = biba_vnode_check_readlink, + .mpo_vnode_check_relabel = biba_vnode_check_relabel, + .mpo_vnode_check_rename_from = biba_vnode_check_rename_from, + .mpo_vnode_check_rename_to = biba_vnode_check_rename_to, + .mpo_vnode_check_revoke = biba_vnode_check_revoke, + .mpo_vnode_check_setacl = biba_vnode_check_setacl, + .mpo_vnode_check_setextattr = biba_vnode_check_setextattr, + .mpo_vnode_check_setflags = biba_vnode_check_setflags, + .mpo_vnode_check_setmode = biba_vnode_check_setmode, + .mpo_vnode_check_setowner = biba_vnode_check_setowner, + .mpo_vnode_check_setutimes = biba_vnode_check_setutimes, + .mpo_vnode_check_stat = biba_vnode_check_stat, + .mpo_vnode_check_unlink = biba_vnode_check_unlink, + .mpo_vnode_check_write = biba_vnode_check_write, + .mpo_associate_nfsd_label = biba_associate_nfsd_label, + .mpo_mbuf_create_from_firewall = biba_mbuf_create_from_firewall, + .mpo_priv_check = biba_priv_check, }; MAC_POLICY_SET(&mac_biba_ops, mac_biba, "TrustedBSD MAC/Biba", - MPC_LOADTIME_FLAG_NOTLATE | MPC_LOADTIME_FLAG_LABELMBUFS, &mac_biba_slot); + MPC_LOADTIME_FLAG_NOTLATE | MPC_LOADTIME_FLAG_LABELMBUFS, &biba_slot); diff --git a/sys/security/mac_bsdextended/mac_bsdextended.c b/sys/security/mac_bsdextended/mac_bsdextended.c index 05521fe..a4c4a38 100644 --- a/sys/security/mac_bsdextended/mac_bsdextended.c +++ b/sys/security/mac_bsdextended/mac_bsdextended.c @@ -65,17 +65,17 @@ #include <security/mac/mac_policy.h> #include <security/mac_bsdextended/mac_bsdextended.h> -static struct mtx mac_bsdextended_mtx; +static struct mtx ugidfw_mtx; SYSCTL_DECL(_security_mac); SYSCTL_NODE(_security_mac, OID_AUTO, bsdextended, CTLFLAG_RW, 0, "TrustedBSD extended BSD MAC policy controls"); -static int mac_bsdextended_enabled = 1; +static int ugidfw_enabled = 1; SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RW, - &mac_bsdextended_enabled, 0, "Enforce extended BSD policy"); -TUNABLE_INT("security.mac.bsdextended.enabled", &mac_bsdextended_enabled); + &ugidfw_enabled, 0, "Enforce extended BSD policy"); +TUNABLE_INT("security.mac.bsdextended.enabled", &ugidfw_enabled); MALLOC_DEFINE(M_MACBSDEXTENDED, "mac_bsdextended", "BSD Extended MAC rule"); @@ -96,23 +96,22 @@ SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, rule_version, CTLFLAG_RD, * This is just used for logging purposes, eventually we would like to log * much more then failed requests. */ -static int mac_bsdextended_logging; +static int ugidfw_logging; SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, logging, CTLFLAG_RW, - &mac_bsdextended_logging, 0, "Log failed authorization requests"); + &ugidfw_logging, 0, "Log failed authorization requests"); /* * This tunable is here for compatibility. It will allow the user to switch * between the new mode (first rule matches) and the old functionality (all * rules match). */ -static int -mac_bsdextended_firstmatch_enabled; +static int ugidfw_firstmatch_enabled; SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, firstmatch_enabled, - CTLFLAG_RW, &mac_bsdextended_firstmatch_enabled, 1, + CTLFLAG_RW, &ugidfw_firstmatch_enabled, 1, "Disable/enable match first rule functionality"); static int -mac_bsdextended_rule_valid(struct mac_bsdextended_rule *rule) +ugidfw_rule_valid(struct mac_bsdextended_rule *rule) { if ((rule->mbr_subject.mbs_flags | MBS_ALL_FLAGS) != MBS_ALL_FLAGS) @@ -156,7 +155,7 @@ sysctl_rule(SYSCTL_HANDLER_ARGS) sizeof(*ruleptr), M_MACBSDEXTENDED, M_WAITOK | M_ZERO); } - mtx_lock(&mac_bsdextended_mtx); + mtx_lock(&ugidfw_mtx); if (req->oldptr) { if (index < 0 || index > rule_slots + 1) { error = ENOENT; @@ -178,7 +177,7 @@ sysctl_rule(SYSCTL_HANDLER_ARGS) rule_count--; rules[index] = NULL; } else if (req->newptr) { - error = mac_bsdextended_rule_valid(&temprule); + error = ugidfw_rule_valid(&temprule); if (error) goto out; if (rules[index] == NULL) { @@ -192,7 +191,7 @@ sysctl_rule(SYSCTL_HANDLER_ARGS) *rules[index] = temprule; } out: - mtx_unlock(&mac_bsdextended_mtx); + mtx_unlock(&ugidfw_mtx); if (ruleptr != NULL) FREE(ruleptr, M_MACBSDEXTENDED); if (req->oldptr && error == 0) @@ -204,21 +203,21 @@ SYSCTL_NODE(_security_mac_bsdextended, OID_AUTO, rules, CTLFLAG_RW, sysctl_rule, "BSD extended MAC rules"); static void -mac_bsdextended_init(struct mac_policy_conf *mpc) +ugidfw_init(struct mac_policy_conf *mpc) { - mtx_init(&mac_bsdextended_mtx, "mac_bsdextended lock", NULL, MTX_DEF); + mtx_init(&ugidfw_mtx, "mac_bsdextended lock", NULL, MTX_DEF); } static void -mac_bsdextended_destroy(struct mac_policy_conf *mpc) +ugidfw_destroy(struct mac_policy_conf *mpc) { - mtx_destroy(&mac_bsdextended_mtx); + mtx_destroy(&ugidfw_mtx); } static int -mac_bsdextended_rulecheck(struct mac_bsdextended_rule *rule, +ugidfw_rulecheck(struct mac_bsdextended_rule *rule, struct ucred *cred, struct vnode *vp, struct vattr *vap, int acc_mode) { int match; @@ -227,7 +226,7 @@ mac_bsdextended_rulecheck(struct mac_bsdextended_rule *rule, /* * Is there a subject match? */ - mtx_assert(&mac_bsdextended_mtx, MA_OWNED); + mtx_assert(&ugidfw_mtx, MA_OWNED); if (rule->mbr_subject.mbs_flags & MBS_UID_DEFINED) { match = ((cred->cr_uid <= rule->mbr_subject.mbs_uid_max && cred->cr_uid >= rule->mbr_subject.mbs_uid_min) || @@ -375,7 +374,7 @@ mac_bsdextended_rulecheck(struct mac_bsdextended_rule *rule, * Is the access permitted? */ if ((rule->mbr_mode & acc_mode) != acc_mode) { - if (mac_bsdextended_logging) + if (ugidfw_logging) log(LOG_AUTHPRIV, "mac_bsdextended: %d:%d request %d" " on %d:%d failed. \n", cred->cr_ruid, cred->cr_rgid, acc_mode, vap->va_uid, @@ -387,14 +386,14 @@ mac_bsdextended_rulecheck(struct mac_bsdextended_rule *rule, * If the rule matched, permits access, and first match is enabled, * return success. */ - if (mac_bsdextended_firstmatch_enabled) + if (ugidfw_firstmatch_enabled) return (EJUSTRETURN); else return (0); } static int -mac_bsdextended_check(struct ucred *cred, struct vnode *vp, struct vattr *vap, +ugidfw_check(struct ucred *cred, struct vnode *vp, struct vattr *vap, int acc_mode) { int error, i; @@ -412,341 +411,340 @@ mac_bsdextended_check(struct ucred *cred, struct vnode *vp, struct vattr *vap, acc_mode &= ~MBI_APPEND; acc_mode |= MBI_WRITE; } - mtx_lock(&mac_bsdextended_mtx); + mtx_lock(&ugidfw_mtx); for (i = 0; i < rule_slots; i++) { if (rules[i] == NULL) continue; - error = mac_bsdextended_rulecheck(rules[i], cred, + error = ugidfw_rulecheck(rules[i], cred, vp, vap, acc_mode); if (error == EJUSTRETURN) break; if (error) { - mtx_unlock(&mac_bsdextended_mtx); + mtx_unlock(&ugidfw_mtx); return (error); } } - mtx_unlock(&mac_bsdextended_mtx); + mtx_unlock(&ugidfw_mtx); return (0); } static int -mac_bsdextended_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode) +ugidfw_check_vp(struct ucred *cred, struct vnode *vp, int acc_mode) { int error; struct vattr vap; - if (!mac_bsdextended_enabled) + if (!ugidfw_enabled) return (0); error = VOP_GETATTR(vp, &vap, cred, curthread); if (error) return (error); - return (mac_bsdextended_check(cred, vp, &vap, acc_mode)); + return (ugidfw_check(cred, vp, &vap, acc_mode)); } static int -mac_bsdextended_system_check_acct(struct ucred *cred, struct vnode *vp, +ugidfw_system_check_acct(struct ucred *cred, struct vnode *vp, struct label *vplabel) { - return (mac_bsdextended_check_vp(cred, vp, MBI_WRITE)); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); } static int -mac_bsdextended_system_check_auditctl(struct ucred *cred, struct vnode *vp, +ugidfw_system_check_auditctl(struct ucred *cred, struct vnode *vp, struct label *vplabel) { - return (mac_bsdextended_check_vp(cred, vp, MBI_WRITE)); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); } static int -mac_bsdextended_system_check_swapoff(struct ucred *cred, struct vnode *vp, +ugidfw_system_check_swapoff(struct ucred *cred, struct vnode *vp, struct label *vplabel) { - return (mac_bsdextended_check_vp(cred, vp, MBI_WRITE)); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); } static int -mac_bsdextended_system_check_swapon(struct ucred *cred, struct vnode *vp, +ugidfw_system_check_swapon(struct ucred *cred, struct vnode *vp, struct label *vplabel) { - return (mac_bsdextended_check_vp(cred, vp, MBI_WRITE)); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); } static int -mac_bsdextended_vnode_check_access(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_access(struct ucred *cred, struct vnode *vp, struct label *vplabel, int acc_mode) { - return (mac_bsdextended_check_vp(cred, vp, acc_mode)); + return (ugidfw_check_vp(cred, vp, acc_mode)); } static int -mac_bsdextended_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, +ugidfw_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { - return (mac_bsdextended_check_vp(cred, dvp, MBI_EXEC)); + return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); } static int -mac_bsdextended_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, +ugidfw_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { - return (mac_bsdextended_check_vp(cred, dvp, MBI_EXEC)); + return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); } static int -mac_bsdextended_check_create_vnode(struct ucred *cred, struct vnode *dvp, +ugidfw_check_create_vnode(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp, struct vattr *vap) { - return (mac_bsdextended_check_vp(cred, dvp, MBI_WRITE)); + return (ugidfw_check_vp(cred, dvp, MBI_WRITE)); } static int -mac_bsdextended_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { - return (mac_bsdextended_check_vp(cred, vp, MBI_ADMIN)); + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); } static int -mac_bsdextended_vnode_check_deleteextattr(struct ucred *cred, - struct vnode *vp, struct label *vplabel, int attrnamespace, - const char *name) +ugidfw_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, + struct label *vplabel, int attrnamespace, const char *name) { - return (mac_bsdextended_check_vp(cred, vp, MBI_WRITE)); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); } static int -mac_bsdextended_vnode_check_exec(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_exec(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct image_params *imgp, struct label *execlabel) { - return (mac_bsdextended_check_vp(cred, vp, MBI_READ|MBI_EXEC)); + return (ugidfw_check_vp(cred, vp, MBI_READ|MBI_EXEC)); } static int -mac_bsdextended_vnode_check_getacl(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_getacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { - return (mac_bsdextended_check_vp(cred, vp, MBI_STAT)); + return (ugidfw_check_vp(cred, vp, MBI_STAT)); } static int -mac_bsdextended_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { - return (mac_bsdextended_check_vp(cred, vp, MBI_READ)); + return (ugidfw_check_vp(cred, vp, MBI_READ)); } static int -mac_bsdextended_vnode_check_link(struct ucred *cred, struct vnode *dvp, +ugidfw_vnode_check_link(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *label, struct componentname *cnp) { int error; - error = mac_bsdextended_check_vp(cred, dvp, MBI_WRITE); + error = ugidfw_check_vp(cred, dvp, MBI_WRITE); if (error) return (error); - error = mac_bsdextended_check_vp(cred, vp, MBI_WRITE); + error = ugidfw_check_vp(cred, vp, MBI_WRITE); if (error) return (error); return (0); } static int -mac_bsdextended_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace) { - return (mac_bsdextended_check_vp(cred, vp, MBI_READ)); + return (ugidfw_check_vp(cred, vp, MBI_READ)); } static int -mac_bsdextended_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, +ugidfw_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp) { - return (mac_bsdextended_check_vp(cred, dvp, MBI_EXEC)); + return (ugidfw_check_vp(cred, dvp, MBI_EXEC)); } static int -mac_bsdextended_vnode_check_open(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_open(struct ucred *cred, struct vnode *vp, struct label *vplabel, int acc_mode) { - return (mac_bsdextended_check_vp(cred, vp, acc_mode)); + return (ugidfw_check_vp(cred, vp, acc_mode)); } static int -mac_bsdextended_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, +ugidfw_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { - return (mac_bsdextended_check_vp(cred, dvp, MBI_READ)); + return (ugidfw_check_vp(cred, dvp, MBI_READ)); } static int -mac_bsdextended_vnode_check_readdlink(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_readdlink(struct ucred *cred, struct vnode *vp, struct label *vplabel) { - return (mac_bsdextended_check_vp(cred, vp, MBI_READ)); + return (ugidfw_check_vp(cred, vp, MBI_READ)); } static int -mac_bsdextended_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, +ugidfw_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { int error; - error = mac_bsdextended_check_vp(cred, dvp, MBI_WRITE); + error = ugidfw_check_vp(cred, dvp, MBI_WRITE); if (error) return (error); - return (mac_bsdextended_check_vp(cred, vp, MBI_WRITE)); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); } static int -mac_bsdextended_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, +ugidfw_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, int samedir, struct componentname *cnp) { int error; - error = mac_bsdextended_check_vp(cred, dvp, MBI_WRITE); + error = ugidfw_check_vp(cred, dvp, MBI_WRITE); if (error) return (error); if (vp != NULL) - error = mac_bsdextended_check_vp(cred, vp, MBI_WRITE); + error = ugidfw_check_vp(cred, vp, MBI_WRITE); return (error); } static int -mac_bsdextended_vnode_check_revoke(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_revoke(struct ucred *cred, struct vnode *vp, struct label *vplabel) { - return (mac_bsdextended_check_vp(cred, vp, MBI_ADMIN)); + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); } static int -mac_bsdextended_check_setacl_vnode(struct ucred *cred, struct vnode *vp, +ugidfw_check_setacl_vnode(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type, struct acl *acl) { - return (mac_bsdextended_check_vp(cred, vp, MBI_ADMIN)); + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); } static int -mac_bsdextended_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { - return (mac_bsdextended_check_vp(cred, vp, MBI_WRITE)); + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); } static int -mac_bsdextended_vnode_check_setflags(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_setflags(struct ucred *cred, struct vnode *vp, struct label *vplabel, u_long flags) { - return (mac_bsdextended_check_vp(cred, vp, MBI_ADMIN)); + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); } static int -mac_bsdextended_vnode_check_setmode(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_setmode(struct ucred *cred, struct vnode *vp, struct label *vplabel, mode_t mode) { - return (mac_bsdextended_check_vp(cred, vp, MBI_ADMIN)); + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); } static int -mac_bsdextended_vnode_check_setowner(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_setowner(struct ucred *cred, struct vnode *vp, struct label *vplabel, uid_t uid, gid_t gid) { - return (mac_bsdextended_check_vp(cred, vp, MBI_ADMIN)); + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); } static int -mac_bsdextended_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, +ugidfw_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct timespec atime, struct timespec utime) { - return (mac_bsdextended_check_vp(cred, vp, MBI_ADMIN)); + return (ugidfw_check_vp(cred, vp, MBI_ADMIN)); } static int -mac_bsdextended_vnode_check_stat(struct ucred *active_cred, +ugidfw_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { - return (mac_bsdextended_check_vp(active_cred, vp, MBI_STAT)); + return (ugidfw_check_vp(active_cred, vp, MBI_STAT)); } static int -mac_bsdextended_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, +ugidfw_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { int error; - error = mac_bsdextended_check_vp(cred, dvp, MBI_WRITE); + error = ugidfw_check_vp(cred, dvp, MBI_WRITE); if (error) return (error); - return (mac_bsdextended_check_vp(cred, vp, MBI_WRITE)); -} - -static struct mac_policy_ops mac_bsdextended_ops = -{ - .mpo_destroy = mac_bsdextended_destroy, - .mpo_init = mac_bsdextended_init, - .mpo_system_check_acct = mac_bsdextended_system_check_acct, - .mpo_system_check_auditctl = mac_bsdextended_system_check_auditctl, - .mpo_system_check_swapoff = mac_bsdextended_system_check_swapoff, - .mpo_system_check_swapon = mac_bsdextended_system_check_swapon, - .mpo_vnode_check_access = mac_bsdextended_vnode_check_access, - .mpo_vnode_check_chdir = mac_bsdextended_vnode_check_chdir, - .mpo_vnode_check_chroot = mac_bsdextended_vnode_check_chroot, - .mpo_vnode_check_create = mac_bsdextended_check_create_vnode, - .mpo_vnode_check_deleteacl = mac_bsdextended_vnode_check_deleteacl, - .mpo_vnode_check_deleteextattr = mac_bsdextended_vnode_check_deleteextattr, - .mpo_vnode_check_exec = mac_bsdextended_vnode_check_exec, - .mpo_vnode_check_getacl = mac_bsdextended_vnode_check_getacl, - .mpo_vnode_check_getextattr = mac_bsdextended_vnode_check_getextattr, - .mpo_vnode_check_link = mac_bsdextended_vnode_check_link, - .mpo_vnode_check_listextattr = mac_bsdextended_vnode_check_listextattr, - .mpo_vnode_check_lookup = mac_bsdextended_vnode_check_lookup, - .mpo_vnode_check_open = mac_bsdextended_vnode_check_open, - .mpo_vnode_check_readdir = mac_bsdextended_vnode_check_readdir, - .mpo_vnode_check_readlink = mac_bsdextended_vnode_check_readdlink, - .mpo_vnode_check_rename_from = mac_bsdextended_vnode_check_rename_from, - .mpo_vnode_check_rename_to = mac_bsdextended_vnode_check_rename_to, - .mpo_vnode_check_revoke = mac_bsdextended_vnode_check_revoke, - .mpo_vnode_check_setacl = mac_bsdextended_check_setacl_vnode, - .mpo_vnode_check_setextattr = mac_bsdextended_vnode_check_setextattr, - .mpo_vnode_check_setflags = mac_bsdextended_vnode_check_setflags, - .mpo_vnode_check_setmode = mac_bsdextended_vnode_check_setmode, - .mpo_vnode_check_setowner = mac_bsdextended_vnode_check_setowner, - .mpo_vnode_check_setutimes = mac_bsdextended_vnode_check_setutimes, - .mpo_vnode_check_stat = mac_bsdextended_vnode_check_stat, - .mpo_vnode_check_unlink = mac_bsdextended_vnode_check_unlink, + return (ugidfw_check_vp(cred, vp, MBI_WRITE)); +} + +static struct mac_policy_ops ugidfw_ops = +{ + .mpo_destroy = ugidfw_destroy, + .mpo_init = ugidfw_init, + .mpo_system_check_acct = ugidfw_system_check_acct, + .mpo_system_check_auditctl = ugidfw_system_check_auditctl, + .mpo_system_check_swapoff = ugidfw_system_check_swapoff, + .mpo_system_check_swapon = ugidfw_system_check_swapon, + .mpo_vnode_check_access = ugidfw_vnode_check_access, + .mpo_vnode_check_chdir = ugidfw_vnode_check_chdir, + .mpo_vnode_check_chroot = ugidfw_vnode_check_chroot, + .mpo_vnode_check_create = ugidfw_check_create_vnode, + .mpo_vnode_check_deleteacl = ugidfw_vnode_check_deleteacl, + .mpo_vnode_check_deleteextattr = ugidfw_vnode_check_deleteextattr, + .mpo_vnode_check_exec = ugidfw_vnode_check_exec, + .mpo_vnode_check_getacl = ugidfw_vnode_check_getacl, + .mpo_vnode_check_getextattr = ugidfw_vnode_check_getextattr, + .mpo_vnode_check_link = ugidfw_vnode_check_link, + .mpo_vnode_check_listextattr = ugidfw_vnode_check_listextattr, + .mpo_vnode_check_lookup = ugidfw_vnode_check_lookup, + .mpo_vnode_check_open = ugidfw_vnode_check_open, + .mpo_vnode_check_readdir = ugidfw_vnode_check_readdir, + .mpo_vnode_check_readlink = ugidfw_vnode_check_readdlink, + .mpo_vnode_check_rename_from = ugidfw_vnode_check_rename_from, + .mpo_vnode_check_rename_to = ugidfw_vnode_check_rename_to, + .mpo_vnode_check_revoke = ugidfw_vnode_check_revoke, + .mpo_vnode_check_setacl = ugidfw_check_setacl_vnode, + .mpo_vnode_check_setextattr = ugidfw_vnode_check_setextattr, + .mpo_vnode_check_setflags = ugidfw_vnode_check_setflags, + .mpo_vnode_check_setmode = ugidfw_vnode_check_setmode, + .mpo_vnode_check_setowner = ugidfw_vnode_check_setowner, + .mpo_vnode_check_setutimes = ugidfw_vnode_check_setutimes, + .mpo_vnode_check_stat = ugidfw_vnode_check_stat, + .mpo_vnode_check_unlink = ugidfw_vnode_check_unlink, }; -MAC_POLICY_SET(&mac_bsdextended_ops, mac_bsdextended, - "TrustedBSD MAC/BSD Extended", MPC_LOADTIME_FLAG_UNLOADOK, NULL); +MAC_POLICY_SET(&ugidfw_ops, mac_bsdextended, "TrustedBSD MAC/BSD Extended", + MPC_LOADTIME_FLAG_UNLOADOK, NULL); diff --git a/sys/security/mac_ifoff/mac_ifoff.c b/sys/security/mac_ifoff/mac_ifoff.c index 31bf09a..6d51ea8 100644 --- a/sys/security/mac_ifoff/mac_ifoff.c +++ b/sys/security/mac_ifoff/mac_ifoff.c @@ -40,6 +40,7 @@ /* * Developed by the TrustedBSD Project. + * * Limit access to interfaces until they are specifically administratively * enabled. Prevents protocol stack-driven packet leakage in unsafe * environments. @@ -61,38 +62,38 @@ SYSCTL_DECL(_security_mac); SYSCTL_NODE(_security_mac, OID_AUTO, ifoff, CTLFLAG_RW, 0, "TrustedBSD mac_ifoff policy controls"); -static int mac_ifoff_enabled = 1; +static int ifoff_enabled = 1; SYSCTL_INT(_security_mac_ifoff, OID_AUTO, enabled, CTLFLAG_RW, - &mac_ifoff_enabled, 0, "Enforce ifoff policy"); -TUNABLE_INT("security.mac.ifoff.enabled", &mac_ifoff_enabled); + &ifoff_enabled, 0, "Enforce ifoff policy"); +TUNABLE_INT("security.mac.ifoff.enabled", &ifoff_enabled); -static int mac_ifoff_lo_enabled = 1; +static int ifoff_lo_enabled = 1; SYSCTL_INT(_security_mac_ifoff, OID_AUTO, lo_enabled, CTLFLAG_RW, - &mac_ifoff_lo_enabled, 0, "Enable loopback interfaces"); -TUNABLE_INT("security.mac.ifoff.lo_enabled", &mac_ifoff_lo_enabled); + &ifoff_lo_enabled, 0, "Enable loopback interfaces"); +TUNABLE_INT("security.mac.ifoff.lo_enabled", &ifoff_lo_enabled); -static int mac_ifoff_other_enabled = 0; +static int ifoff_other_enabled = 0; SYSCTL_INT(_security_mac_ifoff, OID_AUTO, other_enabled, CTLFLAG_RW, - &mac_ifoff_other_enabled, 0, "Enable other interfaces"); -TUNABLE_INT("security.mac.ifoff.other_enabled", &mac_ifoff_other_enabled); + &ifoff_other_enabled, 0, "Enable other interfaces"); +TUNABLE_INT("security.mac.ifoff.other_enabled", &ifoff_other_enabled); -static int mac_ifoff_bpfrecv_enabled = 0; +static int ifoff_bpfrecv_enabled = 0; SYSCTL_INT(_security_mac_ifoff, OID_AUTO, bpfrecv_enabled, CTLFLAG_RW, - &mac_ifoff_bpfrecv_enabled, 0, "Enable BPF reception even when interface " + &ifoff_bpfrecv_enabled, 0, "Enable BPF reception even when interface " "is disabled"); -TUNABLE_INT("security.mac.ifoff.bpfrecv.enabled", &mac_ifoff_bpfrecv_enabled); +TUNABLE_INT("security.mac.ifoff.bpfrecv.enabled", &ifoff_bpfrecv_enabled); static int ifnet_check_outgoing(struct ifnet *ifp) { - if (!mac_ifoff_enabled) + if (!ifoff_enabled) return (0); - if (mac_ifoff_lo_enabled && ifp->if_type == IFT_LOOP) + if (ifoff_lo_enabled && ifp->if_type == IFT_LOOP) return (0); - if (mac_ifoff_other_enabled && ifp->if_type != IFT_LOOP) + if (ifoff_other_enabled && ifp->if_type != IFT_LOOP) return (0); return (EPERM); @@ -101,23 +102,23 @@ ifnet_check_outgoing(struct ifnet *ifp) static int ifnet_check_incoming(struct ifnet *ifp, int viabpf) { - if (!mac_ifoff_enabled) + if (!ifoff_enabled) return (0); - if (mac_ifoff_lo_enabled && ifp->if_type == IFT_LOOP) + if (ifoff_lo_enabled && ifp->if_type == IFT_LOOP) return (0); - if (mac_ifoff_other_enabled && ifp->if_type != IFT_LOOP) + if (ifoff_other_enabled && ifp->if_type != IFT_LOOP) return (0); - if (viabpf && mac_ifoff_bpfrecv_enabled) + if (viabpf && ifoff_bpfrecv_enabled) return (0); return (EPERM); } static int -mac_ifoff_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, +ifoff_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, struct ifnet *ifp, struct label *ifplabel) { @@ -125,7 +126,7 @@ mac_ifoff_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, } static int -mac_ifoff_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, +ifoff_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { @@ -133,7 +134,7 @@ mac_ifoff_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, } static int -mac_ifoff_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, +ifoff_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { @@ -145,7 +146,7 @@ mac_ifoff_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, } static int -mac_ifoff_socket_check_deliver(struct socket *so, struct label *solabel, +ifoff_socket_check_deliver(struct socket *so, struct label *solabel, struct mbuf *m, struct label *mlabel) { @@ -156,13 +157,13 @@ mac_ifoff_socket_check_deliver(struct socket *so, struct label *solabel, return (0); } -static struct mac_policy_ops mac_ifoff_ops = +static struct mac_policy_ops ifoff_ops = { - .mpo_bpfdesc_check_receive = mac_ifoff_bpfdesc_check_receive, - .mpo_ifnet_check_transmit = mac_ifoff_ifnet_check_transmit, - .mpo_inpcb_check_deliver = mac_ifoff_inpcb_check_deliver, - .mpo_socket_check_deliver = mac_ifoff_socket_check_deliver, + .mpo_bpfdesc_check_receive = ifoff_bpfdesc_check_receive, + .mpo_ifnet_check_transmit = ifoff_ifnet_check_transmit, + .mpo_inpcb_check_deliver = ifoff_inpcb_check_deliver, + .mpo_socket_check_deliver = ifoff_socket_check_deliver, }; -MAC_POLICY_SET(&mac_ifoff_ops, mac_ifoff, "TrustedBSD MAC/ifoff", +MAC_POLICY_SET(&ifoff_ops, mac_ifoff, "TrustedBSD MAC/ifoff", MPC_LOADTIME_FLAG_UNLOADOK, NULL); diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c index e66cfe9..01b0b5a 100644 --- a/sys/security/mac_lomac/mac_lomac.c +++ b/sys/security/mac_lomac/mac_lomac.c @@ -96,14 +96,14 @@ SYSCTL_DECL(_security_mac); SYSCTL_NODE(_security_mac, OID_AUTO, lomac, CTLFLAG_RW, 0, "TrustedBSD mac_lomac policy controls"); -static int mac_lomac_label_size = sizeof(struct mac_lomac); +static int lomac_label_size = sizeof(struct mac_lomac); SYSCTL_INT(_security_mac_lomac, OID_AUTO, label_size, CTLFLAG_RD, - &mac_lomac_label_size, 0, "Size of struct mac_lomac"); + &lomac_label_size, 0, "Size of struct mac_lomac"); -static int mac_lomac_enabled = 1; +static int lomac_enabled = 1; SYSCTL_INT(_security_mac_lomac, OID_AUTO, enabled, CTLFLAG_RW, - &mac_lomac_enabled, 0, "Enforce MAC/LOMAC policy"); -TUNABLE_INT("security.mac.lomac.enabled", &mac_lomac_enabled); + &lomac_enabled, 0, "Enforce MAC/LOMAC policy"); +TUNABLE_INT("security.mac.lomac.enabled", &lomac_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_lomac, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, @@ -130,46 +130,46 @@ SYSCTL_INT(_security_mac_lomac, OID_AUTO, revocation_enabled, CTLFLAG_RW, &revocation_enabled, 0, "Revoke access to objects on relabel"); TUNABLE_INT("security.mac.lomac.revocation_enabled", &revocation_enabled); -static int mac_lomac_slot; -#define SLOT(l) ((struct mac_lomac *)mac_label_get((l), mac_lomac_slot)) -#define SLOT_SET(l, val) mac_label_set((l), mac_lomac_slot, (uintptr_t)(val)) +static int lomac_slot; +#define SLOT(l) ((struct mac_lomac *)mac_label_get((l), lomac_slot)) +#define SLOT_SET(l, val) mac_label_set((l), lomac_slot, (uintptr_t)(val)) #define PSLOT(l) ((struct mac_lomac_proc *) \ - mac_label_get((l), mac_lomac_slot)) -#define PSLOT_SET(l, val) mac_label_set((l), mac_lomac_slot, (uintptr_t)(val)) + mac_label_get((l), lomac_slot)) +#define PSLOT_SET(l, val) mac_label_set((l), lomac_slot, (uintptr_t)(val)) -MALLOC_DEFINE(M_MACLOMAC, "mac_lomac_label", "MAC/LOMAC labels"); +MALLOC_DEFINE(M_LOMAC, "mac_lomac_label", "MAC/LOMAC labels"); static struct mac_lomac * lomac_alloc(int flag) { - struct mac_lomac *mac_lomac; + struct mac_lomac *ml; - mac_lomac = malloc(sizeof(struct mac_lomac), M_MACLOMAC, M_ZERO | flag); + ml = malloc(sizeof(*ml), M_LOMAC, M_ZERO | flag); - return (mac_lomac); + return (ml); } static void -lomac_free(struct mac_lomac *mac_lomac) +lomac_free(struct mac_lomac *ml) { - if (mac_lomac != NULL) - free(mac_lomac, M_MACLOMAC); + if (ml != NULL) + free(ml, M_LOMAC); else atomic_add_int(&destroyed_not_inited, 1); } static int -lomac_atmostflags(struct mac_lomac *mac_lomac, int flags) +lomac_atmostflags(struct mac_lomac *ml, int flags) { - if ((mac_lomac->ml_flags & flags) != mac_lomac->ml_flags) + if ((ml->ml_flags & flags) != ml->ml_flags) return (EINVAL); return (0); } static int -mac_lomac_dominate_element(struct mac_lomac_element *a, +lomac_dominate_element(struct mac_lomac_element *a, struct mac_lomac_element *b) { @@ -189,7 +189,7 @@ mac_lomac_dominate_element(struct mac_lomac_element *a, return (1); default: - panic("mac_lomac_dominate_element: b->mle_type invalid"); + panic("lomac_dominate_element: b->mle_type invalid"); } case MAC_LOMAC_TYPE_GRADE: @@ -205,80 +205,78 @@ mac_lomac_dominate_element(struct mac_lomac_element *a, return (a->mle_grade >= b->mle_grade); default: - panic("mac_lomac_dominate_element: b->mle_type invalid"); + panic("lomac_dominate_element: b->mle_type invalid"); } default: - panic("mac_lomac_dominate_element: a->mle_type invalid"); + panic("lomac_dominate_element: a->mle_type invalid"); } } static int -mac_lomac_range_in_range(struct mac_lomac *rangea, struct mac_lomac *rangeb) +lomac_range_in_range(struct mac_lomac *rangea, struct mac_lomac *rangeb) { - return (mac_lomac_dominate_element(&rangeb->ml_rangehigh, + return (lomac_dominate_element(&rangeb->ml_rangehigh, &rangea->ml_rangehigh) && - mac_lomac_dominate_element(&rangea->ml_rangelow, + lomac_dominate_element(&rangea->ml_rangelow, &rangeb->ml_rangelow)); } static int -mac_lomac_single_in_range(struct mac_lomac *single, struct mac_lomac *range) +lomac_single_in_range(struct mac_lomac *single, struct mac_lomac *range) { KASSERT((single->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, - ("mac_lomac_single_in_range: a not single")); + ("lomac_single_in_range: a not single")); KASSERT((range->ml_flags & MAC_LOMAC_FLAG_RANGE) != 0, - ("mac_lomac_single_in_range: b not range")); + ("lomac_single_in_range: b not range")); - return (mac_lomac_dominate_element(&range->ml_rangehigh, - &single->ml_single) && - mac_lomac_dominate_element(&single->ml_single, + return (lomac_dominate_element(&range->ml_rangehigh, + &single->ml_single) && lomac_dominate_element(&single->ml_single, &range->ml_rangelow)); } static int -mac_lomac_auxsingle_in_range(struct mac_lomac *single, struct mac_lomac *range) +lomac_auxsingle_in_range(struct mac_lomac *single, struct mac_lomac *range) { KASSERT((single->ml_flags & MAC_LOMAC_FLAG_AUX) != 0, - ("mac_lomac_single_in_range: a not auxsingle")); + ("lomac_single_in_range: a not auxsingle")); KASSERT((range->ml_flags & MAC_LOMAC_FLAG_RANGE) != 0, - ("mac_lomac_single_in_range: b not range")); + ("lomac_single_in_range: b not range")); - return (mac_lomac_dominate_element(&range->ml_rangehigh, + return (lomac_dominate_element(&range->ml_rangehigh, &single->ml_auxsingle) && - mac_lomac_dominate_element(&single->ml_auxsingle, + lomac_dominate_element(&single->ml_auxsingle, &range->ml_rangelow)); } static int -mac_lomac_dominate_single(struct mac_lomac *a, struct mac_lomac *b) +lomac_dominate_single(struct mac_lomac *a, struct mac_lomac *b) { KASSERT((a->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, - ("mac_lomac_dominate_single: a not single")); + ("lomac_dominate_single: a not single")); KASSERT((b->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, - ("mac_lomac_dominate_single: b not single")); + ("lomac_dominate_single: b not single")); - return (mac_lomac_dominate_element(&a->ml_single, &b->ml_single)); + return (lomac_dominate_element(&a->ml_single, &b->ml_single)); } static int -mac_lomac_subject_dominate(struct mac_lomac *a, struct mac_lomac *b) +lomac_subject_dominate(struct mac_lomac *a, struct mac_lomac *b) { KASSERT((~a->ml_flags & (MAC_LOMAC_FLAG_SINGLE | MAC_LOMAC_FLAG_RANGE)) == 0, - ("mac_lomac_dominate_single: a not subject")); + ("lomac_dominate_single: a not subject")); KASSERT((b->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, - ("mac_lomac_dominate_single: b not single")); + ("lomac_dominate_single: b not single")); - return (mac_lomac_dominate_element(&a->ml_rangehigh, - &b->ml_single)); + return (lomac_dominate_element(&a->ml_rangehigh, &b->ml_single)); } static int -mac_lomac_equal_element(struct mac_lomac_element *a, struct mac_lomac_element *b) +lomac_equal_element(struct mac_lomac_element *a, struct mac_lomac_element *b) { if (a->mle_type == MAC_LOMAC_TYPE_EQUAL || @@ -289,32 +287,32 @@ mac_lomac_equal_element(struct mac_lomac_element *a, struct mac_lomac_element *b } static int -mac_lomac_equal_single(struct mac_lomac *a, struct mac_lomac *b) +lomac_equal_single(struct mac_lomac *a, struct mac_lomac *b) { KASSERT((a->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, - ("mac_lomac_equal_single: a not single")); + ("lomac_equal_single: a not single")); KASSERT((b->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, - ("mac_lomac_equal_single: b not single")); + ("lomac_equal_single: b not single")); - return (mac_lomac_equal_element(&a->ml_single, &b->ml_single)); + return (lomac_equal_element(&a->ml_single, &b->ml_single)); } static int -mac_lomac_contains_equal(struct mac_lomac *mac_lomac) +lomac_contains_equal(struct mac_lomac *ml) { - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_SINGLE) - if (mac_lomac->ml_single.mle_type == MAC_LOMAC_TYPE_EQUAL) + if (ml->ml_flags & MAC_LOMAC_FLAG_SINGLE) + if (ml->ml_single.mle_type == MAC_LOMAC_TYPE_EQUAL) return (1); - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_AUX) - if (mac_lomac->ml_auxsingle.mle_type == MAC_LOMAC_TYPE_EQUAL) + if (ml->ml_flags & MAC_LOMAC_FLAG_AUX) + if (ml->ml_auxsingle.mle_type == MAC_LOMAC_TYPE_EQUAL) return (1); - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_RANGE) { - if (mac_lomac->ml_rangelow.mle_type == MAC_LOMAC_TYPE_EQUAL) + if (ml->ml_flags & MAC_LOMAC_FLAG_RANGE) { + if (ml->ml_rangelow.mle_type == MAC_LOMAC_TYPE_EQUAL) return (1); - if (mac_lomac->ml_rangehigh.mle_type == MAC_LOMAC_TYPE_EQUAL) + if (ml->ml_rangehigh.mle_type == MAC_LOMAC_TYPE_EQUAL) return (1); } @@ -322,25 +320,25 @@ mac_lomac_contains_equal(struct mac_lomac *mac_lomac) } static int -mac_lomac_subject_privileged(struct mac_lomac *mac_lomac) +lomac_subject_privileged(struct mac_lomac *ml) { - KASSERT((mac_lomac->ml_flags & MAC_LOMAC_FLAGS_BOTH) == + KASSERT((ml->ml_flags & MAC_LOMAC_FLAGS_BOTH) == MAC_LOMAC_FLAGS_BOTH, - ("mac_lomac_subject_privileged: subject doesn't have both labels")); + ("lomac_subject_privileged: subject doesn't have both labels")); /* If the single is EQUAL, it's ok. */ - if (mac_lomac->ml_single.mle_type == MAC_LOMAC_TYPE_EQUAL) + if (ml->ml_single.mle_type == MAC_LOMAC_TYPE_EQUAL) return (0); /* If either range endpoint is EQUAL, it's ok. */ - if (mac_lomac->ml_rangelow.mle_type == MAC_LOMAC_TYPE_EQUAL || - mac_lomac->ml_rangehigh.mle_type == MAC_LOMAC_TYPE_EQUAL) + if (ml->ml_rangelow.mle_type == MAC_LOMAC_TYPE_EQUAL || + ml->ml_rangehigh.mle_type == MAC_LOMAC_TYPE_EQUAL) return (0); /* If the range is low-high, it's ok. */ - if (mac_lomac->ml_rangelow.mle_type == MAC_LOMAC_TYPE_LOW && - mac_lomac->ml_rangehigh.mle_type == MAC_LOMAC_TYPE_HIGH) + if (ml->ml_rangelow.mle_type == MAC_LOMAC_TYPE_LOW && + ml->ml_rangehigh.mle_type == MAC_LOMAC_TYPE_HIGH) return (0); /* It's not ok. */ @@ -348,21 +346,21 @@ mac_lomac_subject_privileged(struct mac_lomac *mac_lomac) } static int -mac_lomac_high_single(struct mac_lomac *mac_lomac) +lomac_high_single(struct mac_lomac *ml) { - KASSERT((mac_lomac->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, - ("mac_lomac_high_single: mac_lomac not single")); + KASSERT((ml->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, + ("lomac_high_single: mac_lomac not single")); - return (mac_lomac->ml_single.mle_type == MAC_LOMAC_TYPE_HIGH); + return (ml->ml_single.mle_type == MAC_LOMAC_TYPE_HIGH); } static int -mac_lomac_valid(struct mac_lomac *mac_lomac) +lomac_valid(struct mac_lomac *ml) { - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_SINGLE) { - switch (mac_lomac->ml_single.mle_type) { + if (ml->ml_flags & MAC_LOMAC_FLAG_SINGLE) { + switch (ml->ml_single.mle_type) { case MAC_LOMAC_TYPE_GRADE: case MAC_LOMAC_TYPE_EQUAL: case MAC_LOMAC_TYPE_HIGH: @@ -373,12 +371,12 @@ mac_lomac_valid(struct mac_lomac *mac_lomac) return (EINVAL); } } else { - if (mac_lomac->ml_single.mle_type != MAC_LOMAC_TYPE_UNDEF) + if (ml->ml_single.mle_type != MAC_LOMAC_TYPE_UNDEF) return (EINVAL); } - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_AUX) { - switch (mac_lomac->ml_auxsingle.mle_type) { + if (ml->ml_flags & MAC_LOMAC_FLAG_AUX) { + switch (ml->ml_auxsingle.mle_type) { case MAC_LOMAC_TYPE_GRADE: case MAC_LOMAC_TYPE_EQUAL: case MAC_LOMAC_TYPE_HIGH: @@ -389,12 +387,12 @@ mac_lomac_valid(struct mac_lomac *mac_lomac) return (EINVAL); } } else { - if (mac_lomac->ml_auxsingle.mle_type != MAC_LOMAC_TYPE_UNDEF) + if (ml->ml_auxsingle.mle_type != MAC_LOMAC_TYPE_UNDEF) return (EINVAL); } - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_RANGE) { - switch (mac_lomac->ml_rangelow.mle_type) { + if (ml->ml_flags & MAC_LOMAC_FLAG_RANGE) { + switch (ml->ml_rangelow.mle_type) { case MAC_LOMAC_TYPE_GRADE: case MAC_LOMAC_TYPE_EQUAL: case MAC_LOMAC_TYPE_HIGH: @@ -405,7 +403,7 @@ mac_lomac_valid(struct mac_lomac *mac_lomac) return (EINVAL); } - switch (mac_lomac->ml_rangehigh.mle_type) { + switch (ml->ml_rangehigh.mle_type) { case MAC_LOMAC_TYPE_GRADE: case MAC_LOMAC_TYPE_EQUAL: case MAC_LOMAC_TYPE_HIGH: @@ -415,12 +413,12 @@ mac_lomac_valid(struct mac_lomac *mac_lomac) default: return (EINVAL); } - if (!mac_lomac_dominate_element(&mac_lomac->ml_rangehigh, - &mac_lomac->ml_rangelow)) + if (!lomac_dominate_element(&ml->ml_rangehigh, + &ml->ml_rangelow)) return (EINVAL); } else { - if (mac_lomac->ml_rangelow.mle_type != MAC_LOMAC_TYPE_UNDEF || - mac_lomac->ml_rangehigh.mle_type != MAC_LOMAC_TYPE_UNDEF) + if (ml->ml_rangelow.mle_type != MAC_LOMAC_TYPE_UNDEF || + ml->ml_rangehigh.mle_type != MAC_LOMAC_TYPE_UNDEF) return (EINVAL); } @@ -428,32 +426,32 @@ mac_lomac_valid(struct mac_lomac *mac_lomac) } static void -mac_lomac_set_range(struct mac_lomac *mac_lomac, u_short typelow, - u_short gradelow, u_short typehigh, u_short gradehigh) +lomac_set_range(struct mac_lomac *ml, u_short typelow, u_short gradelow, + u_short typehigh, u_short gradehigh) { - mac_lomac->ml_rangelow.mle_type = typelow; - mac_lomac->ml_rangelow.mle_grade = gradelow; - mac_lomac->ml_rangehigh.mle_type = typehigh; - mac_lomac->ml_rangehigh.mle_grade = gradehigh; - mac_lomac->ml_flags |= MAC_LOMAC_FLAG_RANGE; + ml->ml_rangelow.mle_type = typelow; + ml->ml_rangelow.mle_grade = gradelow; + ml->ml_rangehigh.mle_type = typehigh; + ml->ml_rangehigh.mle_grade = gradehigh; + ml->ml_flags |= MAC_LOMAC_FLAG_RANGE; } static void -mac_lomac_set_single(struct mac_lomac *mac_lomac, u_short type, u_short grade) +lomac_set_single(struct mac_lomac *ml, u_short type, u_short grade) { - mac_lomac->ml_single.mle_type = type; - mac_lomac->ml_single.mle_grade = grade; - mac_lomac->ml_flags |= MAC_LOMAC_FLAG_SINGLE; + ml->ml_single.mle_type = type; + ml->ml_single.mle_grade = grade; + ml->ml_flags |= MAC_LOMAC_FLAG_SINGLE; } static void -mac_lomac_copy_range(struct mac_lomac *labelfrom, struct mac_lomac *labelto) +lomac_copy_range(struct mac_lomac *labelfrom, struct mac_lomac *labelto) { KASSERT((labelfrom->ml_flags & MAC_LOMAC_FLAG_RANGE) != 0, - ("mac_lomac_copy_range: labelfrom not range")); + ("lomac_copy_range: labelfrom not range")); labelto->ml_rangelow = labelfrom->ml_rangelow; labelto->ml_rangehigh = labelfrom->ml_rangehigh; @@ -461,41 +459,40 @@ mac_lomac_copy_range(struct mac_lomac *labelfrom, struct mac_lomac *labelto) } static void -mac_lomac_copy_single(struct mac_lomac *labelfrom, struct mac_lomac *labelto) +lomac_copy_single(struct mac_lomac *labelfrom, struct mac_lomac *labelto) { KASSERT((labelfrom->ml_flags & MAC_LOMAC_FLAG_SINGLE) != 0, - ("mac_lomac_copy_single: labelfrom not single")); + ("lomac_copy_single: labelfrom not single")); labelto->ml_single = labelfrom->ml_single; labelto->ml_flags |= MAC_LOMAC_FLAG_SINGLE; } static void -mac_lomac_copy_auxsingle(struct mac_lomac *labelfrom, struct mac_lomac *labelto) +lomac_copy_auxsingle(struct mac_lomac *labelfrom, struct mac_lomac *labelto) { KASSERT((labelfrom->ml_flags & MAC_LOMAC_FLAG_AUX) != 0, - ("mac_lomac_copy_auxsingle: labelfrom not auxsingle")); + ("lomac_copy_auxsingle: labelfrom not auxsingle")); labelto->ml_auxsingle = labelfrom->ml_auxsingle; labelto->ml_flags |= MAC_LOMAC_FLAG_AUX; } static void -mac_lomac_copy(struct mac_lomac *source, struct mac_lomac *dest) +lomac_copy(struct mac_lomac *source, struct mac_lomac *dest) { if (source->ml_flags & MAC_LOMAC_FLAG_SINGLE) - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); if (source->ml_flags & MAC_LOMAC_FLAG_AUX) - mac_lomac_copy_auxsingle(source, dest); + lomac_copy_auxsingle(source, dest); if (source->ml_flags & MAC_LOMAC_FLAG_RANGE) - mac_lomac_copy_range(source, dest); + lomac_copy_range(source, dest); } -static int mac_lomac_to_string(struct sbuf *sb, - struct mac_lomac *mac_lomac); +static int lomac_to_string(struct sbuf *sb, struct mac_lomac *ml); static int maybe_demote(struct mac_lomac *subjlabel, struct mac_lomac *objlabel, @@ -515,11 +512,11 @@ maybe_demote(struct mac_lomac *subjlabel, struct mac_lomac *objlabel, mtx_lock(&subj->mtx); if (subj->mac_lomac.ml_flags & MAC_LOMAC_FLAG_UPDATE) { /* - * Check to see if the pending demotion would be more or - * less severe than this one, and keep the more severe. - * This can only happen for a multi-threaded application. + * Check to see if the pending demotion would be more or less + * severe than this one, and keep the more severe. This can + * only happen for a multi-threaded application. */ - if (mac_lomac_dominate_single(objlabel, &subj->mac_lomac)) { + if (lomac_dominate_single(objlabel, &subj->mac_lomac)) { mtx_unlock(&subj->mtx); return (0); } @@ -528,14 +525,14 @@ maybe_demote(struct mac_lomac *subjlabel, struct mac_lomac *objlabel, /* * Always demote the single label. */ - mac_lomac_copy_single(objlabel, &subj->mac_lomac); + lomac_copy_single(objlabel, &subj->mac_lomac); /* - * Start with the original range, then minimize each side of - * the range to the point of not dominating the object. The - * high side will always be demoted, of course. + * Start with the original range, then minimize each side of the + * range to the point of not dominating the object. The high side + * will always be demoted, of course. */ - mac_lomac_copy_range(subjlabel, &subj->mac_lomac); - if (!mac_lomac_dominate_element(&objlabel->ml_single, + lomac_copy_range(subjlabel, &subj->mac_lomac); + if (!lomac_dominate_element(&objlabel->ml_single, &subj->mac_lomac.ml_rangelow)) subj->mac_lomac.ml_rangelow = objlabel->ml_single; subj->mac_lomac.ml_rangehigh = objlabel->ml_single; @@ -545,24 +542,23 @@ maybe_demote(struct mac_lomac *subjlabel, struct mac_lomac *objlabel, thread_unlock(curthread); /* - * Avoid memory allocation while holding a mutex; cache the - * label. + * Avoid memory allocation while holding a mutex; cache the label. */ - mac_lomac_copy_single(&subj->mac_lomac, &cached_subjlabel); + lomac_copy_single(&subj->mac_lomac, &cached_subjlabel); mtx_unlock(&subj->mtx); sbuf_new(&subjlabel_sb, NULL, 0, SBUF_AUTOEXTEND); - mac_lomac_to_string(&subjlabel_sb, subjlabel); + lomac_to_string(&subjlabel_sb, subjlabel); sbuf_finish(&subjlabel_sb); subjlabeltext = sbuf_data(&subjlabel_sb); sbuf_new(&subjtext_sb, NULL, 0, SBUF_AUTOEXTEND); - mac_lomac_to_string(&subjtext_sb, &subj->mac_lomac); + lomac_to_string(&subjtext_sb, &subj->mac_lomac); sbuf_finish(&subjtext_sb); subjtext = sbuf_data(&subjtext_sb); sbuf_new(&objlabel_sb, NULL, 0, SBUF_AUTOEXTEND); - mac_lomac_to_string(&objlabel_sb, objlabel); + lomac_to_string(&objlabel_sb, objlabel); sbuf_finish(&objlabel_sb); objlabeltext = sbuf_data(&objlabel_sb); @@ -590,9 +586,9 @@ maybe_demote(struct mac_lomac *subjlabel, struct mac_lomac *objlabel, } /* - * Relabel "to" to "from" only if "from" is a valid label (contains - * at least a single), as for a relabel operation which may or may - * not involve a relevant label. + * Relabel "to" to "from" only if "from" is a valid label (contains at least + * a single), as for a relabel operation which may or may not involve a + * relevant label. */ static void try_relabel(struct mac_lomac *from, struct mac_lomac *to) @@ -600,7 +596,7 @@ try_relabel(struct mac_lomac *from, struct mac_lomac *to) if (from->ml_flags & MAC_LOMAC_FLAG_SINGLE) { bzero(to, sizeof(*to)); - mac_lomac_copy(from, to); + lomac_copy(from, to); } } @@ -608,7 +604,7 @@ try_relabel(struct mac_lomac *from, struct mac_lomac *to) * Policy module operations. */ static void -mac_lomac_init(struct mac_policy_conf *conf) +lomac_init(struct mac_policy_conf *conf) { } @@ -617,14 +613,14 @@ mac_lomac_init(struct mac_policy_conf *conf) * Label operations. */ static void -mac_lomac_init_label(struct label *label) +lomac_init_label(struct label *label) { SLOT_SET(label, lomac_alloc(M_WAITOK)); } static int -mac_lomac_init_label_waitcheck(struct label *label, int flag) +lomac_init_label_waitcheck(struct label *label, int flag) { SLOT_SET(label, lomac_alloc(flag)); @@ -635,16 +631,16 @@ mac_lomac_init_label_waitcheck(struct label *label, int flag) } static void -mac_lomac_proc_init_label(struct label *label) +lomac_proc_init_label(struct label *label) { - PSLOT_SET(label, malloc(sizeof(struct mac_lomac_proc), M_MACLOMAC, + PSLOT_SET(label, malloc(sizeof(struct mac_lomac_proc), M_LOMAC, M_ZERO | M_WAITOK)); mtx_init(&PSLOT(label)->mtx, "MAC/Lomac proc lock", NULL, MTX_DEF); } static void -mac_lomac_destroy_label(struct label *label) +lomac_destroy_label(struct label *label) { lomac_free(SLOT(label)); @@ -652,16 +648,16 @@ mac_lomac_destroy_label(struct label *label) } static void -mac_lomac_proc_destroy_label(struct label *label) +lomac_proc_destroy_label(struct label *label) { mtx_destroy(&PSLOT(label)->mtx); - FREE(PSLOT(label), M_MACLOMAC); + FREE(PSLOT(label), M_LOMAC); PSLOT_SET(label, NULL); } static int -mac_lomac_element_to_string(struct sbuf *sb, struct mac_lomac_element *element) +lomac_element_to_string(struct sbuf *sb, struct mac_lomac_element *element) { switch (element->mle_type) { @@ -678,46 +674,42 @@ mac_lomac_element_to_string(struct sbuf *sb, struct mac_lomac_element *element) return (sbuf_printf(sb, "%d", element->mle_grade)); default: - panic("mac_lomac_element_to_string: invalid type (%d)", + panic("lomac_element_to_string: invalid type (%d)", element->mle_type); } } static int -mac_lomac_to_string(struct sbuf *sb, struct mac_lomac *mac_lomac) +lomac_to_string(struct sbuf *sb, struct mac_lomac *ml) { - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_SINGLE) { - if (mac_lomac_element_to_string(sb, &mac_lomac->ml_single) - == -1) + if (ml->ml_flags & MAC_LOMAC_FLAG_SINGLE) { + if (lomac_element_to_string(sb, &ml->ml_single) == -1) return (EINVAL); } - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_AUX) { + if (ml->ml_flags & MAC_LOMAC_FLAG_AUX) { if (sbuf_putc(sb, '[') == -1) return (EINVAL); - if (mac_lomac_element_to_string(sb, &mac_lomac->ml_auxsingle) - == -1) + if (lomac_element_to_string(sb, &ml->ml_auxsingle) == -1) return (EINVAL); if (sbuf_putc(sb, ']') == -1) return (EINVAL); } - if (mac_lomac->ml_flags & MAC_LOMAC_FLAG_RANGE) { + if (ml->ml_flags & MAC_LOMAC_FLAG_RANGE) { if (sbuf_putc(sb, '(') == -1) return (EINVAL); - if (mac_lomac_element_to_string(sb, &mac_lomac->ml_rangelow) - == -1) + if (lomac_element_to_string(sb, &ml->ml_rangelow) == -1) return (EINVAL); if (sbuf_putc(sb, '-') == -1) return (EINVAL); - if (mac_lomac_element_to_string(sb, &mac_lomac->ml_rangehigh) - == -1) + if (lomac_element_to_string(sb, &ml->ml_rangehigh) == -1) return (EINVAL); if (sbuf_putc(sb, ')') == -1) @@ -728,35 +720,33 @@ mac_lomac_to_string(struct sbuf *sb, struct mac_lomac *mac_lomac) } static int -mac_lomac_externalize_label(struct label *label, char *element_name, +lomac_externalize_label(struct label *label, char *element_name, struct sbuf *sb, int *claimed) { - struct mac_lomac *mac_lomac; + struct mac_lomac *ml; if (strcmp(MAC_LOMAC_LABEL_NAME, element_name) != 0) return (0); (*claimed)++; - mac_lomac = SLOT(label); + ml = SLOT(label); - return (mac_lomac_to_string(sb, mac_lomac)); + return (lomac_to_string(sb, ml)); } static int -mac_lomac_parse_element(struct mac_lomac_element *element, char *string) +lomac_parse_element(struct mac_lomac_element *element, char *string) { - if (strcmp(string, "high") == 0 || - strcmp(string, "hi") == 0) { + if (strcmp(string, "high") == 0 || strcmp(string, "hi") == 0) { element->mle_type = MAC_LOMAC_TYPE_HIGH; element->mle_grade = MAC_LOMAC_TYPE_UNDEF; - } else if (strcmp(string, "low") == 0 || - strcmp(string, "lo") == 0) { + } else if (strcmp(string, "low") == 0 || strcmp(string, "lo") == 0) { element->mle_type = MAC_LOMAC_TYPE_LOW; element->mle_grade = MAC_LOMAC_TYPE_UNDEF; - } else if (strcmp(string, "equal") == 0 || - strcmp(string, "eq") == 0) { + } else if (strcmp(string, "equal") == 0 || strcmp(string, "eq") == 0) + { element->mle_type = MAC_LOMAC_TYPE_EQUAL; element->mle_grade = MAC_LOMAC_TYPE_UNDEF; } else { @@ -779,11 +769,11 @@ mac_lomac_parse_element(struct mac_lomac_element *element, char *string) } /* - * Note: destructively consumes the string, make a local copy before - * calling if that's a problem. + * Note: destructively consumes the string, make a local copy before calling + * if that's a problem. */ static int -mac_lomac_parse(struct mac_lomac *mac_lomac, char *string) +lomac_parse(struct mac_lomac *ml, char *string) { char *range, *rangeend, *rangehigh, *rangelow, *single, *auxsingle, *auxsingleend; @@ -822,7 +812,7 @@ mac_lomac_parse(struct mac_lomac *mac_lomac, char *string) } KASSERT((rangelow != NULL && rangehigh != NULL) || (rangelow == NULL && rangehigh == NULL), - ("mac_lomac_internalize_label: range mismatch")); + ("lomac_internalize_label: range mismatch")); if (auxsingle != NULL) { /* Nul terminate the end of the single string. */ *auxsingle = '\0'; @@ -836,35 +826,33 @@ mac_lomac_parse(struct mac_lomac *mac_lomac, char *string) *auxsingleend = '\0'; } - bzero(mac_lomac, sizeof(*mac_lomac)); + bzero(ml, sizeof(*ml)); if (single != NULL) { - error = mac_lomac_parse_element(&mac_lomac->ml_single, single); + error = lomac_parse_element(&ml->ml_single, single); if (error) return (error); - mac_lomac->ml_flags |= MAC_LOMAC_FLAG_SINGLE; + ml->ml_flags |= MAC_LOMAC_FLAG_SINGLE; } if (auxsingle != NULL) { - error = mac_lomac_parse_element(&mac_lomac->ml_auxsingle, + error = lomac_parse_element(&ml->ml_auxsingle, auxsingle); if (error) return (error); - mac_lomac->ml_flags |= MAC_LOMAC_FLAG_AUX; + ml->ml_flags |= MAC_LOMAC_FLAG_AUX; } if (rangelow != NULL) { - error = mac_lomac_parse_element(&mac_lomac->ml_rangelow, - rangelow); + error = lomac_parse_element(&ml->ml_rangelow, rangelow); if (error) return (error); - error = mac_lomac_parse_element(&mac_lomac->ml_rangehigh, - rangehigh); + error = lomac_parse_element(&ml->ml_rangehigh, rangehigh); if (error) return (error); - mac_lomac->ml_flags |= MAC_LOMAC_FLAG_RANGE; + ml->ml_flags |= MAC_LOMAC_FLAG_RANGE; } - error = mac_lomac_valid(mac_lomac); + error = lomac_valid(ml); if (error) return (error); @@ -872,10 +860,10 @@ mac_lomac_parse(struct mac_lomac *mac_lomac, char *string) } static int -mac_lomac_internalize_label(struct label *label, char *element_name, +lomac_internalize_label(struct label *label, char *element_name, char *element_data, int *claimed) { - struct mac_lomac *mac_lomac, mac_lomac_temp; + struct mac_lomac *ml, ml_temp; int error; if (strcmp(MAC_LOMAC_LABEL_NAME, element_name) != 0) @@ -883,35 +871,35 @@ mac_lomac_internalize_label(struct label *label, char *element_name, (*claimed)++; - error = mac_lomac_parse(&mac_lomac_temp, element_data); + error = lomac_parse(&ml_temp, element_data); if (error) return (error); - mac_lomac = SLOT(label); - *mac_lomac = mac_lomac_temp; + ml = SLOT(label); + *ml = ml_temp; return (0); } static void -mac_lomac_copy_label(struct label *src, struct label *dest) +lomac_copy_label(struct label *src, struct label *dest) { *SLOT(dest) = *SLOT(src); } /* - * Labeling event operations: file system objects, and things that look - * a lot like file system objects. + * Labeling event operations: file system objects, and things that look a lot + * like file system objects. */ static void -mac_lomac_devfs_create_device(struct ucred *cred, struct mount *mp, +lomac_devfs_create_device(struct ucred *cred, struct mount *mp, struct cdev *dev, struct devfs_dirent *de, struct label *delabel) { - struct mac_lomac *mac_lomac; + struct mac_lomac *ml; int lomac_type; - mac_lomac = SLOT(delabel); + ml = SLOT(delabel); if (strcmp(dev->si_name, "null") == 0 || strcmp(dev->si_name, "zero") == 0 || strcmp(dev->si_name, "random") == 0 || @@ -924,21 +912,21 @@ mac_lomac_devfs_create_device(struct ucred *cred, struct mount *mp, lomac_type = MAC_LOMAC_TYPE_EQUAL; else lomac_type = MAC_LOMAC_TYPE_HIGH; - mac_lomac_set_single(mac_lomac, lomac_type, 0); + lomac_set_single(ml, lomac_type, 0); } static void -mac_lomac_devfs_create_directory(struct mount *mp, char *dirname, - int dirnamelen, struct devfs_dirent *de, struct label *delabel) +lomac_devfs_create_directory(struct mount *mp, char *dirname, int dirnamelen, + struct devfs_dirent *de, struct label *delabel) { - struct mac_lomac *mac_lomac; + struct mac_lomac *ml; - mac_lomac = SLOT(delabel); - mac_lomac_set_single(mac_lomac, MAC_LOMAC_TYPE_HIGH, 0); + ml = SLOT(delabel); + lomac_set_single(ml, MAC_LOMAC_TYPE_HIGH, 0); } static void -mac_lomac_devfs_create_symlink(struct ucred *cred, struct mount *mp, +lomac_devfs_create_symlink(struct ucred *cred, struct mount *mp, struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de, struct label *delabel) { @@ -947,22 +935,22 @@ mac_lomac_devfs_create_symlink(struct ucred *cred, struct mount *mp, source = SLOT(cred->cr_label); dest = SLOT(delabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_mount_create(struct ucred *cred, struct mount *mp, +lomac_mount_create(struct ucred *cred, struct mount *mp, struct label *mplabel) { struct mac_lomac *source, *dest; source = SLOT(cred->cr_label); dest = SLOT(mplabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_vnode_relabel(struct ucred *cred, struct vnode *vp, +lomac_vnode_relabel(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *newlabel) { struct mac_lomac *source, *dest; @@ -974,7 +962,7 @@ mac_lomac_vnode_relabel(struct ucred *cred, struct vnode *vp, } static void -mac_lomac_devfs_update(struct mount *mp, struct devfs_dirent *de, +lomac_devfs_update(struct mount *mp, struct devfs_dirent *de, struct label *delabel, struct vnode *vp, struct label *vplabel) { struct mac_lomac *source, *dest; @@ -982,11 +970,11 @@ mac_lomac_devfs_update(struct mount *mp, struct devfs_dirent *de, source = SLOT(vplabel); dest = SLOT(delabel); - mac_lomac_copy(source, dest); + lomac_copy(source, dest); } static void -mac_lomac_devfs_vnode_associate(struct mount *mp, struct label *mplabel, +lomac_devfs_vnode_associate(struct mount *mp, struct label *mplabel, struct devfs_dirent *de, struct label *delabel, struct vnode *vp, struct label *vplabel) { @@ -995,70 +983,71 @@ mac_lomac_devfs_vnode_associate(struct mount *mp, struct label *mplabel, source = SLOT(delabel); dest = SLOT(vplabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static int -mac_lomac_vnode_associate_extattr(struct mount *mp, struct label *mplabel, +lomac_vnode_associate_extattr(struct mount *mp, struct label *mplabel, struct vnode *vp, struct label *vplabel) { - struct mac_lomac temp, *source, *dest; + struct mac_lomac ml_temp, *source, *dest; int buflen, error; source = SLOT(mplabel); dest = SLOT(vplabel); - buflen = sizeof(temp); - bzero(&temp, buflen); + buflen = sizeof(ml_temp); + bzero(&ml_temp, buflen); error = vn_extattr_get(vp, IO_NODELOCKED, MAC_LOMAC_EXTATTR_NAMESPACE, - MAC_LOMAC_EXTATTR_NAME, &buflen, (char *)&temp, curthread); + MAC_LOMAC_EXTATTR_NAME, &buflen, (char *)&ml_temp, curthread); if (error == ENOATTR || error == EOPNOTSUPP) { /* Fall back to the mntlabel. */ - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); return (0); } else if (error) return (error); - if (buflen != sizeof(temp)) { - if (buflen != sizeof(temp) - sizeof(temp.ml_auxsingle)) { - printf("mac_lomac_vnode_associate_extattr: bad size %d\n", + if (buflen != sizeof(ml_temp)) { + if (buflen != sizeof(ml_temp) - sizeof(ml_temp.ml_auxsingle)) { + printf("lomac_vnode_associate_extattr: bad size %d\n", buflen); return (EPERM); } - bzero(&temp.ml_auxsingle, sizeof(temp.ml_auxsingle)); - buflen = sizeof(temp); + bzero(&ml_temp.ml_auxsingle, sizeof(ml_temp.ml_auxsingle)); + buflen = sizeof(ml_temp); (void)vn_extattr_set(vp, IO_NODELOCKED, MAC_LOMAC_EXTATTR_NAMESPACE, MAC_LOMAC_EXTATTR_NAME, - buflen, (char *)&temp, curthread); + buflen, (char *)&ml_temp, curthread); } - if (mac_lomac_valid(&temp) != 0) { - printf("mac_lomac_vnode_associate_extattr: invalid\n"); + if (lomac_valid(&ml_temp) != 0) { + printf("lomac_vnode_associate_extattr: invalid\n"); return (EPERM); } - if ((temp.ml_flags & MAC_LOMAC_FLAGS_BOTH) != MAC_LOMAC_FLAG_SINGLE) { - printf("mac_lomac_vnode_associate_extattr: not single\n"); + if ((ml_temp.ml_flags & MAC_LOMAC_FLAGS_BOTH) != + MAC_LOMAC_FLAG_SINGLE) { + printf("lomac_vnode_associate_extattr: not single\n"); return (EPERM); } - mac_lomac_copy_single(&temp, dest); + lomac_copy_single(&ml_temp, dest); return (0); } static void -mac_lomac_vnode_associate_singlelabel(struct mount *mp, - struct label *mplabel, struct vnode *vp, struct label *vplabel) +lomac_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, + struct vnode *vp, struct label *vplabel) { struct mac_lomac *source, *dest; source = SLOT(mplabel); dest = SLOT(vplabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static int -mac_lomac_vnode_create_extattr(struct ucred *cred, struct mount *mp, +lomac_vnode_create_extattr(struct ucred *cred, struct mount *mp, struct label *mplabel, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { @@ -1073,22 +1062,22 @@ mac_lomac_vnode_create_extattr(struct ucred *cred, struct mount *mp, dest = SLOT(vplabel); dir = SLOT(dvplabel); if (dir->ml_flags & MAC_LOMAC_FLAG_AUX) { - mac_lomac_copy_auxsingle(dir, &temp); - mac_lomac_set_single(&temp, dir->ml_auxsingle.mle_type, + lomac_copy_auxsingle(dir, &temp); + lomac_set_single(&temp, dir->ml_auxsingle.mle_type, dir->ml_auxsingle.mle_grade); } else { - mac_lomac_copy_single(source, &temp); + lomac_copy_single(source, &temp); } error = vn_extattr_set(vp, IO_NODELOCKED, MAC_LOMAC_EXTATTR_NAMESPACE, MAC_LOMAC_EXTATTR_NAME, buflen, (char *)&temp, curthread); if (error == 0) - mac_lomac_copy(&temp, dest); + lomac_copy(&temp, dest); return (error); } static int -mac_lomac_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, +lomac_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *intlabel) { struct mac_lomac *source, temp; @@ -1102,7 +1091,7 @@ mac_lomac_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, if ((source->ml_flags & MAC_LOMAC_FLAG_SINGLE) == 0) return (0); - mac_lomac_copy_single(source, &temp); + lomac_copy_single(source, &temp); error = vn_extattr_set(vp, IO_NODELOCKED, MAC_LOMAC_EXTATTR_NAMESPACE, MAC_LOMAC_EXTATTR_NAME, buflen, (char *)&temp, curthread); return (error); @@ -1112,7 +1101,7 @@ mac_lomac_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, * Labeling event operations: IPC object. */ static void -mac_lomac_inpcb_create(struct socket *so, struct label *solabel, +lomac_inpcb_create(struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel) { struct mac_lomac *source, *dest; @@ -1120,11 +1109,11 @@ mac_lomac_inpcb_create(struct socket *so, struct label *solabel, source = SLOT(solabel); dest = SLOT(inplabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_socket_create_mbuf(struct socket *so, struct label *solabel, +lomac_socket_create_mbuf(struct socket *so, struct label *solabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *source, *dest; @@ -1132,11 +1121,11 @@ mac_lomac_socket_create_mbuf(struct socket *so, struct label *solabel, source = SLOT(solabel); dest = SLOT(mlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_socket_create(struct ucred *cred, struct socket *so, +lomac_socket_create(struct ucred *cred, struct socket *so, struct label *solabel) { struct mac_lomac *source, *dest; @@ -1144,11 +1133,11 @@ mac_lomac_socket_create(struct ucred *cred, struct socket *so, source = SLOT(cred->cr_label); dest = SLOT(solabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_pipe_create(struct ucred *cred, struct pipepair *pp, +lomac_pipe_create(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_lomac *source, *dest; @@ -1156,11 +1145,11 @@ mac_lomac_pipe_create(struct ucred *cred, struct pipepair *pp, source = SLOT(cred->cr_label); dest = SLOT(pplabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_socket_newconn(struct socket *oldso, struct label *oldsolabel, +lomac_socket_newconn(struct socket *oldso, struct label *oldsolabel, struct socket *newso, struct label *newsolabel) { struct mac_lomac *source, *dest; @@ -1168,11 +1157,11 @@ mac_lomac_socket_newconn(struct socket *oldso, struct label *oldsolabel, source = SLOT(oldsolabel); dest = SLOT(newsolabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_socket_relabel(struct ucred *cred, struct socket *so, +lomac_socket_relabel(struct ucred *cred, struct socket *so, struct label *solabel, struct label *newlabel) { struct mac_lomac *source, *dest; @@ -1184,7 +1173,7 @@ mac_lomac_socket_relabel(struct ucred *cred, struct socket *so, } static void -mac_lomac_pipe_relabel(struct ucred *cred, struct pipepair *pp, +lomac_pipe_relabel(struct ucred *cred, struct pipepair *pp, struct label *pplabel, struct label *newlabel) { struct mac_lomac *source, *dest; @@ -1196,7 +1185,7 @@ mac_lomac_pipe_relabel(struct ucred *cred, struct pipepair *pp, } static void -mac_lomac_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, +lomac_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, struct socket *so, struct label *sopeerlabel) { struct mac_lomac *source, *dest; @@ -1204,14 +1193,14 @@ mac_lomac_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(sopeerlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } /* * Labeling event operations: network objects. */ static void -mac_lomac_socketpeer_set_from_socket(struct socket *oldso, +lomac_socketpeer_set_from_socket(struct socket *oldso, struct label *oldsolabel, struct socket *newso, struct label *newsopeerlabel) { @@ -1220,11 +1209,11 @@ mac_lomac_socketpeer_set_from_socket(struct socket *oldso, source = SLOT(oldsolabel); dest = SLOT(newsopeerlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_bpfdesc_create(struct ucred *cred, struct bpf_d *d, +lomac_bpfdesc_create(struct ucred *cred, struct bpf_d *d, struct label *dlabel) { struct mac_lomac *source, *dest; @@ -1232,11 +1221,11 @@ mac_lomac_bpfdesc_create(struct ucred *cred, struct bpf_d *d, source = SLOT(cred->cr_label); dest = SLOT(dlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_ifnet_create(struct ifnet *ifp, struct label *ifplabel) +lomac_ifnet_create(struct ifnet *ifp, struct label *ifplabel) { char tifname[IFNAMSIZ], *p, *q; char tiflist[sizeof(trusted_interfaces)]; @@ -1289,12 +1278,12 @@ mac_lomac_ifnet_create(struct ifnet *ifp, struct label *ifplabel) } } set: - mac_lomac_set_single(dest, grade, 0); - mac_lomac_set_range(dest, grade, 0, grade, 0); + lomac_set_single(dest, grade, 0); + lomac_set_range(dest, grade, 0, grade, 0); } static void -mac_lomac_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +lomac_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { struct mac_lomac *source, *dest; @@ -1302,11 +1291,11 @@ mac_lomac_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, source = SLOT(mlabel); dest = SLOT(ipqlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, +lomac_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *source, *dest; @@ -1315,11 +1304,11 @@ mac_lomac_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, dest = SLOT(mlabel); /* Just use the head, since we require them all to match. */ - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_netinet_fragment(struct mbuf *m, struct label *mlabel, +lomac_netinet_fragment(struct mbuf *m, struct label *mlabel, struct mbuf *frag, struct label *fraglabel) { struct mac_lomac *source, *dest; @@ -1327,11 +1316,11 @@ mac_lomac_netinet_fragment(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(fraglabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, +lomac_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *source, *dest; @@ -1339,22 +1328,22 @@ mac_lomac_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, source = SLOT(inplabel); dest = SLOT(mlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, +lomac_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *dest; dest = SLOT(mlabel); - mac_lomac_set_single(dest, MAC_LOMAC_TYPE_EQUAL, 0); + lomac_set_single(dest, MAC_LOMAC_TYPE_EQUAL, 0); } static void -mac_lomac_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, +lomac_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *source, *dest; @@ -1362,11 +1351,11 @@ mac_lomac_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, source = SLOT(dlabel); dest = SLOT(mlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, +lomac_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *source, *dest; @@ -1374,11 +1363,11 @@ mac_lomac_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, source = SLOT(ifplabel); dest = SLOT(mlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, +lomac_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, struct ifnet *ifp, struct label *ifplabel, struct mbuf *mnew, struct label *mnewlabel) { @@ -1387,11 +1376,11 @@ mac_lomac_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(mnewlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, +lomac_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, struct mbuf *mnew, struct label *mnewlabel) { struct mac_lomac *source, *dest; @@ -1399,11 +1388,11 @@ mac_lomac_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(mnewlabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static int -mac_lomac_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +lomac_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { struct mac_lomac *a, *b; @@ -1411,11 +1400,11 @@ mac_lomac_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, a = SLOT(ipqlabel); b = SLOT(mlabel); - return (mac_lomac_equal_single(a, b)); + return (lomac_equal_single(a, b)); } static void -mac_lomac_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, +lomac_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, struct label *ifplabel, struct label *newlabel) { struct mac_lomac *source, *dest; @@ -1427,7 +1416,7 @@ mac_lomac_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, } static void -mac_lomac_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +lomac_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { @@ -1435,7 +1424,7 @@ mac_lomac_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, } static void -mac_lomac_inpcb_sosetlabel(struct socket *so, struct label *solabel, +lomac_inpcb_sosetlabel(struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel) { struct mac_lomac *source, *dest; @@ -1443,46 +1432,46 @@ mac_lomac_inpcb_sosetlabel(struct socket *so, struct label *solabel, source = SLOT(solabel); dest = SLOT(inplabel); - mac_lomac_copy_single(source, dest); + lomac_copy_single(source, dest); } static void -mac_lomac_init_syncache_from_inpcb(struct label *label, struct inpcb *inp) +lomac_init_syncache_from_inpcb(struct label *label, struct inpcb *inp) { struct mac_lomac *source, *dest; source = SLOT(inp->inp_label); dest = SLOT(label); - mac_lomac_copy(source, dest); + lomac_copy(source, dest); } static void -mac_lomac_create_mbuf_from_syncache(struct label *sc_label, struct mbuf *m, +lomac_create_mbuf_from_syncache(struct label *sc_label, struct mbuf *m, struct label *mlabel) { struct mac_lomac *source, *dest; source = SLOT(sc_label); dest = SLOT(mlabel); - mac_lomac_copy(source, dest); + lomac_copy(source, dest); } static void -mac_lomac_mbuf_create_from_firewall(struct mbuf *m, struct label *mlabel) +lomac_mbuf_create_from_firewall(struct mbuf *m, struct label *mlabel) { struct mac_lomac *dest; dest = SLOT(mlabel); /* XXX: where is the label for the firewall really comming from? */ - mac_lomac_set_single(dest, MAC_LOMAC_TYPE_EQUAL, 0); + lomac_set_single(dest, MAC_LOMAC_TYPE_EQUAL, 0); } /* * Labeling event operations: processes. */ static void -mac_lomac_vnode_execve_transition(struct ucred *old, struct ucred *new, +lomac_vnode_execve_transition(struct ucred *old, struct ucred *new, struct vnode *vp, struct label *vplabel, struct label *interpvplabel, struct image_params *imgp, struct label *execlabel) { @@ -1493,38 +1482,37 @@ mac_lomac_vnode_execve_transition(struct ucred *old, struct ucred *new, obj = SLOT(vplabel); robj = interpvplabel != NULL ? SLOT(interpvplabel) : obj; - mac_lomac_copy(source, dest); + lomac_copy(source, dest); /* - * If there's an auxiliary label on the real object, respect it - * and assume that this level should be assumed immediately if - * a higher level is currently in place. + * If there's an auxiliary label on the real object, respect it and + * assume that this level should be assumed immediately if a higher + * level is currently in place. */ if (robj->ml_flags & MAC_LOMAC_FLAG_AUX && - !mac_lomac_dominate_element(&robj->ml_auxsingle, &dest->ml_single) - && mac_lomac_auxsingle_in_range(robj, dest)) - mac_lomac_set_single(dest, robj->ml_auxsingle.mle_type, + !lomac_dominate_element(&robj->ml_auxsingle, &dest->ml_single) + && lomac_auxsingle_in_range(robj, dest)) + lomac_set_single(dest, robj->ml_auxsingle.mle_type, robj->ml_auxsingle.mle_grade); /* - * Restructuring to use the execve transitioning mechanism - * instead of the normal demotion mechanism here would be - * difficult, so just copy the label over and perform standard - * demotion. This is also non-optimal because it will result - * in the intermediate label "new" being created and immediately - * recycled. + * Restructuring to use the execve transitioning mechanism instead of + * the normal demotion mechanism here would be difficult, so just + * copy the label over and perform standard demotion. This is also + * non-optimal because it will result in the intermediate label "new" + * being created and immediately recycled. */ - if (mac_lomac_enabled && revocation_enabled && - !mac_lomac_dominate_single(obj, source)) + if (lomac_enabled && revocation_enabled && + !lomac_dominate_single(obj, source)) (void)maybe_demote(source, obj, "executing", "file", vp); } static int -mac_lomac_vnode_execve_will_transition(struct ucred *old, struct vnode *vp, +lomac_vnode_execve_will_transition(struct ucred *old, struct vnode *vp, struct label *vplabel, struct label *interpvplabel, struct image_params *imgp, struct label *execlabel) { struct mac_lomac *subj, *obj, *robj; - if (!mac_lomac_enabled || !revocation_enabled) + if (!lomac_enabled || !revocation_enabled) return (0); subj = SLOT(old->cr_label); @@ -1532,37 +1520,35 @@ mac_lomac_vnode_execve_will_transition(struct ucred *old, struct vnode *vp, robj = interpvplabel != NULL ? SLOT(interpvplabel) : obj; return ((robj->ml_flags & MAC_LOMAC_FLAG_AUX && - !mac_lomac_dominate_element(&robj->ml_auxsingle, &subj->ml_single) - && mac_lomac_auxsingle_in_range(robj, subj)) || - !mac_lomac_dominate_single(obj, subj)); + !lomac_dominate_element(&robj->ml_auxsingle, &subj->ml_single) + && lomac_auxsingle_in_range(robj, subj)) || + !lomac_dominate_single(obj, subj)); } static void -mac_lomac_proc_create_swapper(struct ucred *cred) +lomac_proc_create_swapper(struct ucred *cred) { struct mac_lomac *dest; dest = SLOT(cred->cr_label); - mac_lomac_set_single(dest, MAC_LOMAC_TYPE_EQUAL, 0); - mac_lomac_set_range(dest, MAC_LOMAC_TYPE_LOW, 0, MAC_LOMAC_TYPE_HIGH, - 0); + lomac_set_single(dest, MAC_LOMAC_TYPE_EQUAL, 0); + lomac_set_range(dest, MAC_LOMAC_TYPE_LOW, 0, MAC_LOMAC_TYPE_HIGH, 0); } static void -mac_lomac_proc_create_init(struct ucred *cred) +lomac_proc_create_init(struct ucred *cred) { struct mac_lomac *dest; dest = SLOT(cred->cr_label); - mac_lomac_set_single(dest, MAC_LOMAC_TYPE_HIGH, 0); - mac_lomac_set_range(dest, MAC_LOMAC_TYPE_LOW, 0, MAC_LOMAC_TYPE_HIGH, - 0); + lomac_set_single(dest, MAC_LOMAC_TYPE_HIGH, 0); + lomac_set_range(dest, MAC_LOMAC_TYPE_LOW, 0, MAC_LOMAC_TYPE_HIGH, 0); } static void -mac_lomac_cred_relabel(struct ucred *cred, struct label *newlabel) +lomac_cred_relabel(struct ucred *cred, struct label *newlabel) { struct mac_lomac *source, *dest; @@ -1576,24 +1562,24 @@ mac_lomac_cred_relabel(struct ucred *cred, struct label *newlabel) * Access control checks. */ static int -mac_lomac_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, +lomac_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, struct ifnet *ifp, struct label *ifplabel) { struct mac_lomac *a, *b; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); a = SLOT(dlabel); b = SLOT(ifplabel); - if (mac_lomac_equal_single(a, b)) + if (lomac_equal_single(a, b)) return (0); return (EACCES); } static int -mac_lomac_cred_check_relabel(struct ucred *cred, struct label *newlabel) +lomac_cred_check_relabel(struct ucred *cred, struct label *newlabel) { struct mac_lomac *subj, *new; int error; @@ -1602,8 +1588,8 @@ mac_lomac_cred_check_relabel(struct ucred *cred, struct label *newlabel) new = SLOT(newlabel); /* - * If there is a LOMAC label update for the credential, it may - * be an update of the single, range, or both. + * If there is a LOMAC label update for the credential, it may be an + * update of the single, range, or both. */ error = lomac_atmostflags(new, MAC_LOMAC_FLAGS_BOTH); if (error) @@ -1617,41 +1603,38 @@ mac_lomac_cred_check_relabel(struct ucred *cred, struct label *newlabel) * Fill in the missing parts from the previous label. */ if ((new->ml_flags & MAC_LOMAC_FLAG_SINGLE) == 0) - mac_lomac_copy_single(subj, new); + lomac_copy_single(subj, new); if ((new->ml_flags & MAC_LOMAC_FLAG_RANGE) == 0) - mac_lomac_copy_range(subj, new); + lomac_copy_range(subj, new); /* - * To change the LOMAC range on a credential, the new - * range label must be in the current range. + * To change the LOMAC range on a credential, the new range + * label must be in the current range. */ - if (!mac_lomac_range_in_range(new, subj)) + if (!lomac_range_in_range(new, subj)) return (EPERM); /* - * To change the LOMAC single label on a credential, the - * new single label must be in the new range. Implicitly - * from the previous check, the new single is in the old - * range. + * To change the LOMAC single label on a credential, the new + * single label must be in the new range. Implicitly from + * the previous check, the new single is in the old range. */ - if (!mac_lomac_single_in_range(new, new)) + if (!lomac_single_in_range(new, new)) return (EPERM); /* - * To have EQUAL in any component of the new credential - * LOMAC label, the subject must already have EQUAL in - * their label. + * To have EQUAL in any component of the new credential LOMAC + * label, the subject must already have EQUAL in their label. */ - if (mac_lomac_contains_equal(new)) { - error = mac_lomac_subject_privileged(subj); + if (lomac_contains_equal(new)) { + error = lomac_subject_privileged(subj); if (error) return (error); } /* - * XXXMAC: Additional consistency tests regarding the - * single and range of the new label might be performed - * here. + * XXXMAC: Additional consistency tests regarding the single + * and range of the new label might be performed here. */ } @@ -1659,25 +1642,25 @@ mac_lomac_cred_check_relabel(struct ucred *cred, struct label *newlabel) } static int -mac_lomac_cred_check_visible(struct ucred *cr1, struct ucred *cr2) +lomac_cred_check_visible(struct ucred *cr1, struct ucred *cr2) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cr1->cr_label); obj = SLOT(cr2->cr_label); /* XXX: range */ - if (!mac_lomac_dominate_single(obj, subj)) + if (!lomac_dominate_single(obj, subj)) return (ESRCH); return (0); } static int -mac_lomac_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, +lomac_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, struct label *ifplabel, struct label *newlabel) { struct mac_lomac *subj, *new; @@ -1687,8 +1670,8 @@ mac_lomac_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, new = SLOT(newlabel); /* - * If there is a LOMAC label update for the interface, it may - * be an update of the single, range, or both. + * If there is a LOMAC label update for the interface, it may be an + * update of the single, range, or both. */ error = lomac_atmostflags(new, MAC_LOMAC_FLAGS_BOTH); if (error) @@ -1697,7 +1680,7 @@ mac_lomac_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, /* * Relabling network interfaces requires LOMAC privilege. */ - error = mac_lomac_subject_privileged(subj); + error = lomac_subject_privileged(subj); if (error) return (error); @@ -1709,9 +1692,9 @@ mac_lomac_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, * Fill in the missing parts from the previous label. */ if ((new->ml_flags & MAC_LOMAC_FLAG_SINGLE) == 0) - mac_lomac_copy_single(subj, new); + lomac_copy_single(subj, new); if ((new->ml_flags & MAC_LOMAC_FLAG_RANGE) == 0) - mac_lomac_copy_range(subj, new); + lomac_copy_range(subj, new); /* * Rely on the traditional superuser status for the LOMAC @@ -1734,62 +1717,62 @@ mac_lomac_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, } static int -mac_lomac_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, +lomac_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *p, *i; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); p = SLOT(mlabel); i = SLOT(ifplabel); - return (mac_lomac_single_in_range(p, i) ? 0 : EACCES); + return (lomac_single_in_range(p, i) ? 0 : EACCES); } static int -mac_lomac_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, +lomac_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *p, *i; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); p = SLOT(mlabel); i = SLOT(inplabel); - return (mac_lomac_equal_single(p, i) ? 0 : EACCES); + return (lomac_equal_single(p, i) ? 0 : EACCES); } static int -mac_lomac_kld_check_load(struct ucred *cred, struct vnode *vp, +lomac_kld_check_load(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (mac_lomac_subject_privileged(subj)) + if (lomac_subject_privileged(subj)) return (EPERM); - if (!mac_lomac_high_single(obj)) + if (!lomac_high_single(obj)) return (EACCES); return (0); } static int -mac_lomac_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, +lomac_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, struct label *pplabel, unsigned long cmd, void /* caddr_t */ *data) { - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); /* XXX: This will be implemented soon... */ @@ -1798,25 +1781,25 @@ mac_lomac_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, } static int -mac_lomac_pipe_check_read(struct ucred *cred, struct pipepair *pp, +lomac_pipe_check_read(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_lomac_dominate_single(obj, subj)) + if (!lomac_dominate_single(obj, subj)) return (maybe_demote(subj, obj, "reading", "pipe", NULL)); return (0); } static int -mac_lomac_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, +lomac_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, struct label *pplabel, struct label *newlabel) { struct mac_lomac *subj, *obj, *new; @@ -1827,8 +1810,8 @@ mac_lomac_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, obj = SLOT(pplabel); /* - * If there is a LOMAC label update for a pipe, it must be a - * single update. + * If there is a LOMAC label update for a pipe, it must be a single + * update. */ error = lomac_atmostflags(new, MAC_LOMAC_FLAG_SINGLE); if (error) @@ -1838,7 +1821,7 @@ mac_lomac_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, * To perform a relabel of a pipe (LOMAC label or not), LOMAC must * authorize the relabel. */ - if (!mac_lomac_single_in_range(obj, subj)) + if (!lomac_single_in_range(obj, subj)) return (EPERM); /* @@ -1849,15 +1832,15 @@ mac_lomac_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, * To change the LOMAC label on a pipe, the new pipe label * must be in the subject range. */ - if (!mac_lomac_single_in_range(new, subj)) + if (!lomac_single_in_range(new, subj)) return (EPERM); /* * To change the LOMAC label on a pipe to be EQUAL, the * subject must have appropriate privilege. */ - if (mac_lomac_contains_equal(new)) { - error = mac_lomac_subject_privileged(subj); + if (lomac_contains_equal(new)) { + error = lomac_subject_privileged(subj); if (error) return (error); } @@ -1867,100 +1850,100 @@ mac_lomac_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, } static int -mac_lomac_pipe_check_write(struct ucred *cred, struct pipepair *pp, +lomac_pipe_check_write(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_proc_check_debug(struct ucred *cred, struct proc *p) +lomac_proc_check_debug(struct ucred *cred, struct proc *p) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_lomac_dominate_single(obj, subj)) + if (!lomac_dominate_single(obj, subj)) return (ESRCH); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_proc_check_sched(struct ucred *cred, struct proc *p) +lomac_proc_check_sched(struct ucred *cred, struct proc *p) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_lomac_dominate_single(obj, subj)) + if (!lomac_dominate_single(obj, subj)) return (ESRCH); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_proc_check_signal(struct ucred *cred, struct proc *p, int signum) +lomac_proc_check_signal(struct ucred *cred, struct proc *p, int signum) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_lomac_dominate_single(obj, subj)) + if (!lomac_dominate_single(obj, subj)) return (ESRCH); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_socket_check_deliver(struct socket *so, struct label *solabel, +lomac_socket_check_deliver(struct socket *so, struct label *solabel, struct mbuf *m, struct label *mlabel) { struct mac_lomac *p, *s; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); p = SLOT(mlabel); s = SLOT(solabel); - return (mac_lomac_equal_single(p, s) ? 0 : EACCES); + return (lomac_equal_single(p, s) ? 0 : EACCES); } static int -mac_lomac_socket_check_relabel(struct ucred *cred, struct socket *so, +lomac_socket_check_relabel(struct ucred *cred, struct socket *so, struct label *solabel, struct label *newlabel) { struct mac_lomac *subj, *obj, *new; @@ -1971,8 +1954,8 @@ mac_lomac_socket_check_relabel(struct ucred *cred, struct socket *so, obj = SLOT(solabel); /* - * If there is a LOMAC label update for the socket, it may be - * an update of single. + * If there is a LOMAC label update for the socket, it may be an + * update of single. */ error = lomac_atmostflags(new, MAC_LOMAC_FLAG_SINGLE); if (error) @@ -1982,7 +1965,7 @@ mac_lomac_socket_check_relabel(struct ucred *cred, struct socket *so, * To relabel a socket, the old socket single must be in the subject * range. */ - if (!mac_lomac_single_in_range(obj, subj)) + if (!lomac_single_in_range(obj, subj)) return (EPERM); /* @@ -1990,18 +1973,18 @@ mac_lomac_socket_check_relabel(struct ucred *cred, struct socket *so, */ if (new->ml_flags & MAC_LOMAC_FLAG_SINGLE) { /* - * To relabel a socket, the new socket single must be in - * the subject range. + * To relabel a socket, the new socket single must be in the + * subject range. */ - if (!mac_lomac_single_in_range(new, subj)) + if (!lomac_single_in_range(new, subj)) return (EPERM); /* * To change the LOMAC label on the socket to contain EQUAL, * the subject must have appropriate privilege. */ - if (mac_lomac_contains_equal(new)) { - error = mac_lomac_subject_privileged(subj); + if (lomac_contains_equal(new)) { + error = lomac_subject_privileged(subj); if (error) return (error); } @@ -2011,18 +1994,18 @@ mac_lomac_socket_check_relabel(struct ucred *cred, struct socket *so, } static int -mac_lomac_socket_check_visible(struct ucred *cred, struct socket *so, +lomac_socket_check_visible(struct ucred *cred, struct socket *so, struct label *solabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(solabel); - if (!mac_lomac_dominate_single(obj, subj)) + if (!lomac_dominate_single(obj, subj)) return (ENOENT); return (0); @@ -2034,12 +2017,12 @@ mac_lomac_socket_check_visible(struct ucred *cred, struct socket *so, * policy as they might otherwise allow bypassing of the integrity policy. */ static int -mac_lomac_priv_check(struct ucred *cred, int priv) +lomac_priv_check(struct ucred *cred, int priv) { struct mac_lomac *subj; int error; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); /* @@ -2210,7 +2193,7 @@ mac_lomac_priv_check(struct ucred *cred, int priv) */ default: subj = SLOT(cred->cr_label); - error = mac_lomac_subject_privileged(subj); + error = lomac_subject_privileged(subj); if (error) return (error); } @@ -2219,107 +2202,107 @@ mac_lomac_priv_check(struct ucred *cred, int priv) static int -mac_lomac_system_check_acct(struct ucred *cred, struct vnode *vp, +lomac_system_check_acct(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (mac_lomac_subject_privileged(subj)) + if (lomac_subject_privileged(subj)) return (EPERM); - if (!mac_lomac_high_single(obj)) + if (!lomac_high_single(obj)) return (EACCES); return (0); } static int -mac_lomac_system_check_auditctl(struct ucred *cred, struct vnode *vp, +lomac_system_check_auditctl(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (mac_lomac_subject_privileged(subj)) + if (lomac_subject_privileged(subj)) return (EPERM); - if (!mac_lomac_high_single(obj)) + if (!lomac_high_single(obj)) return (EACCES); return (0); } static int -mac_lomac_system_check_swapoff(struct ucred *cred, struct vnode *vp, +lomac_system_check_swapoff(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_lomac *subj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); - if (mac_lomac_subject_privileged(subj)) + if (lomac_subject_privileged(subj)) return (EPERM); return (0); } static int -mac_lomac_system_check_swapon(struct ucred *cred, struct vnode *vp, +lomac_system_check_swapon(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (mac_lomac_subject_privileged(subj)) + if (lomac_subject_privileged(subj)) return (EPERM); - if (!mac_lomac_high_single(obj)) + if (!lomac_high_single(obj)) return (EACCES); return (0); } static int -mac_lomac_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, +lomac_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req) { struct mac_lomac *subj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); /* - * Treat sysctl variables without CTLFLAG_ANYBODY flag as - * lomac/high, but also require privilege to change them. + * Treat sysctl variables without CTLFLAG_ANYBODY flag as lomac/high, + * but also require privilege to change them. */ if (req->newptr != NULL && (oidp->oid_kind & CTLFLAG_ANYBODY) == 0) { #ifdef notdef - if (!mac_lomac_subject_dominate_high(subj)) + if (!lomac_subject_dominate_high(subj)) return (EACCES); #endif - if (mac_lomac_subject_privileged(subj)) + if (lomac_subject_privileged(subj)) return (EPERM); } @@ -2327,70 +2310,70 @@ mac_lomac_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, } static int -mac_lomac_vnode_check_create(struct ucred *cred, struct vnode *dvp, +lomac_vnode_check_create(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp, struct vattr *vap) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); if (obj->ml_flags & MAC_LOMAC_FLAG_AUX && - !mac_lomac_dominate_element(&subj->ml_single, &obj->ml_auxsingle)) + !lomac_dominate_element(&subj->ml_single, &obj->ml_auxsingle)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_link(struct ucred *cred, struct vnode *dvp, +lomac_vnode_check_link(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_mmap(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_mmap(struct ucred *cred, struct vnode *vp, struct label *vplabel, int prot, int flags) { struct mac_lomac *subj, *obj; @@ -2399,18 +2382,18 @@ mac_lomac_vnode_check_mmap(struct ucred *cred, struct vnode *vp, * Rely on the use of open()-time protections to handle * non-revocation cases. */ - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); if (((prot & VM_PROT_WRITE) != 0) && ((flags & MAP_SHARED) != 0)) { - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); } if (prot & (VM_PROT_READ | VM_PROT_EXECUTE)) { - if (!mac_lomac_dominate_single(obj, subj)) + if (!lomac_dominate_single(obj, subj)) return (maybe_demote(subj, obj, "mapping", "file", vp)); } @@ -2418,7 +2401,7 @@ mac_lomac_vnode_check_mmap(struct ucred *cred, struct vnode *vp, } static void -mac_lomac_vnode_check_mmap_downgrade(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_mmap_downgrade(struct ucred *cred, struct vnode *vp, struct label *vplabel, /* XXX vm_prot_t */ int *prot) { struct mac_lomac *subj, *obj; @@ -2427,23 +2410,23 @@ mac_lomac_vnode_check_mmap_downgrade(struct ucred *cred, struct vnode *vp, * Rely on the use of open()-time protections to handle * non-revocation cases. */ - if (!mac_lomac_enabled || !revocation_enabled) + if (!lomac_enabled || !revocation_enabled) return; subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) *prot &= ~VM_PROT_WRITE; } static int -mac_lomac_vnode_check_open(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_open(struct ucred *cred, struct vnode *vp, struct label *vplabel, int acc_mode) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); @@ -2451,7 +2434,7 @@ mac_lomac_vnode_check_open(struct ucred *cred, struct vnode *vp, /* XXX privilege override for admin? */ if (acc_mode & (VWRITE | VAPPEND | VADMIN)) { - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); } @@ -2459,25 +2442,25 @@ mac_lomac_vnode_check_open(struct ucred *cred, struct vnode *vp, } static int -mac_lomac_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, +lomac_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled || !revocation_enabled) + if (!lomac_enabled || !revocation_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_dominate_single(obj, subj)) + if (!lomac_dominate_single(obj, subj)) return (maybe_demote(subj, obj, "reading", "file", vp)); return (0); } static int -mac_lomac_vnode_check_relabel(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_relabel(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *newlabel) { struct mac_lomac *old, *new, *subj; @@ -2500,7 +2483,7 @@ mac_lomac_vnode_check_relabel(struct ucred *cred, struct vnode *vp, * To perform a relabel of the vnode (LOMAC label or not), LOMAC must * authorize the relabel. */ - if (!mac_lomac_single_in_range(old, subj)) + if (!lomac_single_in_range(old, subj)) return (EPERM); /* @@ -2511,15 +2494,15 @@ mac_lomac_vnode_check_relabel(struct ucred *cred, struct vnode *vp, * To change the LOMAC label on a vnode, the new vnode label * must be in the subject range. */ - if (!mac_lomac_single_in_range(new, subj)) + if (!lomac_single_in_range(new, subj)) return (EPERM); /* - * To change the LOMAC label on the vnode to be EQUAL, - * the subject must have appropriate privilege. + * To change the LOMAC label on the vnode to be EQUAL, the + * subject must have appropriate privilege. */ - if (mac_lomac_contains_equal(new)) { - error = mac_lomac_subject_privileged(subj); + if (lomac_contains_equal(new)) { + error = lomac_subject_privileged(subj); if (error) return (error); } @@ -2529,21 +2512,21 @@ mac_lomac_vnode_check_relabel(struct ucred *cred, struct vnode *vp, * Fill in the missing parts from the previous label. */ if ((new->ml_flags & MAC_LOMAC_FLAG_SINGLE) == 0) - mac_lomac_copy_single(subj, new); + lomac_copy_single(subj, new); /* * To change the auxiliary LOMAC label on a vnode, the new * vnode label must be in the subject range. */ - if (!mac_lomac_auxsingle_in_range(new, subj)) + if (!lomac_auxsingle_in_range(new, subj)) return (EPERM); /* * To change the auxiliary LOMAC label on the vnode to be * EQUAL, the subject must have appropriate privilege. */ - if (mac_lomac_contains_equal(new)) { - error = mac_lomac_subject_privileged(subj); + if (lomac_contains_equal(new)) { + error = lomac_subject_privileged(subj); if (error) return (error); } @@ -2553,49 +2536,49 @@ mac_lomac_vnode_check_relabel(struct ucred *cred, struct vnode *vp, } static int -mac_lomac_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, +lomac_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, +lomac_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, int samedir, struct componentname *cnp) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); if (vp != NULL) { obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); } @@ -2603,55 +2586,55 @@ mac_lomac_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, } static int -mac_lomac_vnode_check_revoke(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_revoke(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_setacl(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_setacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type, struct acl *acl) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); /* XXX: protect the MAC EA in a special way? */ @@ -2660,121 +2643,121 @@ mac_lomac_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, } static int -mac_lomac_vnode_check_setflags(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_setflags(struct ucred *cred, struct vnode *vp, struct label *vplabel, u_long flags) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_setmode(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_setmode(struct ucred *cred, struct vnode *vp, struct label *vplabel, mode_t mode) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_setowner(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_setowner(struct ucred *cred, struct vnode *vp, struct label *vplabel, uid_t uid, gid_t gid) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, +lomac_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct timespec atime, struct timespec mtime) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, +lomac_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled) + if (!lomac_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static int -mac_lomac_vnode_check_write(struct ucred *active_cred, +lomac_vnode_check_write(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_lomac *subj, *obj; - if (!mac_lomac_enabled || !revocation_enabled) + if (!lomac_enabled || !revocation_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_lomac_subject_dominate(subj, obj)) + if (!lomac_subject_dominate(subj, obj)) return (EACCES); return (0); } static void -mac_lomac_thread_userret(struct thread *td) +lomac_thread_userret(struct thread *td) { struct proc *p = td->td_proc; struct mac_lomac_proc *subj = PSLOT(p->p_label); @@ -2788,8 +2771,8 @@ mac_lomac_thread_userret(struct thread *td) newcred = crget(); /* * Prevent a lock order reversal in - * mac_cred_mmapped_drop_perms; ideally, the other - * user of subj->mtx wouldn't be holding Giant. + * mac_cred_mmapped_drop_perms; ideally, the other user of + * subj->mtx wouldn't be holding Giant. */ mtx_lock(&Giant); PROC_LOCK(p); @@ -2804,7 +2787,7 @@ mac_lomac_thread_userret(struct thread *td) oldcred = p->p_ucred; crcopy(newcred, oldcred); crhold(newcred); - mac_lomac_copy(&subj->mac_lomac, SLOT(newcred->cr_label)); + lomac_copy(&subj->mac_lomac, SLOT(newcred->cr_label)); p->p_ucred = newcred; crfree(oldcred); dodrop = 1; @@ -2819,147 +2802,144 @@ mac_lomac_thread_userret(struct thread *td) } } -static struct mac_policy_ops mac_lomac_ops = -{ - .mpo_init = mac_lomac_init, - .mpo_bpfdesc_init_label = mac_lomac_init_label, - .mpo_cred_init_label = mac_lomac_init_label, - .mpo_devfs_init_label = mac_lomac_init_label, - .mpo_ifnet_init_label = mac_lomac_init_label, - .mpo_init_syncache_label = mac_lomac_init_label_waitcheck, - .mpo_inpcb_init_label = mac_lomac_init_label_waitcheck, - .mpo_ipq_init_label = mac_lomac_init_label_waitcheck, - .mpo_mbuf_init_label = mac_lomac_init_label_waitcheck, - .mpo_mount_init_label = mac_lomac_init_label, - .mpo_pipe_init_label = mac_lomac_init_label, - .mpo_proc_init_label = mac_lomac_proc_init_label, - .mpo_socket_init_label = mac_lomac_init_label_waitcheck, - .mpo_socketpeer_init_label = mac_lomac_init_label_waitcheck, - .mpo_vnode_init_label = mac_lomac_init_label, - .mpo_init_syncache_from_inpcb = mac_lomac_init_syncache_from_inpcb, - .mpo_bpfdesc_destroy_label = mac_lomac_destroy_label, - .mpo_cred_destroy_label = mac_lomac_destroy_label, - .mpo_devfs_destroy_label = mac_lomac_destroy_label, - .mpo_ifnet_destroy_label = mac_lomac_destroy_label, - .mpo_inpcb_destroy_label = mac_lomac_destroy_label, - .mpo_ipq_destroy_label = mac_lomac_destroy_label, - .mpo_mbuf_destroy_label = mac_lomac_destroy_label, - .mpo_mount_destroy_label = mac_lomac_destroy_label, - .mpo_pipe_destroy_label = mac_lomac_destroy_label, - .mpo_proc_destroy_label = mac_lomac_proc_destroy_label, - .mpo_destroy_syncache_label = mac_lomac_destroy_label, - .mpo_socket_destroy_label = mac_lomac_destroy_label, - .mpo_socketpeer_destroy_label = mac_lomac_destroy_label, - .mpo_vnode_destroy_label = mac_lomac_destroy_label, - .mpo_cred_copy_label = mac_lomac_copy_label, - .mpo_ifnet_copy_label = mac_lomac_copy_label, - .mpo_mbuf_copy_label = mac_lomac_copy_label, - .mpo_pipe_copy_label = mac_lomac_copy_label, - .mpo_socket_copy_label = mac_lomac_copy_label, - .mpo_vnode_copy_label = mac_lomac_copy_label, - .mpo_cred_externalize_label = mac_lomac_externalize_label, - .mpo_ifnet_externalize_label = mac_lomac_externalize_label, - .mpo_pipe_externalize_label = mac_lomac_externalize_label, - .mpo_socket_externalize_label = mac_lomac_externalize_label, - .mpo_socketpeer_externalize_label = mac_lomac_externalize_label, - .mpo_vnode_externalize_label = mac_lomac_externalize_label, - .mpo_cred_internalize_label = mac_lomac_internalize_label, - .mpo_ifnet_internalize_label = mac_lomac_internalize_label, - .mpo_pipe_internalize_label = mac_lomac_internalize_label, - .mpo_socket_internalize_label = mac_lomac_internalize_label, - .mpo_vnode_internalize_label = mac_lomac_internalize_label, - .mpo_devfs_create_device = mac_lomac_devfs_create_device, - .mpo_devfs_create_directory = mac_lomac_devfs_create_directory, - .mpo_devfs_create_symlink = mac_lomac_devfs_create_symlink, - .mpo_mount_create = mac_lomac_mount_create, - .mpo_vnode_relabel = mac_lomac_vnode_relabel, - .mpo_devfs_update = mac_lomac_devfs_update, - .mpo_devfs_vnode_associate = mac_lomac_devfs_vnode_associate, - .mpo_vnode_associate_extattr = mac_lomac_vnode_associate_extattr, - .mpo_vnode_associate_singlelabel = - mac_lomac_vnode_associate_singlelabel, - .mpo_vnode_create_extattr = mac_lomac_vnode_create_extattr, - .mpo_vnode_setlabel_extattr = mac_lomac_vnode_setlabel_extattr, - .mpo_socket_create_mbuf = mac_lomac_socket_create_mbuf, - .mpo_create_mbuf_from_syncache = mac_lomac_create_mbuf_from_syncache, - .mpo_pipe_create = mac_lomac_pipe_create, - .mpo_socket_create = mac_lomac_socket_create, - .mpo_socket_newconn = mac_lomac_socket_newconn, - .mpo_pipe_relabel = mac_lomac_pipe_relabel, - .mpo_socket_relabel = mac_lomac_socket_relabel, - .mpo_socketpeer_set_from_mbuf = mac_lomac_socketpeer_set_from_mbuf, - .mpo_socketpeer_set_from_socket = - mac_lomac_socketpeer_set_from_socket, - .mpo_bpfdesc_create = mac_lomac_bpfdesc_create, - .mpo_ipq_reassemble = mac_lomac_ipq_reassemble, - .mpo_netinet_fragment = mac_lomac_netinet_fragment, - .mpo_ifnet_create = mac_lomac_ifnet_create, - .mpo_inpcb_create = mac_lomac_inpcb_create, - .mpo_ipq_create = mac_lomac_ipq_create, - .mpo_inpcb_create_mbuf = mac_lomac_inpcb_create_mbuf, - .mpo_create_mbuf_linklayer = mac_lomac_create_mbuf_linklayer, - .mpo_bpfdesc_create_mbuf = mac_lomac_bpfdesc_create_mbuf, - .mpo_ifnet_create_mbuf = mac_lomac_ifnet_create_mbuf, - .mpo_mbuf_create_multicast_encap = - mac_lomac_mbuf_create_multicast_encap, - .mpo_mbuf_create_netlayer = mac_lomac_mbuf_create_netlayer, - .mpo_ipq_match = mac_lomac_ipq_match, - .mpo_ifnet_relabel = mac_lomac_ifnet_relabel, - .mpo_ipq_update = mac_lomac_ipq_update, - .mpo_inpcb_sosetlabel = mac_lomac_inpcb_sosetlabel, - .mpo_vnode_execve_transition = mac_lomac_vnode_execve_transition, +static struct mac_policy_ops lomac_ops = +{ + .mpo_init = lomac_init, + .mpo_bpfdesc_init_label = lomac_init_label, + .mpo_cred_init_label = lomac_init_label, + .mpo_devfs_init_label = lomac_init_label, + .mpo_ifnet_init_label = lomac_init_label, + .mpo_init_syncache_label = lomac_init_label_waitcheck, + .mpo_inpcb_init_label = lomac_init_label_waitcheck, + .mpo_ipq_init_label = lomac_init_label_waitcheck, + .mpo_mbuf_init_label = lomac_init_label_waitcheck, + .mpo_mount_init_label = lomac_init_label, + .mpo_pipe_init_label = lomac_init_label, + .mpo_proc_init_label = lomac_proc_init_label, + .mpo_socket_init_label = lomac_init_label_waitcheck, + .mpo_socketpeer_init_label = lomac_init_label_waitcheck, + .mpo_vnode_init_label = lomac_init_label, + .mpo_init_syncache_from_inpcb = lomac_init_syncache_from_inpcb, + .mpo_bpfdesc_destroy_label = lomac_destroy_label, + .mpo_cred_destroy_label = lomac_destroy_label, + .mpo_devfs_destroy_label = lomac_destroy_label, + .mpo_ifnet_destroy_label = lomac_destroy_label, + .mpo_inpcb_destroy_label = lomac_destroy_label, + .mpo_ipq_destroy_label = lomac_destroy_label, + .mpo_mbuf_destroy_label = lomac_destroy_label, + .mpo_mount_destroy_label = lomac_destroy_label, + .mpo_pipe_destroy_label = lomac_destroy_label, + .mpo_proc_destroy_label = lomac_proc_destroy_label, + .mpo_destroy_syncache_label = lomac_destroy_label, + .mpo_socket_destroy_label = lomac_destroy_label, + .mpo_socketpeer_destroy_label = lomac_destroy_label, + .mpo_vnode_destroy_label = lomac_destroy_label, + .mpo_cred_copy_label = lomac_copy_label, + .mpo_ifnet_copy_label = lomac_copy_label, + .mpo_mbuf_copy_label = lomac_copy_label, + .mpo_pipe_copy_label = lomac_copy_label, + .mpo_socket_copy_label = lomac_copy_label, + .mpo_vnode_copy_label = lomac_copy_label, + .mpo_cred_externalize_label = lomac_externalize_label, + .mpo_ifnet_externalize_label = lomac_externalize_label, + .mpo_pipe_externalize_label = lomac_externalize_label, + .mpo_socket_externalize_label = lomac_externalize_label, + .mpo_socketpeer_externalize_label = lomac_externalize_label, + .mpo_vnode_externalize_label = lomac_externalize_label, + .mpo_cred_internalize_label = lomac_internalize_label, + .mpo_ifnet_internalize_label = lomac_internalize_label, + .mpo_pipe_internalize_label = lomac_internalize_label, + .mpo_socket_internalize_label = lomac_internalize_label, + .mpo_vnode_internalize_label = lomac_internalize_label, + .mpo_devfs_create_device = lomac_devfs_create_device, + .mpo_devfs_create_directory = lomac_devfs_create_directory, + .mpo_devfs_create_symlink = lomac_devfs_create_symlink, + .mpo_mount_create = lomac_mount_create, + .mpo_vnode_relabel = lomac_vnode_relabel, + .mpo_devfs_update = lomac_devfs_update, + .mpo_devfs_vnode_associate = lomac_devfs_vnode_associate, + .mpo_vnode_associate_extattr = lomac_vnode_associate_extattr, + .mpo_vnode_associate_singlelabel = lomac_vnode_associate_singlelabel, + .mpo_vnode_create_extattr = lomac_vnode_create_extattr, + .mpo_vnode_setlabel_extattr = lomac_vnode_setlabel_extattr, + .mpo_socket_create_mbuf = lomac_socket_create_mbuf, + .mpo_create_mbuf_from_syncache = lomac_create_mbuf_from_syncache, + .mpo_pipe_create = lomac_pipe_create, + .mpo_socket_create = lomac_socket_create, + .mpo_socket_newconn = lomac_socket_newconn, + .mpo_pipe_relabel = lomac_pipe_relabel, + .mpo_socket_relabel = lomac_socket_relabel, + .mpo_socketpeer_set_from_mbuf = lomac_socketpeer_set_from_mbuf, + .mpo_socketpeer_set_from_socket = lomac_socketpeer_set_from_socket, + .mpo_bpfdesc_create = lomac_bpfdesc_create, + .mpo_ipq_reassemble = lomac_ipq_reassemble, + .mpo_netinet_fragment = lomac_netinet_fragment, + .mpo_ifnet_create = lomac_ifnet_create, + .mpo_inpcb_create = lomac_inpcb_create, + .mpo_ipq_create = lomac_ipq_create, + .mpo_inpcb_create_mbuf = lomac_inpcb_create_mbuf, + .mpo_create_mbuf_linklayer = lomac_create_mbuf_linklayer, + .mpo_bpfdesc_create_mbuf = lomac_bpfdesc_create_mbuf, + .mpo_ifnet_create_mbuf = lomac_ifnet_create_mbuf, + .mpo_mbuf_create_multicast_encap = lomac_mbuf_create_multicast_encap, + .mpo_mbuf_create_netlayer = lomac_mbuf_create_netlayer, + .mpo_ipq_match = lomac_ipq_match, + .mpo_ifnet_relabel = lomac_ifnet_relabel, + .mpo_ipq_update = lomac_ipq_update, + .mpo_inpcb_sosetlabel = lomac_inpcb_sosetlabel, + .mpo_vnode_execve_transition = lomac_vnode_execve_transition, .mpo_vnode_execve_will_transition = - mac_lomac_vnode_execve_will_transition, - .mpo_proc_create_swapper = mac_lomac_proc_create_swapper, - .mpo_proc_create_init = mac_lomac_proc_create_init, - .mpo_cred_relabel = mac_lomac_cred_relabel, - .mpo_bpfdesc_check_receive = mac_lomac_bpfdesc_check_receive, - .mpo_cred_check_relabel = mac_lomac_cred_check_relabel, - .mpo_cred_check_visible = mac_lomac_cred_check_visible, - .mpo_ifnet_check_relabel = mac_lomac_ifnet_check_relabel, - .mpo_ifnet_check_transmit = mac_lomac_ifnet_check_transmit, - .mpo_inpcb_check_deliver = mac_lomac_inpcb_check_deliver, - .mpo_kld_check_load = mac_lomac_kld_check_load, - .mpo_pipe_check_ioctl = mac_lomac_pipe_check_ioctl, - .mpo_pipe_check_read = mac_lomac_pipe_check_read, - .mpo_pipe_check_relabel = mac_lomac_pipe_check_relabel, - .mpo_pipe_check_write = mac_lomac_pipe_check_write, - .mpo_proc_check_debug = mac_lomac_proc_check_debug, - .mpo_proc_check_sched = mac_lomac_proc_check_sched, - .mpo_proc_check_signal = mac_lomac_proc_check_signal, - .mpo_socket_check_deliver = mac_lomac_socket_check_deliver, - .mpo_socket_check_relabel = mac_lomac_socket_check_relabel, - .mpo_socket_check_visible = mac_lomac_socket_check_visible, - .mpo_system_check_acct = mac_lomac_system_check_acct, - .mpo_system_check_auditctl = mac_lomac_system_check_auditctl, - .mpo_system_check_swapoff = mac_lomac_system_check_swapoff, - .mpo_system_check_swapon = mac_lomac_system_check_swapon, - .mpo_system_check_sysctl = mac_lomac_system_check_sysctl, - .mpo_vnode_check_access = mac_lomac_vnode_check_open, - .mpo_vnode_check_create = mac_lomac_vnode_check_create, - .mpo_vnode_check_deleteacl = mac_lomac_vnode_check_deleteacl, - .mpo_vnode_check_link = mac_lomac_vnode_check_link, - .mpo_vnode_check_mmap = mac_lomac_vnode_check_mmap, - .mpo_vnode_check_mmap_downgrade = mac_lomac_vnode_check_mmap_downgrade, - .mpo_vnode_check_open = mac_lomac_vnode_check_open, - .mpo_vnode_check_read = mac_lomac_vnode_check_read, - .mpo_vnode_check_relabel = mac_lomac_vnode_check_relabel, - .mpo_vnode_check_rename_from = mac_lomac_vnode_check_rename_from, - .mpo_vnode_check_rename_to = mac_lomac_vnode_check_rename_to, - .mpo_vnode_check_revoke = mac_lomac_vnode_check_revoke, - .mpo_vnode_check_setacl = mac_lomac_vnode_check_setacl, - .mpo_vnode_check_setextattr = mac_lomac_vnode_check_setextattr, - .mpo_vnode_check_setflags = mac_lomac_vnode_check_setflags, - .mpo_vnode_check_setmode = mac_lomac_vnode_check_setmode, - .mpo_vnode_check_setowner = mac_lomac_vnode_check_setowner, - .mpo_vnode_check_setutimes = mac_lomac_vnode_check_setutimes, - .mpo_vnode_check_unlink = mac_lomac_vnode_check_unlink, - .mpo_vnode_check_write = mac_lomac_vnode_check_write, - .mpo_thread_userret = mac_lomac_thread_userret, - .mpo_mbuf_create_from_firewall = mac_lomac_mbuf_create_from_firewall, - .mpo_priv_check = mac_lomac_priv_check, + lomac_vnode_execve_will_transition, + .mpo_proc_create_swapper = lomac_proc_create_swapper, + .mpo_proc_create_init = lomac_proc_create_init, + .mpo_cred_relabel = lomac_cred_relabel, + .mpo_bpfdesc_check_receive = lomac_bpfdesc_check_receive, + .mpo_cred_check_relabel = lomac_cred_check_relabel, + .mpo_cred_check_visible = lomac_cred_check_visible, + .mpo_ifnet_check_relabel = lomac_ifnet_check_relabel, + .mpo_ifnet_check_transmit = lomac_ifnet_check_transmit, + .mpo_inpcb_check_deliver = lomac_inpcb_check_deliver, + .mpo_kld_check_load = lomac_kld_check_load, + .mpo_pipe_check_ioctl = lomac_pipe_check_ioctl, + .mpo_pipe_check_read = lomac_pipe_check_read, + .mpo_pipe_check_relabel = lomac_pipe_check_relabel, + .mpo_pipe_check_write = lomac_pipe_check_write, + .mpo_proc_check_debug = lomac_proc_check_debug, + .mpo_proc_check_sched = lomac_proc_check_sched, + .mpo_proc_check_signal = lomac_proc_check_signal, + .mpo_socket_check_deliver = lomac_socket_check_deliver, + .mpo_socket_check_relabel = lomac_socket_check_relabel, + .mpo_socket_check_visible = lomac_socket_check_visible, + .mpo_system_check_acct = lomac_system_check_acct, + .mpo_system_check_auditctl = lomac_system_check_auditctl, + .mpo_system_check_swapoff = lomac_system_check_swapoff, + .mpo_system_check_swapon = lomac_system_check_swapon, + .mpo_system_check_sysctl = lomac_system_check_sysctl, + .mpo_vnode_check_access = lomac_vnode_check_open, + .mpo_vnode_check_create = lomac_vnode_check_create, + .mpo_vnode_check_deleteacl = lomac_vnode_check_deleteacl, + .mpo_vnode_check_link = lomac_vnode_check_link, + .mpo_vnode_check_mmap = lomac_vnode_check_mmap, + .mpo_vnode_check_mmap_downgrade = lomac_vnode_check_mmap_downgrade, + .mpo_vnode_check_open = lomac_vnode_check_open, + .mpo_vnode_check_read = lomac_vnode_check_read, + .mpo_vnode_check_relabel = lomac_vnode_check_relabel, + .mpo_vnode_check_rename_from = lomac_vnode_check_rename_from, + .mpo_vnode_check_rename_to = lomac_vnode_check_rename_to, + .mpo_vnode_check_revoke = lomac_vnode_check_revoke, + .mpo_vnode_check_setacl = lomac_vnode_check_setacl, + .mpo_vnode_check_setextattr = lomac_vnode_check_setextattr, + .mpo_vnode_check_setflags = lomac_vnode_check_setflags, + .mpo_vnode_check_setmode = lomac_vnode_check_setmode, + .mpo_vnode_check_setowner = lomac_vnode_check_setowner, + .mpo_vnode_check_setutimes = lomac_vnode_check_setutimes, + .mpo_vnode_check_unlink = lomac_vnode_check_unlink, + .mpo_vnode_check_write = lomac_vnode_check_write, + .mpo_thread_userret = lomac_thread_userret, + .mpo_mbuf_create_from_firewall = lomac_mbuf_create_from_firewall, + .mpo_priv_check = lomac_priv_check, }; -MAC_POLICY_SET(&mac_lomac_ops, mac_lomac, "TrustedBSD MAC/LOMAC", +MAC_POLICY_SET(&lomac_ops, mac_lomac, "TrustedBSD MAC/LOMAC", MPC_LOADTIME_FLAG_NOTLATE | MPC_LOADTIME_FLAG_LABELMBUFS, - &mac_lomac_slot); + &lomac_slot); diff --git a/sys/security/mac_mls/mac_mls.c b/sys/security/mac_mls/mac_mls.c index ea62f3f..cfca2af 100644 --- a/sys/security/mac_mls/mac_mls.c +++ b/sys/security/mac_mls/mac_mls.c @@ -93,14 +93,14 @@ SYSCTL_DECL(_security_mac); SYSCTL_NODE(_security_mac, OID_AUTO, mls, CTLFLAG_RW, 0, "TrustedBSD mac_mls policy controls"); -static int mac_mls_label_size = sizeof(struct mac_mls); +static int mls_label_size = sizeof(struct mac_mls); SYSCTL_INT(_security_mac_mls, OID_AUTO, label_size, CTLFLAG_RD, - &mac_mls_label_size, 0, "Size of struct mac_mls"); + &mls_label_size, 0, "Size of struct mac_mls"); -static int mac_mls_enabled = 1; -SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RW, - &mac_mls_enabled, 0, "Enforce MAC/MLS policy"); -TUNABLE_INT("security.mac.mls.enabled", &mac_mls_enabled); +static int mls_enabled = 1; +SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RW, &mls_enabled, 0, + "Enforce MAC/MLS policy"); +TUNABLE_INT("security.mac.mls.enabled", &mls_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_mls, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, @@ -120,9 +120,9 @@ static int max_compartments = MAC_MLS_MAX_COMPARTMENTS; SYSCTL_INT(_security_mac_mls, OID_AUTO, max_compartments, CTLFLAG_RD, &max_compartments, 0, "Maximum compartments the policy supports"); -static int mac_mls_slot; -#define SLOT(l) ((struct mac_mls *)mac_label_get((l), mac_mls_slot)) -#define SLOT_SET(l, val) mac_label_set((l), mac_mls_slot, (uintptr_t)(val)) +static int mls_slot; +#define SLOT(l) ((struct mac_mls *)mac_label_get((l), mls_slot)) +#define SLOT_SET(l, val) mac_label_set((l), mls_slot, (uintptr_t)(val)) static uma_zone_t zone_mls; @@ -144,27 +144,26 @@ mls_alloc(int flag) } static void -mls_free(struct mac_mls *mac_mls) +mls_free(struct mac_mls *mm) { - if (mac_mls != NULL) - uma_zfree(zone_mls, mac_mls); + if (mm != NULL) + uma_zfree(zone_mls, mm); else atomic_add_int(&destroyed_not_inited, 1); } static int -mls_atmostflags(struct mac_mls *mac_mls, int flags) +mls_atmostflags(struct mac_mls *mm, int flags) { - if ((mac_mls->mm_flags & flags) != mac_mls->mm_flags) + if ((mm->mm_flags & flags) != mm->mm_flags) return (EINVAL); return (0); } static int -mac_mls_dominate_element(struct mac_mls_element *a, - struct mac_mls_element *b) +mls_dominate_element(struct mac_mls_element *a, struct mac_mls_element *b) { int bit; @@ -184,7 +183,7 @@ mac_mls_dominate_element(struct mac_mls_element *a, return (1); default: - panic("mac_mls_dominate_element: b->mme_type invalid"); + panic("mls_dominate_element: b->mme_type invalid"); } case MAC_MLS_TYPE_LEVEL: @@ -205,56 +204,56 @@ mac_mls_dominate_element(struct mac_mls_element *a, return (a->mme_level >= b->mme_level); default: - panic("mac_mls_dominate_element: b->mme_type invalid"); + panic("mls_dominate_element: b->mme_type invalid"); } default: - panic("mac_mls_dominate_element: a->mme_type invalid"); + panic("mls_dominate_element: a->mme_type invalid"); } return (0); } static int -mac_mls_range_in_range(struct mac_mls *rangea, struct mac_mls *rangeb) +mls_range_in_range(struct mac_mls *rangea, struct mac_mls *rangeb) { - return (mac_mls_dominate_element(&rangeb->mm_rangehigh, + return (mls_dominate_element(&rangeb->mm_rangehigh, &rangea->mm_rangehigh) && - mac_mls_dominate_element(&rangea->mm_rangelow, + mls_dominate_element(&rangea->mm_rangelow, &rangeb->mm_rangelow)); } static int -mac_mls_effective_in_range(struct mac_mls *effective, struct mac_mls *range) +mls_effective_in_range(struct mac_mls *effective, struct mac_mls *range) { KASSERT((effective->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0, - ("mac_mls_effective_in_range: a not effective")); + ("mls_effective_in_range: a not effective")); KASSERT((range->mm_flags & MAC_MLS_FLAG_RANGE) != 0, - ("mac_mls_effective_in_range: b not range")); + ("mls_effective_in_range: b not range")); - return (mac_mls_dominate_element(&range->mm_rangehigh, + return (mls_dominate_element(&range->mm_rangehigh, &effective->mm_effective) && - mac_mls_dominate_element(&effective->mm_effective, + mls_dominate_element(&effective->mm_effective, &range->mm_rangelow)); return (1); } static int -mac_mls_dominate_effective(struct mac_mls *a, struct mac_mls *b) +mls_dominate_effective(struct mac_mls *a, struct mac_mls *b) { KASSERT((a->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0, - ("mac_mls_dominate_effective: a not effective")); + ("mls_dominate_effective: a not effective")); KASSERT((b->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0, - ("mac_mls_dominate_effective: b not effective")); + ("mls_dominate_effective: b not effective")); - return (mac_mls_dominate_element(&a->mm_effective, &b->mm_effective)); + return (mls_dominate_element(&a->mm_effective, &b->mm_effective)); } static int -mac_mls_equal_element(struct mac_mls_element *a, struct mac_mls_element *b) +mls_equal_element(struct mac_mls_element *a, struct mac_mls_element *b) { if (a->mme_type == MAC_MLS_TYPE_EQUAL || @@ -265,29 +264,29 @@ mac_mls_equal_element(struct mac_mls_element *a, struct mac_mls_element *b) } static int -mac_mls_equal_effective(struct mac_mls *a, struct mac_mls *b) +mls_equal_effective(struct mac_mls *a, struct mac_mls *b) { KASSERT((a->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0, - ("mac_mls_equal_effective: a not effective")); + ("mls_equal_effective: a not effective")); KASSERT((b->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0, - ("mac_mls_equal_effective: b not effective")); + ("mls_equal_effective: b not effective")); - return (mac_mls_equal_element(&a->mm_effective, &b->mm_effective)); + return (mls_equal_element(&a->mm_effective, &b->mm_effective)); } static int -mac_mls_contains_equal(struct mac_mls *mac_mls) +mls_contains_equal(struct mac_mls *mm) { - if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE) - if (mac_mls->mm_effective.mme_type == MAC_MLS_TYPE_EQUAL) + if (mm->mm_flags & MAC_MLS_FLAG_EFFECTIVE) + if (mm->mm_effective.mme_type == MAC_MLS_TYPE_EQUAL) return (1); - if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) { - if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_EQUAL) + if (mm->mm_flags & MAC_MLS_FLAG_RANGE) { + if (mm->mm_rangelow.mme_type == MAC_MLS_TYPE_EQUAL) return (1); - if (mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_EQUAL) + if (mm->mm_rangehigh.mme_type == MAC_MLS_TYPE_EQUAL) return (1); } @@ -295,25 +294,24 @@ mac_mls_contains_equal(struct mac_mls *mac_mls) } static int -mac_mls_subject_privileged(struct mac_mls *mac_mls) +mls_subject_privileged(struct mac_mls *mm) { - KASSERT((mac_mls->mm_flags & MAC_MLS_FLAGS_BOTH) == - MAC_MLS_FLAGS_BOTH, - ("mac_mls_subject_privileged: subject doesn't have both labels")); + KASSERT((mm->mm_flags & MAC_MLS_FLAGS_BOTH) == MAC_MLS_FLAGS_BOTH, + ("mls_subject_privileged: subject doesn't have both labels")); /* If the effective is EQUAL, it's ok. */ - if (mac_mls->mm_effective.mme_type == MAC_MLS_TYPE_EQUAL) + if (mm->mm_effective.mme_type == MAC_MLS_TYPE_EQUAL) return (0); /* If either range endpoint is EQUAL, it's ok. */ - if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_EQUAL || - mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_EQUAL) + if (mm->mm_rangelow.mme_type == MAC_MLS_TYPE_EQUAL || + mm->mm_rangehigh.mme_type == MAC_MLS_TYPE_EQUAL) return (0); /* If the range is low-high, it's ok. */ - if (mac_mls->mm_rangelow.mme_type == MAC_MLS_TYPE_LOW && - mac_mls->mm_rangehigh.mme_type == MAC_MLS_TYPE_HIGH) + if (mm->mm_rangelow.mme_type == MAC_MLS_TYPE_LOW && + mm->mm_rangehigh.mme_type == MAC_MLS_TYPE_HIGH) return (0); /* It's not ok. */ @@ -321,20 +319,20 @@ mac_mls_subject_privileged(struct mac_mls *mac_mls) } static int -mac_mls_valid(struct mac_mls *mac_mls) +mls_valid(struct mac_mls *mm) { - if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { - switch (mac_mls->mm_effective.mme_type) { + if (mm->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { + switch (mm->mm_effective.mme_type) { case MAC_MLS_TYPE_LEVEL: break; case MAC_MLS_TYPE_EQUAL: case MAC_MLS_TYPE_HIGH: case MAC_MLS_TYPE_LOW: - if (mac_mls->mm_effective.mme_level != 0 || + if (mm->mm_effective.mme_level != 0 || !MAC_MLS_BIT_SET_EMPTY( - mac_mls->mm_effective.mme_compartments)) + mm->mm_effective.mme_compartments)) return (EINVAL); break; @@ -342,21 +340,21 @@ mac_mls_valid(struct mac_mls *mac_mls) return (EINVAL); } } else { - if (mac_mls->mm_effective.mme_type != MAC_MLS_TYPE_UNDEF) + if (mm->mm_effective.mme_type != MAC_MLS_TYPE_UNDEF) return (EINVAL); } - if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) { - switch (mac_mls->mm_rangelow.mme_type) { + if (mm->mm_flags & MAC_MLS_FLAG_RANGE) { + switch (mm->mm_rangelow.mme_type) { case MAC_MLS_TYPE_LEVEL: break; case MAC_MLS_TYPE_EQUAL: case MAC_MLS_TYPE_HIGH: case MAC_MLS_TYPE_LOW: - if (mac_mls->mm_rangelow.mme_level != 0 || + if (mm->mm_rangelow.mme_level != 0 || !MAC_MLS_BIT_SET_EMPTY( - mac_mls->mm_rangelow.mme_compartments)) + mm->mm_rangelow.mme_compartments)) return (EINVAL); break; @@ -364,28 +362,28 @@ mac_mls_valid(struct mac_mls *mac_mls) return (EINVAL); } - switch (mac_mls->mm_rangehigh.mme_type) { + switch (mm->mm_rangehigh.mme_type) { case MAC_MLS_TYPE_LEVEL: break; case MAC_MLS_TYPE_EQUAL: case MAC_MLS_TYPE_HIGH: case MAC_MLS_TYPE_LOW: - if (mac_mls->mm_rangehigh.mme_level != 0 || + if (mm->mm_rangehigh.mme_level != 0 || !MAC_MLS_BIT_SET_EMPTY( - mac_mls->mm_rangehigh.mme_compartments)) + mm->mm_rangehigh.mme_compartments)) return (EINVAL); break; default: return (EINVAL); } - if (!mac_mls_dominate_element(&mac_mls->mm_rangehigh, - &mac_mls->mm_rangelow)) + if (!mls_dominate_element(&mm->mm_rangehigh, + &mm->mm_rangelow)) return (EINVAL); } else { - if (mac_mls->mm_rangelow.mme_type != MAC_MLS_TYPE_UNDEF || - mac_mls->mm_rangehigh.mme_type != MAC_MLS_TYPE_UNDEF) + if (mm->mm_rangelow.mme_type != MAC_MLS_TYPE_UNDEF || + mm->mm_rangehigh.mme_type != MAC_MLS_TYPE_UNDEF) return (EINVAL); } @@ -393,45 +391,45 @@ mac_mls_valid(struct mac_mls *mac_mls) } static void -mac_mls_set_range(struct mac_mls *mac_mls, u_short typelow, - u_short levellow, u_char *compartmentslow, u_short typehigh, - u_short levelhigh, u_char *compartmentshigh) +mls_set_range(struct mac_mls *mm, u_short typelow, u_short levellow, + u_char *compartmentslow, u_short typehigh, u_short levelhigh, + u_char *compartmentshigh) { - mac_mls->mm_rangelow.mme_type = typelow; - mac_mls->mm_rangelow.mme_level = levellow; + mm->mm_rangelow.mme_type = typelow; + mm->mm_rangelow.mme_level = levellow; if (compartmentslow != NULL) - memcpy(mac_mls->mm_rangelow.mme_compartments, + memcpy(mm->mm_rangelow.mme_compartments, compartmentslow, - sizeof(mac_mls->mm_rangelow.mme_compartments)); - mac_mls->mm_rangehigh.mme_type = typehigh; - mac_mls->mm_rangehigh.mme_level = levelhigh; + sizeof(mm->mm_rangelow.mme_compartments)); + mm->mm_rangehigh.mme_type = typehigh; + mm->mm_rangehigh.mme_level = levelhigh; if (compartmentshigh != NULL) - memcpy(mac_mls->mm_rangehigh.mme_compartments, + memcpy(mm->mm_rangehigh.mme_compartments, compartmentshigh, - sizeof(mac_mls->mm_rangehigh.mme_compartments)); - mac_mls->mm_flags |= MAC_MLS_FLAG_RANGE; + sizeof(mm->mm_rangehigh.mme_compartments)); + mm->mm_flags |= MAC_MLS_FLAG_RANGE; } static void -mac_mls_set_effective(struct mac_mls *mac_mls, u_short type, u_short level, +mls_set_effective(struct mac_mls *mm, u_short type, u_short level, u_char *compartments) { - mac_mls->mm_effective.mme_type = type; - mac_mls->mm_effective.mme_level = level; + mm->mm_effective.mme_type = type; + mm->mm_effective.mme_level = level; if (compartments != NULL) - memcpy(mac_mls->mm_effective.mme_compartments, compartments, - sizeof(mac_mls->mm_effective.mme_compartments)); - mac_mls->mm_flags |= MAC_MLS_FLAG_EFFECTIVE; + memcpy(mm->mm_effective.mme_compartments, compartments, + sizeof(mm->mm_effective.mme_compartments)); + mm->mm_flags |= MAC_MLS_FLAG_EFFECTIVE; } static void -mac_mls_copy_range(struct mac_mls *labelfrom, struct mac_mls *labelto) +mls_copy_range(struct mac_mls *labelfrom, struct mac_mls *labelto) { KASSERT((labelfrom->mm_flags & MAC_MLS_FLAG_RANGE) != 0, - ("mac_mls_copy_range: labelfrom not range")); + ("mls_copy_range: labelfrom not range")); labelto->mm_rangelow = labelfrom->mm_rangelow; labelto->mm_rangehigh = labelfrom->mm_rangehigh; @@ -439,31 +437,31 @@ mac_mls_copy_range(struct mac_mls *labelfrom, struct mac_mls *labelto) } static void -mac_mls_copy_effective(struct mac_mls *labelfrom, struct mac_mls *labelto) +mls_copy_effective(struct mac_mls *labelfrom, struct mac_mls *labelto) { KASSERT((labelfrom->mm_flags & MAC_MLS_FLAG_EFFECTIVE) != 0, - ("mac_mls_copy_effective: labelfrom not effective")); + ("mls_copy_effective: labelfrom not effective")); labelto->mm_effective = labelfrom->mm_effective; labelto->mm_flags |= MAC_MLS_FLAG_EFFECTIVE; } static void -mac_mls_copy(struct mac_mls *source, struct mac_mls *dest) +mls_copy(struct mac_mls *source, struct mac_mls *dest) { if (source->mm_flags & MAC_MLS_FLAG_EFFECTIVE) - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); if (source->mm_flags & MAC_MLS_FLAG_RANGE) - mac_mls_copy_range(source, dest); + mls_copy_range(source, dest); } /* * Policy module operations. */ static void -mac_mls_init(struct mac_policy_conf *conf) +mls_init(struct mac_policy_conf *conf) { zone_mls = uma_zcreate("mac_mls", sizeof(struct mac_mls), NULL, @@ -474,14 +472,14 @@ mac_mls_init(struct mac_policy_conf *conf) * Label operations. */ static void -mac_mls_init_label(struct label *label) +mls_init_label(struct label *label) { SLOT_SET(label, mls_alloc(M_WAITOK)); } static int -mac_mls_init_label_waitcheck(struct label *label, int flag) +mls_init_label_waitcheck(struct label *label, int flag) { SLOT_SET(label, mls_alloc(flag)); @@ -492,7 +490,7 @@ mac_mls_init_label_waitcheck(struct label *label, int flag) } static void -mac_mls_destroy_label(struct label *label) +mls_destroy_label(struct label *label) { mls_free(SLOT(label)); @@ -500,12 +498,12 @@ mac_mls_destroy_label(struct label *label) } /* - * mac_mls_element_to_string() accepts an sbuf and MLS element. It - * converts the MLS element to a string and stores the result in the - * sbuf; if there isn't space in the sbuf, -1 is returned. + * mls_element_to_string() accepts an sbuf and MLS element. It converts the + * MLS element to a string and stores the result in the sbuf; if there isn't + * space in the sbuf, -1 is returned. */ static int -mac_mls_element_to_string(struct sbuf *sb, struct mac_mls_element *element) +mls_element_to_string(struct sbuf *sb, struct mac_mls_element *element) { int i, first; @@ -541,41 +539,38 @@ mac_mls_element_to_string(struct sbuf *sb, struct mac_mls_element *element) return (0); default: - panic("mac_mls_element_to_string: invalid type (%d)", + panic("mls_element_to_string: invalid type (%d)", element->mme_type); } } /* - * mac_mls_to_string() converts an MLS label to a string, and places - * the results in the passed sbuf. It returns 0 on success, or EINVAL - * if there isn't room in the sbuf. Note: the sbuf will be modified - * even in a failure case, so the caller may need to revert the sbuf - * by restoring the offset if that's undesired. + * mls_to_string() converts an MLS label to a string, and places the results + * in the passed sbuf. It returns 0 on success, or EINVAL if there isn't + * room in the sbuf. Note: the sbuf will be modified even in a failure case, + * so the caller may need to revert the sbuf by restoring the offset if + * that's undesired. */ static int -mac_mls_to_string(struct sbuf *sb, struct mac_mls *mac_mls) +mls_to_string(struct sbuf *sb, struct mac_mls *mm) { - if (mac_mls->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { - if (mac_mls_element_to_string(sb, &mac_mls->mm_effective) - == -1) + if (mm->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { + if (mls_element_to_string(sb, &mm->mm_effective) == -1) return (EINVAL); } - if (mac_mls->mm_flags & MAC_MLS_FLAG_RANGE) { + if (mm->mm_flags & MAC_MLS_FLAG_RANGE) { if (sbuf_putc(sb, '(') == -1) return (EINVAL); - if (mac_mls_element_to_string(sb, &mac_mls->mm_rangelow) - == -1) + if (mls_element_to_string(sb, &mm->mm_rangelow) == -1) return (EINVAL); if (sbuf_putc(sb, '-') == -1) return (EINVAL); - if (mac_mls_element_to_string(sb, &mac_mls->mm_rangehigh) - == -1) + if (mls_element_to_string(sb, &mm->mm_rangehigh) == -1) return (EINVAL); if (sbuf_putc(sb, ')') == -1) @@ -586,33 +581,31 @@ mac_mls_to_string(struct sbuf *sb, struct mac_mls *mac_mls) } static int -mac_mls_externalize_label(struct label *label, char *element_name, +mls_externalize_label(struct label *label, char *element_name, struct sbuf *sb, int *claimed) { - struct mac_mls *mac_mls; + struct mac_mls *mm; if (strcmp(MAC_MLS_LABEL_NAME, element_name) != 0) return (0); (*claimed)++; - mac_mls = SLOT(label); + mm = SLOT(label); - return (mac_mls_to_string(sb, mac_mls)); + return (mls_to_string(sb, mm)); } static int -mac_mls_parse_element(struct mac_mls_element *element, char *string) +mls_parse_element(struct mac_mls_element *element, char *string) { char *compartment, *end, *level; int value; - if (strcmp(string, "high") == 0 || - strcmp(string, "hi") == 0) { + if (strcmp(string, "high") == 0 || strcmp(string, "hi") == 0) { element->mme_type = MAC_MLS_TYPE_HIGH; element->mme_level = MAC_MLS_TYPE_UNDEF; - } else if (strcmp(string, "low") == 0 || - strcmp(string, "lo") == 0) { + } else if (strcmp(string, "low") == 0 || strcmp(string, "lo") == 0) { element->mme_type = MAC_MLS_TYPE_LOW; element->mme_level = MAC_MLS_TYPE_UNDEF; } else if (strcmp(string, "equal") == 0 || @@ -634,9 +627,8 @@ mac_mls_parse_element(struct mac_mls_element *element, char *string) element->mme_level = value; /* - * Optional compartment piece of the element. If none - * are included, we assume that the label has no - * compartments. + * Optional compartment piece of the element. If none are + * included, we assume that the label has no compartments. */ if (string == NULL) return (0); @@ -657,11 +649,11 @@ mac_mls_parse_element(struct mac_mls_element *element, char *string) } /* - * Note: destructively consumes the string, make a local copy before - * calling if that's a problem. + * Note: destructively consumes the string, make a local copy before calling + * if that's a problem. */ static int -mac_mls_parse(struct mac_mls *mac_mls, char *string) +mls_parse(struct mac_mls *mm, char *string) { char *rangehigh, *rangelow, *effective; int error; @@ -686,29 +678,29 @@ mac_mls_parse(struct mac_mls *mac_mls, char *string) KASSERT((rangelow != NULL && rangehigh != NULL) || (rangelow == NULL && rangehigh == NULL), - ("mac_mls_parse: range mismatch")); + ("mls_parse: range mismatch")); - bzero(mac_mls, sizeof(*mac_mls)); + bzero(mm, sizeof(*mm)); if (effective != NULL) { - error = mac_mls_parse_element(&mac_mls->mm_effective, effective); + error = mls_parse_element(&mm->mm_effective, effective); if (error) return (error); - mac_mls->mm_flags |= MAC_MLS_FLAG_EFFECTIVE; + mm->mm_flags |= MAC_MLS_FLAG_EFFECTIVE; } if (rangelow != NULL) { - error = mac_mls_parse_element(&mac_mls->mm_rangelow, + error = mls_parse_element(&mm->mm_rangelow, rangelow); if (error) return (error); - error = mac_mls_parse_element(&mac_mls->mm_rangehigh, + error = mls_parse_element(&mm->mm_rangehigh, rangehigh); if (error) return (error); - mac_mls->mm_flags |= MAC_MLS_FLAG_RANGE; + mm->mm_flags |= MAC_MLS_FLAG_RANGE; } - error = mac_mls_valid(mac_mls); + error = mls_valid(mm); if (error) return (error); @@ -716,10 +708,10 @@ mac_mls_parse(struct mac_mls *mac_mls, char *string) } static int -mac_mls_internalize_label(struct label *label, char *element_name, +mls_internalize_label(struct label *label, char *element_name, char *element_data, int *claimed) { - struct mac_mls *mac_mls, mac_mls_temp; + struct mac_mls *mm, mm_temp; int error; if (strcmp(MAC_MLS_LABEL_NAME, element_name) != 0) @@ -727,35 +719,35 @@ mac_mls_internalize_label(struct label *label, char *element_name, (*claimed)++; - error = mac_mls_parse(&mac_mls_temp, element_data); + error = mls_parse(&mm_temp, element_data); if (error) return (error); - mac_mls = SLOT(label); - *mac_mls = mac_mls_temp; + mm = SLOT(label); + *mm = mm_temp; return (0); } static void -mac_mls_copy_label(struct label *src, struct label *dest) +mls_copy_label(struct label *src, struct label *dest) { *SLOT(dest) = *SLOT(src); } /* - * Labeling event operations: file system objects, and things that look - * a lot like file system objects. + * Labeling event operations: file system objects, and things that look a lot + * like file system objects. */ static void -mac_mls_devfs_create_device(struct ucred *cred, struct mount *mp, +mls_devfs_create_device(struct ucred *cred, struct mount *mp, struct cdev *dev, struct devfs_dirent *de, struct label *delabel) { - struct mac_mls *mac_mls; + struct mac_mls *mm; int mls_type; - mac_mls = SLOT(delabel); + mm = SLOT(delabel); if (strcmp(dev->si_name, "null") == 0 || strcmp(dev->si_name, "zero") == 0 || strcmp(dev->si_name, "random") == 0 || @@ -770,21 +762,21 @@ mac_mls_devfs_create_device(struct ucred *cred, struct mount *mp, mls_type = MAC_MLS_TYPE_EQUAL; else mls_type = MAC_MLS_TYPE_LOW; - mac_mls_set_effective(mac_mls, mls_type, 0, NULL); + mls_set_effective(mm, mls_type, 0, NULL); } static void -mac_mls_devfs_create_directory(struct mount *mp, char *dirname, - int dirnamelen, struct devfs_dirent *de, struct label *delabel) +mls_devfs_create_directory(struct mount *mp, char *dirname, int dirnamelen, + struct devfs_dirent *de, struct label *delabel) { - struct mac_mls *mac_mls; + struct mac_mls *mm; - mac_mls = SLOT(delabel); - mac_mls_set_effective(mac_mls, MAC_MLS_TYPE_LOW, 0, NULL); + mm = SLOT(delabel); + mls_set_effective(mm, MAC_MLS_TYPE_LOW, 0, NULL); } static void -mac_mls_devfs_create_symlink(struct ucred *cred, struct mount *mp, +mls_devfs_create_symlink(struct ucred *cred, struct mount *mp, struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de, struct label *delabel) { @@ -793,22 +785,22 @@ mac_mls_devfs_create_symlink(struct ucred *cred, struct mount *mp, source = SLOT(cred->cr_label); dest = SLOT(delabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_mount_create(struct ucred *cred, struct mount *mp, - struct label *mplabel) +mls_mount_create(struct ucred *cred, struct mount *mp, struct label *mplabel) { struct mac_mls *source, *dest; source = SLOT(cred->cr_label); dest = SLOT(mplabel); - mac_mls_copy_effective(source, dest); + + mls_copy_effective(source, dest); } static void -mac_mls_vnode_relabel(struct ucred *cred, struct vnode *vp, +mls_vnode_relabel(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *label) { struct mac_mls *source, *dest; @@ -816,11 +808,11 @@ mac_mls_vnode_relabel(struct ucred *cred, struct vnode *vp, source = SLOT(label); dest = SLOT(vplabel); - mac_mls_copy(source, dest); + mls_copy(source, dest); } static void -mac_mls_devfs_update(struct mount *mp, struct devfs_dirent *de, +mls_devfs_update(struct mount *mp, struct devfs_dirent *de, struct label *delabel, struct vnode *vp, struct label *vplabel) { struct mac_mls *source, *dest; @@ -828,11 +820,11 @@ mac_mls_devfs_update(struct mount *mp, struct devfs_dirent *de, source = SLOT(vplabel); dest = SLOT(delabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_devfs_vnode_associate(struct mount *mp, struct label *mplabel, +mls_devfs_vnode_associate(struct mount *mp, struct label *mplabel, struct devfs_dirent *de, struct label *delabel, struct vnode *vp, struct label *vplabel) { @@ -841,103 +833,103 @@ mac_mls_devfs_vnode_associate(struct mount *mp, struct label *mplabel, source = SLOT(delabel); dest = SLOT(vplabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static int -mac_mls_vnode_associate_extattr(struct mount *mp, struct label *mplabel, +mls_vnode_associate_extattr(struct mount *mp, struct label *mplabel, struct vnode *vp, struct label *vplabel) { - struct mac_mls temp, *source, *dest; + struct mac_mls mm_temp, *source, *dest; int buflen, error; source = SLOT(mplabel); dest = SLOT(vplabel); - buflen = sizeof(temp); - bzero(&temp, buflen); + buflen = sizeof(mm_temp); + bzero(&mm_temp, buflen); error = vn_extattr_get(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE, - MAC_MLS_EXTATTR_NAME, &buflen, (char *) &temp, curthread); + MAC_MLS_EXTATTR_NAME, &buflen, (char *) &mm_temp, curthread); if (error == ENOATTR || error == EOPNOTSUPP) { /* Fall back to the mntlabel. */ - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); return (0); } else if (error) return (error); - if (buflen != sizeof(temp)) { - printf("mac_mls_vnode_associate_extattr: bad size %d\n", - buflen); + if (buflen != sizeof(mm_temp)) { + printf("mls_vnode_associate_extattr: bad size %d\n", buflen); return (EPERM); } - if (mac_mls_valid(&temp) != 0) { - printf("mac_mls_vnode_associate_extattr: invalid\n"); + if (mls_valid(&mm_temp) != 0) { + printf("mls_vnode_associate_extattr: invalid\n"); return (EPERM); } - if ((temp.mm_flags & MAC_MLS_FLAGS_BOTH) != MAC_MLS_FLAG_EFFECTIVE) { - printf("mac_mls_associated_vnode_extattr: not effective\n"); + if ((mm_temp.mm_flags & MAC_MLS_FLAGS_BOTH) != + MAC_MLS_FLAG_EFFECTIVE) { + printf("mls_associated_vnode_extattr: not effective\n"); return (EPERM); } - mac_mls_copy_effective(&temp, dest); + mls_copy_effective(&mm_temp, dest); return (0); } static void -mac_mls_vnode_associate_singlelabel(struct mount *mp, - struct label *mplabel, struct vnode *vp, struct label *vplabel) +mls_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, + struct vnode *vp, struct label *vplabel) { struct mac_mls *source, *dest; source = SLOT(mplabel); dest = SLOT(vplabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static int -mac_mls_vnode_create_extattr(struct ucred *cred, struct mount *mp, +mls_vnode_create_extattr(struct ucred *cred, struct mount *mp, struct label *mplabel, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { - struct mac_mls *source, *dest, temp; + struct mac_mls *source, *dest, mm_temp; size_t buflen; int error; - buflen = sizeof(temp); - bzero(&temp, buflen); + buflen = sizeof(mm_temp); + bzero(&mm_temp, buflen); source = SLOT(cred->cr_label); dest = SLOT(vplabel); - mac_mls_copy_effective(source, &temp); + mls_copy_effective(source, &mm_temp); error = vn_extattr_set(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE, - MAC_MLS_EXTATTR_NAME, buflen, (char *) &temp, curthread); + MAC_MLS_EXTATTR_NAME, buflen, (char *) &mm_temp, curthread); if (error == 0) - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); return (error); } static int -mac_mls_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, +mls_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *intlabel) { - struct mac_mls *source, temp; + struct mac_mls *source, mm_temp; size_t buflen; int error; - buflen = sizeof(temp); - bzero(&temp, buflen); + buflen = sizeof(mm_temp); + bzero(&mm_temp, buflen); source = SLOT(intlabel); if ((source->mm_flags & MAC_MLS_FLAG_EFFECTIVE) == 0) return (0); - mac_mls_copy_effective(source, &temp); + mls_copy_effective(source, &mm_temp); error = vn_extattr_set(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE, - MAC_MLS_EXTATTR_NAME, buflen, (char *) &temp, curthread); + MAC_MLS_EXTATTR_NAME, buflen, (char *) &mm_temp, curthread); return (error); } @@ -945,19 +937,19 @@ mac_mls_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, * Labeling event operations: IPC object. */ static void -mac_mls_inpcb_create(struct socket *so, struct label *solabel, - struct inpcb *inp, struct label *inplabel) +mls_inpcb_create(struct socket *so, struct label *solabel, struct inpcb *inp, + struct label *inplabel) { struct mac_mls *source, *dest; source = SLOT(solabel); dest = SLOT(inplabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_socket_create_mbuf(struct socket *so, struct label *solabel, +mls_socket_create_mbuf(struct socket *so, struct label *solabel, struct mbuf *m, struct label *mlabel) { struct mac_mls *source, *dest; @@ -965,11 +957,11 @@ mac_mls_socket_create_mbuf(struct socket *so, struct label *solabel, source = SLOT(solabel); dest = SLOT(mlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_socket_create(struct ucred *cred, struct socket *so, +mls_socket_create(struct ucred *cred, struct socket *so, struct label *solabel) { struct mac_mls *source, *dest; @@ -977,11 +969,11 @@ mac_mls_socket_create(struct ucred *cred, struct socket *so, source = SLOT(cred->cr_label); dest = SLOT(solabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_pipe_create(struct ucred *cred, struct pipepair *pp, +mls_pipe_create(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_mls *source, *dest; @@ -989,11 +981,11 @@ mac_mls_pipe_create(struct ucred *cred, struct pipepair *pp, source = SLOT(cred->cr_label); dest = SLOT(pplabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_posixsem_create(struct ucred *cred, struct ksem *ks, +mls_posixsem_create(struct ucred *cred, struct ksem *ks, struct label *kslabel) { struct mac_mls *source, *dest; @@ -1001,11 +993,11 @@ mac_mls_posixsem_create(struct ucred *cred, struct ksem *ks, source = SLOT(cred->cr_label); dest = SLOT(kslabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_socket_newconn(struct socket *oldso, struct label *oldsolabel, +mls_socket_newconn(struct socket *oldso, struct label *oldsolabel, struct socket *newso, struct label *newsolabel) { struct mac_mls *source, *dest; @@ -1013,11 +1005,11 @@ mac_mls_socket_newconn(struct socket *oldso, struct label *oldsolabel, source = SLOT(oldsolabel); dest = SLOT(newsolabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_socket_relabel(struct ucred *cred, struct socket *so, +mls_socket_relabel(struct ucred *cred, struct socket *so, struct label *solabel, struct label *newlabel) { struct mac_mls *source, *dest; @@ -1025,11 +1017,11 @@ mac_mls_socket_relabel(struct ucred *cred, struct socket *so, source = SLOT(newlabel); dest = SLOT(solabel); - mac_mls_copy(source, dest); + mls_copy(source, dest); } static void -mac_mls_pipe_relabel(struct ucred *cred, struct pipepair *pp, +mls_pipe_relabel(struct ucred *cred, struct pipepair *pp, struct label *pplabel, struct label *newlabel) { struct mac_mls *source, *dest; @@ -1037,11 +1029,11 @@ mac_mls_pipe_relabel(struct ucred *cred, struct pipepair *pp, source = SLOT(newlabel); dest = SLOT(pplabel); - mac_mls_copy(source, dest); + mls_copy(source, dest); } static void -mac_mls_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, +mls_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, struct socket *so, struct label *sopeerlabel) { struct mac_mls *source, *dest; @@ -1049,14 +1041,14 @@ mac_mls_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(sopeerlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } /* * Labeling event operations: System V IPC objects. */ static void -mac_mls_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, +mls_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqlabel, struct msg *msgptr, struct label *msglabel) { struct mac_mls *source, *dest; @@ -1065,11 +1057,11 @@ mac_mls_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, source = SLOT(cred->cr_label); dest = SLOT(msglabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_sysvmsq_create(struct ucred *cred, struct msqid_kernel *msqkptr, +mls_sysvmsq_create(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqlabel) { struct mac_mls *source, *dest; @@ -1077,11 +1069,11 @@ mac_mls_sysvmsq_create(struct ucred *cred, struct msqid_kernel *msqkptr, source = SLOT(cred->cr_label); dest = SLOT(msqlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, +mls_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, struct label *semalabel) { struct mac_mls *source, *dest; @@ -1089,11 +1081,11 @@ mac_mls_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, source = SLOT(cred->cr_label); dest = SLOT(semalabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, +mls_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, struct label *shmlabel) { struct mac_mls *source, *dest; @@ -1101,14 +1093,14 @@ mac_mls_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, source = SLOT(cred->cr_label); dest = SLOT(shmlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } /* * Labeling event operations: network objects. */ static void -mac_mls_socketpeer_set_from_socket(struct socket *oldso, +mls_socketpeer_set_from_socket(struct socket *oldso, struct label *oldsolabel, struct socket *newso, struct label *newsopeerlabel) { @@ -1117,23 +1109,22 @@ mac_mls_socketpeer_set_from_socket(struct socket *oldso, source = SLOT(oldsolabel); dest = SLOT(newsopeerlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_bpfdesc_create(struct ucred *cred, struct bpf_d *d, - struct label *dlabel) +mls_bpfdesc_create(struct ucred *cred, struct bpf_d *d, struct label *dlabel) { struct mac_mls *source, *dest; source = SLOT(cred->cr_label); dest = SLOT(dlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_ifnet_create(struct ifnet *ifp, struct label *ifplabel) +mls_ifnet_create(struct ifnet *ifp, struct label *ifplabel) { struct mac_mls *dest; int type; @@ -1145,12 +1136,12 @@ mac_mls_ifnet_create(struct ifnet *ifp, struct label *ifplabel) else type = MAC_MLS_TYPE_LOW; - mac_mls_set_effective(dest, type, 0, NULL); - mac_mls_set_range(dest, type, 0, NULL, type, 0, NULL); + mls_set_effective(dest, type, 0, NULL); + mls_set_range(dest, type, 0, NULL, type, 0, NULL); } static void -mac_mls_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +mls_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { struct mac_mls *source, *dest; @@ -1158,12 +1149,12 @@ mac_mls_ipq_create(struct mbuf *m, struct label *mlabel, struct ipq *ipq, source = SLOT(mlabel); dest = SLOT(ipqlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, - struct mbuf *m, struct label *mlabel) +mls_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, struct mbuf *m, + struct label *mlabel) { struct mac_mls *source, *dest; @@ -1171,23 +1162,23 @@ mac_mls_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, dest = SLOT(mlabel); /* Just use the head, since we require them all to match. */ - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_netinet_fragment(struct mbuf *m, struct label *mlabel, - struct mbuf *frag, struct label *fraglabel) +mls_netinet_fragment(struct mbuf *m, struct label *mlabel, struct mbuf *frag, + struct label *fraglabel) { struct mac_mls *source, *dest; source = SLOT(mlabel); dest = SLOT(fraglabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, +mls_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { struct mac_mls *source, *dest; @@ -1195,22 +1186,22 @@ mac_mls_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, source = SLOT(inplabel); dest = SLOT(mlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, +mls_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_mls *dest; dest = SLOT(mlabel); - mac_mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL); + mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL); } static void -mac_mls_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, +mls_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, struct mbuf *m, struct label *mlabel) { struct mac_mls *source, *dest; @@ -1218,11 +1209,11 @@ mac_mls_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, source = SLOT(dlabel); dest = SLOT(mlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, +mls_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_mls *source, *dest; @@ -1230,11 +1221,11 @@ mac_mls_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, source = SLOT(ifplabel); dest = SLOT(mlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, +mls_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, struct ifnet *ifp, struct label *ifplabel, struct mbuf *mnew, struct label *mnewlabel) { @@ -1243,11 +1234,11 @@ mac_mls_mbuf_create_multicast_encap(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(mnewlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static void -mac_mls_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, +mls_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, struct mbuf *mnew, struct label *mnewlabel) { struct mac_mls *source, *dest; @@ -1255,11 +1246,11 @@ mac_mls_mbuf_create_netlayer(struct mbuf *m, struct label *mlabel, source = SLOT(mlabel); dest = SLOT(mnewlabel); - mac_mls_copy_effective(source, dest); + mls_copy_effective(source, dest); } static int -mac_mls_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +mls_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { struct mac_mls *a, *b; @@ -1267,11 +1258,11 @@ mac_mls_ipq_match(struct mbuf *m, struct label *mlabel, struct ipq *ipq, a = SLOT(ipqlabel); b = SLOT(mlabel); - return (mac_mls_equal_effective(a, b)); + return (mls_equal_effective(a, b)); } static void -mac_mls_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, +mls_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, struct label *ifplabel, struct label *newlabel) { struct mac_mls *source, *dest; @@ -1279,11 +1270,11 @@ mac_mls_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, source = SLOT(newlabel); dest = SLOT(ifplabel); - mac_mls_copy(source, dest); + mls_copy(source, dest); } static void -mac_mls_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, +mls_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, struct label *ipqlabel) { @@ -1291,7 +1282,7 @@ mac_mls_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *ipq, } static void -mac_mls_inpcb_sosetlabel(struct socket *so, struct label *solabel, +mls_inpcb_sosetlabel(struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel) { struct mac_mls *source, *dest; @@ -1299,105 +1290,107 @@ mac_mls_inpcb_sosetlabel(struct socket *so, struct label *solabel, source = SLOT(solabel); dest = SLOT(inplabel); - mac_mls_copy(source, dest); + mls_copy(source, dest); } static void -mac_mls_mbuf_create_from_firewall(struct mbuf *m, struct label *mlabel) +mls_mbuf_create_from_firewall(struct mbuf *m, struct label *mlabel) { struct mac_mls *dest; dest = SLOT(mlabel); /* XXX: where is the label for the firewall really comming from? */ - mac_mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL); + mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL); } static void -mac_mls_init_syncache_from_inpcb(struct label *label, struct inpcb *inp) +mls_init_syncache_from_inpcb(struct label *label, struct inpcb *inp) { struct mac_mls *source, *dest; source = SLOT(inp->inp_label); dest = SLOT(label); - mac_mls_copy_effective(source, dest); + + mls_copy_effective(source, dest); } static void -mac_mls_create_mbuf_from_syncache(struct label *sc_label, struct mbuf *m, +mls_create_mbuf_from_syncache(struct label *sc_label, struct mbuf *m, struct label *mlabel) { struct mac_mls *source, *dest; source = SLOT(sc_label); dest = SLOT(mlabel); - mac_mls_copy_effective(source, dest); + + mls_copy_effective(source, dest); } /* * Labeling event operations: processes. */ static void -mac_mls_proc_create_swapper(struct ucred *cred) +mls_proc_create_swapper(struct ucred *cred) { struct mac_mls *dest; dest = SLOT(cred->cr_label); - mac_mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL); - mac_mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, - 0, NULL); + mls_set_effective(dest, MAC_MLS_TYPE_EQUAL, 0, NULL); + mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0, + NULL); } static void -mac_mls_proc_create_init(struct ucred *cred) +mls_proc_create_init(struct ucred *cred) { struct mac_mls *dest; dest = SLOT(cred->cr_label); - mac_mls_set_effective(dest, MAC_MLS_TYPE_LOW, 0, NULL); - mac_mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, - 0, NULL); + mls_set_effective(dest, MAC_MLS_TYPE_LOW, 0, NULL); + mls_set_range(dest, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0, + NULL); } static void -mac_mls_cred_relabel(struct ucred *cred, struct label *newlabel) +mls_cred_relabel(struct ucred *cred, struct label *newlabel) { struct mac_mls *source, *dest; source = SLOT(newlabel); dest = SLOT(cred->cr_label); - mac_mls_copy(source, dest); + mls_copy(source, dest); } /* * Label cleanup/flush operations. */ static void -mac_mls_sysvmsg_cleanup(struct label *msglabel) +mls_sysvmsg_cleanup(struct label *msglabel) { bzero(SLOT(msglabel), sizeof(struct mac_mls)); } static void -mac_mls_sysvmsq_cleanup(struct label *msqlabel) +mls_sysvmsq_cleanup(struct label *msqlabel) { bzero(SLOT(msqlabel), sizeof(struct mac_mls)); } static void -mac_mls_sysvsem_cleanup(struct label *semalabel) +mls_sysvsem_cleanup(struct label *semalabel) { bzero(SLOT(semalabel), sizeof(struct mac_mls)); } static void -mac_mls_sysvshm_cleanup(struct label *shmlabel) +mls_sysvshm_cleanup(struct label *shmlabel) { bzero(SLOT(shmlabel), sizeof(struct mac_mls)); @@ -1407,24 +1400,24 @@ mac_mls_sysvshm_cleanup(struct label *shmlabel) * Access control checks. */ static int -mac_mls_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, +mls_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, struct ifnet *ifp, struct label *ifplabel) { struct mac_mls *a, *b; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); a = SLOT(dlabel); b = SLOT(ifplabel); - if (mac_mls_equal_effective(a, b)) + if (mls_equal_effective(a, b)) return (0); return (EACCES); } static int -mac_mls_cred_check_relabel(struct ucred *cred, struct label *newlabel) +mls_cred_check_relabel(struct ucred *cred, struct label *newlabel) { struct mac_mls *subj, *new; int error; @@ -1433,8 +1426,8 @@ mac_mls_cred_check_relabel(struct ucred *cred, struct label *newlabel) new = SLOT(newlabel); /* - * If there is an MLS label update for the credential, it may be - * an update of effective, range, or both. + * If there is an MLS label update for the credential, it may be an + * update of effective, range, or both. */ error = mls_atmostflags(new, MAC_MLS_FLAGS_BOTH); if (error) @@ -1445,38 +1438,36 @@ mac_mls_cred_check_relabel(struct ucred *cred, struct label *newlabel) */ if (new->mm_flags & MAC_MLS_FLAGS_BOTH) { /* - * If the change request modifies both the MLS label effective - * and range, check that the new effective will be in the - * new range. + * If the change request modifies both the MLS label + * effective and range, check that the new effective will be + * in the new range. */ if ((new->mm_flags & MAC_MLS_FLAGS_BOTH) == - MAC_MLS_FLAGS_BOTH && - !mac_mls_effective_in_range(new, new)) + MAC_MLS_FLAGS_BOTH && !mls_effective_in_range(new, new)) return (EINVAL); /* - * To change the MLS effective label on a credential, the - * new effective label must be in the current range. + * To change the MLS effective label on a credential, the new + * effective label must be in the current range. */ if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE && - !mac_mls_effective_in_range(new, subj)) + !mls_effective_in_range(new, subj)) return (EPERM); /* - * To change the MLS range label on a credential, the - * new range must be in the current range. + * To change the MLS range label on a credential, the new + * range must be in the current range. */ if (new->mm_flags & MAC_MLS_FLAG_RANGE && - !mac_mls_range_in_range(new, subj)) + !mls_range_in_range(new, subj)) return (EPERM); /* - * To have EQUAL in any component of the new credential - * MLS label, the subject must already have EQUAL in - * their label. + * To have EQUAL in any component of the new credential MLS + * label, the subject must already have EQUAL in their label. */ - if (mac_mls_contains_equal(new)) { - error = mac_mls_subject_privileged(subj); + if (mls_contains_equal(new)) { + error = mls_subject_privileged(subj); if (error) return (error); } @@ -1486,25 +1477,25 @@ mac_mls_cred_check_relabel(struct ucred *cred, struct label *newlabel) } static int -mac_mls_cred_check_visible(struct ucred *cr1, struct ucred *cr2) +mls_cred_check_visible(struct ucred *cr1, struct ucred *cr2) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cr1->cr_label); obj = SLOT(cr2->cr_label); /* XXX: range */ - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (ESRCH); return (0); } static int -mac_mls_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, +mls_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, struct label *ifplabel, struct label *newlabel) { struct mac_mls *subj, *new; @@ -1514,8 +1505,8 @@ mac_mls_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, new = SLOT(newlabel); /* - * If there is an MLS label update for the interface, it may - * be an update of effective, range, or both. + * If there is an MLS label update for the interface, it may be an + * update of effective, range, or both. */ error = mls_atmostflags(new, MAC_MLS_FLAGS_BOTH); if (error) @@ -1524,138 +1515,138 @@ mac_mls_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, /* * Relabeling network interfaces requires MLS privilege. */ - error = mac_mls_subject_privileged(subj); + error = mls_subject_privileged(subj); return (0); } static int -mac_mls_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, +mls_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mlabel) { struct mac_mls *p, *i; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); p = SLOT(mlabel); i = SLOT(ifplabel); - return (mac_mls_effective_in_range(p, i) ? 0 : EACCES); + return (mls_effective_in_range(p, i) ? 0 : EACCES); } static int -mac_mls_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, +mls_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { struct mac_mls *p, *i; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); p = SLOT(mlabel); i = SLOT(inplabel); - return (mac_mls_equal_effective(p, i) ? 0 : EACCES); + return (mls_equal_effective(p, i) ? 0 : EACCES); } static int -mac_mls_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, +mls_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, struct label *msglabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msglabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, +mls_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, struct label *msglabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msglabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_sysvmsq_check_msqget(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqklabel) +mls_sysvmsq_check_msqget(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqklabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msqklabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_sysvmsq_check_msqsnd(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqklabel) +mls_sysvmsq_check_msqsnd(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqklabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msqklabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_sysvmsq_check_msqrcv(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqklabel) +mls_sysvmsq_check_msqrcv(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqklabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(msqklabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_sysvmsq_check_msqctl(struct ucred *cred, - struct msqid_kernel *msqkptr, struct label *msqklabel, int cmd) +mls_sysvmsq_check_msqctl(struct ucred *cred, struct msqid_kernel *msqkptr, + struct label *msqklabel, int cmd) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); @@ -1664,12 +1655,12 @@ mac_mls_sysvmsq_check_msqctl(struct ucred *cred, switch(cmd) { case IPC_RMID: case IPC_SET: - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); break; case IPC_STAT: - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); break; @@ -1681,12 +1672,12 @@ mac_mls_sysvmsq_check_msqctl(struct ucred *cred, } static int -mac_mls_sysvsem_check_semctl(struct ucred *cred, - struct semid_kernel *semakptr, struct label *semaklabel, int cmd) +mls_sysvsem_check_semctl(struct ucred *cred, struct semid_kernel *semakptr, + struct label *semaklabel, int cmd) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); @@ -1697,7 +1688,7 @@ mac_mls_sysvsem_check_semctl(struct ucred *cred, case IPC_SET: case SETVAL: case SETALL: - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); break; @@ -1707,7 +1698,7 @@ mac_mls_sysvsem_check_semctl(struct ucred *cred, case GETNCNT: case GETZCNT: case GETALL: - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); break; @@ -1719,75 +1710,75 @@ mac_mls_sysvsem_check_semctl(struct ucred *cred, } static int -mac_mls_sysvsem_check_semget(struct ucred *cred, - struct semid_kernel *semakptr, struct label *semaklabel) +mls_sysvsem_check_semget(struct ucred *cred, struct semid_kernel *semakptr, + struct label *semaklabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(semaklabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_sysvsem_check_semop(struct ucred *cred, - struct semid_kernel *semakptr, struct label *semaklabel, - size_t accesstype) +mls_sysvsem_check_semop(struct ucred *cred, struct semid_kernel *semakptr, + struct label *semaklabel, size_t accesstype) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(semaklabel); if( accesstype & SEM_R ) - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); if( accesstype & SEM_A ) - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_sysvshm_check_shmat(struct ucred *cred, - struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) +mls_sysvshm_check_shmat(struct ucred *cred, struct shmid_kernel *shmsegptr, + struct label *shmseglabel, int shmflg) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(shmseglabel); - if (!mac_mls_dominate_effective(subj, obj)) - return (EACCES); - if ((shmflg & SHM_RDONLY) == 0) - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(subj, obj)) + return (EACCES); + if ((shmflg & SHM_RDONLY) == 0) { + if (!mls_dominate_effective(obj, subj)) return (EACCES); + } return (0); } static int -mac_mls_sysvshm_check_shmctl(struct ucred *cred, - struct shmid_kernel *shmsegptr, struct label *shmseglabel, int cmd) +mls_sysvshm_check_shmctl(struct ucred *cred, struct shmid_kernel *shmsegptr, + struct label *shmseglabel, int cmd) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); @@ -1796,13 +1787,13 @@ mac_mls_sysvshm_check_shmctl(struct ucred *cred, switch(cmd) { case IPC_RMID: case IPC_SET: - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); break; case IPC_STAT: case SHM_STAT: - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); break; @@ -1814,47 +1805,47 @@ mac_mls_sysvshm_check_shmctl(struct ucred *cred, } static int -mac_mls_sysvshm_check_shmget(struct ucred *cred, - struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) +mls_sysvshm_check_shmget(struct ucred *cred, struct shmid_kernel *shmsegptr, + struct label *shmseglabel, int shmflg) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(shmseglabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_mount_check_stat(struct ucred *cred, struct mount *mp, +mls_mount_check_stat(struct ucred *cred, struct mount *mp, struct label *mntlabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(mntlabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, +mls_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, struct label *pplabel, unsigned long cmd, void /* caddr_t */ *data) { - if(!mac_mls_enabled) + if (!mls_enabled) return (0); /* XXX: This will be implemented soon... */ @@ -1863,43 +1854,43 @@ mac_mls_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, } static int -mac_mls_pipe_check_poll(struct ucred *cred, struct pipepair *pp, +mls_pipe_check_poll(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_pipe_check_read(struct ucred *cred, struct pipepair *pp, +mls_pipe_check_read(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, +mls_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, struct label *pplabel, struct label *newlabel) { struct mac_mls *subj, *obj, *new; @@ -1910,8 +1901,8 @@ mac_mls_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, obj = SLOT(pplabel); /* - * If there is an MLS label update for a pipe, it must be a - * effective update. + * If there is an MLS label update for a pipe, it must be a effective + * update. */ error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE); if (error) @@ -1921,7 +1912,7 @@ mac_mls_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, * To perform a relabel of a pipe (MLS label or not), MLS must * authorize the relabel. */ - if (!mac_mls_effective_in_range(obj, subj)) + if (!mls_effective_in_range(obj, subj)) return (EPERM); /* @@ -1929,18 +1920,18 @@ mac_mls_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, */ if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { /* - * To change the MLS label on a pipe, the new pipe label - * must be in the subject range. + * To change the MLS label on a pipe, the new pipe label must + * be in the subject range. */ - if (!mac_mls_effective_in_range(new, subj)) + if (!mls_effective_in_range(new, subj)) return (EPERM); /* - * To change the MLS label on a pipe to be EQUAL, the - * subject must have appropriate privilege. + * To change the MLS label on a pipe to be EQUAL, the subject + * must have appropriate privilege. */ - if (mac_mls_contains_equal(new)) { - error = mac_mls_subject_privileged(subj); + if (mls_contains_equal(new)) { + error = mls_subject_privileged(subj); if (error) return (error); } @@ -1950,154 +1941,154 @@ mac_mls_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, } static int -mac_mls_pipe_check_stat(struct ucred *cred, struct pipepair *pp, +mls_pipe_check_stat(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_pipe_check_write(struct ucred *cred, struct pipepair *pp, +mls_pipe_check_write(struct ucred *cred, struct pipepair *pp, struct label *pplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(pplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_posixsem_check_write(struct ucred *cred, struct ksem *ks, +mls_posixsem_check_write(struct ucred *cred, struct ksem *ks, struct label *kslabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(kslabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_posixsem_check_rdonly(struct ucred *cred, struct ksem *ks, +mls_posixsem_check_rdonly(struct ucred *cred, struct ksem *ks, struct label *kslabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(kslabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_proc_check_debug(struct ucred *cred, struct proc *p) +mls_proc_check_debug(struct ucred *cred, struct proc *p) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (ESRCH); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_proc_check_sched(struct ucred *cred, struct proc *p) +mls_proc_check_sched(struct ucred *cred, struct proc *p) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (ESRCH); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_proc_check_signal(struct ucred *cred, struct proc *p, int signum) +mls_proc_check_signal(struct ucred *cred, struct proc *p, int signum) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(p->p_ucred->cr_label); /* XXX: range checks */ - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (ESRCH); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_socket_check_deliver(struct socket *so, struct label *solabel, +mls_socket_check_deliver(struct socket *so, struct label *solabel, struct mbuf *m, struct label *mlabel) { struct mac_mls *p, *s; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); p = SLOT(mlabel); s = SLOT(solabel); - return (mac_mls_equal_effective(p, s) ? 0 : EACCES); + return (mls_equal_effective(p, s) ? 0 : EACCES); } static int -mac_mls_socket_check_relabel(struct ucred *cred, struct socket *so, +mls_socket_check_relabel(struct ucred *cred, struct socket *so, struct label *solabel, struct label *newlabel) { struct mac_mls *subj, *obj, *new; @@ -2108,18 +2099,18 @@ mac_mls_socket_check_relabel(struct ucred *cred, struct socket *so, obj = SLOT(solabel); /* - * If there is an MLS label update for the socket, it may be - * an update of effective. + * If there is an MLS label update for the socket, it may be an + * update of effective. */ error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE); if (error) return (error); /* - * To relabel a socket, the old socket effective must be in the subject - * range. + * To relabel a socket, the old socket effective must be in the + * subject range. */ - if (!mac_mls_effective_in_range(obj, subj)) + if (!mls_effective_in_range(obj, subj)) return (EPERM); /* @@ -2130,15 +2121,15 @@ mac_mls_socket_check_relabel(struct ucred *cred, struct socket *so, * To relabel a socket, the new socket effective must be in * the subject range. */ - if (!mac_mls_effective_in_range(new, subj)) + if (!mls_effective_in_range(new, subj)) return (EPERM); /* * To change the MLS label on the socket to contain EQUAL, * the subject must have appropriate privilege. */ - if (mac_mls_contains_equal(new)) { - error = mac_mls_subject_privileged(subj); + if (mls_contains_equal(new)) { + error = mls_subject_privileged(subj); if (error) return (error); } @@ -2148,172 +2139,172 @@ mac_mls_socket_check_relabel(struct ucred *cred, struct socket *so, } static int -mac_mls_socket_check_visible(struct ucred *cred, struct socket *so, +mls_socket_check_visible(struct ucred *cred, struct socket *so, struct label *solabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(solabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (ENOENT); return (0); } static int -mac_mls_system_check_acct(struct ucred *cred, struct vnode *vp, +mls_system_check_acct(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj) || - !mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(obj, subj) || + !mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_system_check_auditctl(struct ucred *cred, struct vnode *vp, +mls_system_check_auditctl(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj) || - !mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(obj, subj) || + !mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_system_check_swapon(struct ucred *cred, struct vnode *vp, +mls_system_check_swapon(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj) || - !mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(obj, subj) || + !mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_create(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_create(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp, struct vattr *vap) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, +mls_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, +mls_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_exec(struct ucred *cred, struct vnode *vp, +mls_vnode_check_exec(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct image_params *imgp, struct label *execlabel) { @@ -2323,8 +2314,8 @@ mac_mls_vnode_check_exec(struct ucred *cred, struct vnode *vp, if (execlabel != NULL) { /* * We currently don't permit labels to be changed at - * exec-time as part of MLS, so disallow non-NULL - * MLS label elements in the execlabel. + * exec-time as part of MLS, so disallow non-NULL MLS label + * elements in the execlabel. */ exec = SLOT(execlabel); error = mls_atmostflags(exec, 0); @@ -2332,117 +2323,117 @@ mac_mls_vnode_check_exec(struct ucred *cred, struct vnode *vp, return (error); } - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_getacl(struct ucred *cred, struct vnode *vp, +mls_vnode_check_getacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, +mls_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_link(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_link(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, +mls_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_mmap(struct ucred *cred, struct vnode *vp, +mls_vnode_check_mmap(struct ucred *cred, struct vnode *vp, struct label *vplabel, int prot, int flags) { struct mac_mls *subj, *obj; @@ -2451,18 +2442,18 @@ mac_mls_vnode_check_mmap(struct ucred *cred, struct vnode *vp, * Rely on the use of open()-time protections to handle * non-revocation cases. */ - if (!mac_mls_enabled || !revocation_enabled) + if (!mls_enabled || !revocation_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); if (prot & (VM_PROT_READ | VM_PROT_EXECUTE)) { - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); } if (((prot & VM_PROT_WRITE) != 0) && ((flags & MAP_SHARED) != 0)) { - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); } @@ -2470,12 +2461,12 @@ mac_mls_vnode_check_mmap(struct ucred *cred, struct vnode *vp, } static int -mac_mls_vnode_check_open(struct ucred *cred, struct vnode *vp, +mls_vnode_check_open(struct ucred *cred, struct vnode *vp, struct label *vplabel, int acc_mode) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); @@ -2483,11 +2474,11 @@ mac_mls_vnode_check_open(struct ucred *cred, struct vnode *vp, /* XXX privilege override for admin? */ if (acc_mode & (VREAD | VEXEC | VSTAT)) { - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); } if (acc_mode & (VWRITE | VAPPEND | VADMIN)) { - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); } @@ -2495,79 +2486,79 @@ mac_mls_vnode_check_open(struct ucred *cred, struct vnode *vp, } static int -mac_mls_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, +mls_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled || !revocation_enabled) + if (!mls_enabled || !revocation_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, +mls_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled || !revocation_enabled) + if (!mls_enabled || !revocation_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_readlink(struct ucred *cred, struct vnode *vp, +mls_vnode_check_readlink(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_relabel(struct ucred *cred, struct vnode *vp, +mls_vnode_check_relabel(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *newlabel) { struct mac_mls *old, *new, *subj; @@ -2589,7 +2580,7 @@ mac_mls_vnode_check_relabel(struct ucred *cred, struct vnode *vp, * To perform a relabel of the vnode (MLS label or not), MLS must * authorize the relabel. */ - if (!mac_mls_effective_in_range(old, subj)) + if (!mls_effective_in_range(old, subj)) return (EPERM); /* @@ -2600,15 +2591,15 @@ mac_mls_vnode_check_relabel(struct ucred *cred, struct vnode *vp, * To change the MLS label on a vnode, the new vnode label * must be in the subject range. */ - if (!mac_mls_effective_in_range(new, subj)) + if (!mls_effective_in_range(new, subj)) return (EPERM); /* - * To change the MLS label on the vnode to be EQUAL, - * the subject must have appropriate privilege. + * To change the MLS label on the vnode to be EQUAL, the + * subject must have appropriate privilege. */ - if (mac_mls_contains_equal(new)) { - error = mac_mls_subject_privileged(subj); + if (mls_contains_equal(new)) { + error = mls_subject_privileged(subj); if (error) return (error); } @@ -2618,49 +2609,49 @@ mac_mls_vnode_check_relabel(struct ucred *cred, struct vnode *vp, } static int -mac_mls_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, int samedir, struct componentname *cnp) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); if (vp != NULL) { obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); } @@ -2668,55 +2659,55 @@ mac_mls_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, } static int -mac_mls_vnode_check_revoke(struct ucred *cred, struct vnode *vp, +mls_vnode_check_revoke(struct ucred *cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_setacl(struct ucred *cred, struct vnode *vp, +mls_vnode_check_setacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type, struct acl *acl) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, +mls_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); /* XXX: protect the MAC EA in a special way? */ @@ -2725,327 +2716,327 @@ mac_mls_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, } static int -mac_mls_vnode_check_setflags(struct ucred *cred, struct vnode *vp, +mls_vnode_check_setflags(struct ucred *cred, struct vnode *vp, struct label *vplabel, u_long flags) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_setmode(struct ucred *cred, struct vnode *vp, +mls_vnode_check_setmode(struct ucred *cred, struct vnode *vp, struct label *vplabel, mode_t mode) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_setowner(struct ucred *cred, struct vnode *vp, +mls_vnode_check_setowner(struct ucred *cred, struct vnode *vp, struct label *vplabel, uid_t uid, gid_t gid) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, +mls_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct timespec atime, struct timespec mtime) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, +mls_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(subj, obj)) + if (!mls_dominate_effective(subj, obj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, +mls_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled) + if (!mls_enabled) return (0); subj = SLOT(cred->cr_label); obj = SLOT(dvplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static int -mac_mls_vnode_check_write(struct ucred *active_cred, struct ucred *file_cred, +mls_vnode_check_write(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { struct mac_mls *subj, *obj; - if (!mac_mls_enabled || !revocation_enabled) + if (!mls_enabled || !revocation_enabled) return (0); subj = SLOT(active_cred->cr_label); obj = SLOT(vplabel); - if (!mac_mls_dominate_effective(obj, subj)) + if (!mls_dominate_effective(obj, subj)) return (EACCES); return (0); } static void -mac_mls_associate_nfsd_label(struct ucred *cred) +mls_associate_nfsd_label(struct ucred *cred) { struct mac_mls *label; label = SLOT(cred->cr_label); - mac_mls_set_effective(label, MAC_MLS_TYPE_LOW, 0, NULL); - mac_mls_set_range(label, MAC_MLS_TYPE_LOW, 0, NULL, - MAC_MLS_TYPE_HIGH, 0, NULL); -} - -static struct mac_policy_ops mac_mls_ops = -{ - .mpo_init = mac_mls_init, - .mpo_bpfdesc_init_label = mac_mls_init_label, - .mpo_cred_init_label = mac_mls_init_label, - .mpo_devfs_init_label = mac_mls_init_label, - .mpo_ifnet_init_label = mac_mls_init_label, - .mpo_inpcb_init_label = mac_mls_init_label_waitcheck, - .mpo_init_syncache_label = mac_mls_init_label_waitcheck, - .mpo_sysvmsg_init_label = mac_mls_init_label, - .mpo_sysvmsq_init_label = mac_mls_init_label, - .mpo_sysvsem_init_label = mac_mls_init_label, - .mpo_sysvshm_init_label = mac_mls_init_label, - .mpo_ipq_init_label = mac_mls_init_label_waitcheck, - .mpo_mbuf_init_label = mac_mls_init_label_waitcheck, - .mpo_mount_init_label = mac_mls_init_label, - .mpo_pipe_init_label = mac_mls_init_label, - .mpo_posixsem_init_label = mac_mls_init_label, - .mpo_socket_init_label = mac_mls_init_label_waitcheck, - .mpo_socketpeer_init_label = mac_mls_init_label_waitcheck, - .mpo_vnode_init_label = mac_mls_init_label, - .mpo_bpfdesc_destroy_label = mac_mls_destroy_label, - .mpo_cred_destroy_label = mac_mls_destroy_label, - .mpo_devfs_destroy_label = mac_mls_destroy_label, - .mpo_ifnet_destroy_label = mac_mls_destroy_label, - .mpo_inpcb_destroy_label = mac_mls_destroy_label, - .mpo_destroy_syncache_label = mac_mls_destroy_label, - .mpo_sysvmsg_destroy_label = mac_mls_destroy_label, - .mpo_sysvmsq_destroy_label = mac_mls_destroy_label, - .mpo_sysvsem_destroy_label = mac_mls_destroy_label, - .mpo_sysvshm_destroy_label = mac_mls_destroy_label, - .mpo_ipq_destroy_label = mac_mls_destroy_label, - .mpo_mbuf_destroy_label = mac_mls_destroy_label, - .mpo_mount_destroy_label = mac_mls_destroy_label, - .mpo_pipe_destroy_label = mac_mls_destroy_label, - .mpo_posixsem_destroy_label = mac_mls_destroy_label, - .mpo_socket_destroy_label = mac_mls_destroy_label, - .mpo_socketpeer_destroy_label = mac_mls_destroy_label, - .mpo_vnode_destroy_label = mac_mls_destroy_label, - .mpo_cred_copy_label = mac_mls_copy_label, - .mpo_ifnet_copy_label = mac_mls_copy_label, - .mpo_mbuf_copy_label = mac_mls_copy_label, - .mpo_pipe_copy_label = mac_mls_copy_label, - .mpo_socket_copy_label = mac_mls_copy_label, - .mpo_vnode_copy_label = mac_mls_copy_label, - .mpo_cred_externalize_label = mac_mls_externalize_label, - .mpo_ifnet_externalize_label = mac_mls_externalize_label, - .mpo_pipe_externalize_label = mac_mls_externalize_label, - .mpo_socket_externalize_label = mac_mls_externalize_label, - .mpo_socketpeer_externalize_label = mac_mls_externalize_label, - .mpo_vnode_externalize_label = mac_mls_externalize_label, - .mpo_cred_internalize_label = mac_mls_internalize_label, - .mpo_ifnet_internalize_label = mac_mls_internalize_label, - .mpo_pipe_internalize_label = mac_mls_internalize_label, - .mpo_socket_internalize_label = mac_mls_internalize_label, - .mpo_vnode_internalize_label = mac_mls_internalize_label, - .mpo_devfs_create_device = mac_mls_devfs_create_device, - .mpo_devfs_create_directory = mac_mls_devfs_create_directory, - .mpo_devfs_create_symlink = mac_mls_devfs_create_symlink, - .mpo_mount_create = mac_mls_mount_create, - .mpo_vnode_relabel = mac_mls_vnode_relabel, - .mpo_devfs_update = mac_mls_devfs_update, - .mpo_devfs_vnode_associate = mac_mls_devfs_vnode_associate, - .mpo_vnode_associate_extattr = mac_mls_vnode_associate_extattr, - .mpo_vnode_associate_singlelabel = mac_mls_vnode_associate_singlelabel, - .mpo_vnode_create_extattr = mac_mls_vnode_create_extattr, - .mpo_vnode_setlabel_extattr = mac_mls_vnode_setlabel_extattr, - .mpo_socket_create_mbuf = mac_mls_socket_create_mbuf, - .mpo_create_mbuf_from_syncache = mac_mls_create_mbuf_from_syncache, - .mpo_pipe_create = mac_mls_pipe_create, - .mpo_posixsem_create = mac_mls_posixsem_create, - .mpo_socket_create = mac_mls_socket_create, - .mpo_socket_newconn = mac_mls_socket_newconn, - .mpo_pipe_relabel = mac_mls_pipe_relabel, - .mpo_socket_relabel = mac_mls_socket_relabel, - .mpo_socketpeer_set_from_mbuf = mac_mls_socketpeer_set_from_mbuf, - .mpo_socketpeer_set_from_socket = mac_mls_socketpeer_set_from_socket, - .mpo_bpfdesc_create = mac_mls_bpfdesc_create, - .mpo_ipq_reassemble = mac_mls_ipq_reassemble, - .mpo_netinet_fragment = mac_mls_netinet_fragment, - .mpo_ifnet_create = mac_mls_ifnet_create, - .mpo_inpcb_create = mac_mls_inpcb_create, - .mpo_init_syncache_from_inpcb = mac_mls_init_syncache_from_inpcb, - .mpo_ipq_create = mac_mls_ipq_create, - .mpo_sysvmsg_create = mac_mls_sysvmsg_create, - .mpo_sysvmsq_create = mac_mls_sysvmsq_create, - .mpo_sysvsem_create = mac_mls_sysvsem_create, - .mpo_sysvshm_create = mac_mls_sysvshm_create, - .mpo_inpcb_create_mbuf = mac_mls_inpcb_create_mbuf, - .mpo_create_mbuf_linklayer = mac_mls_create_mbuf_linklayer, - .mpo_bpfdesc_create_mbuf = mac_mls_bpfdesc_create_mbuf, - .mpo_ifnet_create_mbuf = mac_mls_ifnet_create_mbuf, - .mpo_mbuf_create_multicast_encap = mac_mls_mbuf_create_multicast_encap, - .mpo_mbuf_create_netlayer = mac_mls_mbuf_create_netlayer, - .mpo_ipq_match = mac_mls_ipq_match, - .mpo_ifnet_relabel = mac_mls_ifnet_relabel, - .mpo_ipq_update = mac_mls_ipq_update, - .mpo_inpcb_sosetlabel = mac_mls_inpcb_sosetlabel, - .mpo_proc_create_swapper = mac_mls_proc_create_swapper, - .mpo_proc_create_init = mac_mls_proc_create_init, - .mpo_cred_relabel = mac_mls_cred_relabel, - .mpo_sysvmsg_cleanup = mac_mls_sysvmsg_cleanup, - .mpo_sysvmsq_cleanup = mac_mls_sysvmsq_cleanup, - .mpo_sysvsem_cleanup = mac_mls_sysvsem_cleanup, - .mpo_sysvshm_cleanup = mac_mls_sysvshm_cleanup, - .mpo_bpfdesc_check_receive = mac_mls_bpfdesc_check_receive, - .mpo_cred_check_relabel = mac_mls_cred_check_relabel, - .mpo_cred_check_visible = mac_mls_cred_check_visible, - .mpo_ifnet_check_relabel = mac_mls_ifnet_check_relabel, - .mpo_ifnet_check_transmit = mac_mls_ifnet_check_transmit, - .mpo_inpcb_check_deliver = mac_mls_inpcb_check_deliver, - .mpo_sysvmsq_check_msgrcv = mac_mls_sysvmsq_check_msgrcv, - .mpo_sysvmsq_check_msgrmid = mac_mls_sysvmsq_check_msgrmid, - .mpo_sysvmsq_check_msqget = mac_mls_sysvmsq_check_msqget, - .mpo_sysvmsq_check_msqsnd = mac_mls_sysvmsq_check_msqsnd, - .mpo_sysvmsq_check_msqrcv = mac_mls_sysvmsq_check_msqrcv, - .mpo_sysvmsq_check_msqctl = mac_mls_sysvmsq_check_msqctl, - .mpo_sysvsem_check_semctl = mac_mls_sysvsem_check_semctl, - .mpo_sysvsem_check_semget = mac_mls_sysvsem_check_semget, - .mpo_sysvsem_check_semop = mac_mls_sysvsem_check_semop, - .mpo_sysvshm_check_shmat = mac_mls_sysvshm_check_shmat, - .mpo_sysvshm_check_shmctl = mac_mls_sysvshm_check_shmctl, - .mpo_sysvshm_check_shmget = mac_mls_sysvshm_check_shmget, - .mpo_mount_check_stat = mac_mls_mount_check_stat, - .mpo_pipe_check_ioctl = mac_mls_pipe_check_ioctl, - .mpo_pipe_check_poll = mac_mls_pipe_check_poll, - .mpo_pipe_check_read = mac_mls_pipe_check_read, - .mpo_pipe_check_relabel = mac_mls_pipe_check_relabel, - .mpo_pipe_check_stat = mac_mls_pipe_check_stat, - .mpo_pipe_check_write = mac_mls_pipe_check_write, - .mpo_posixsem_check_destroy = mac_mls_posixsem_check_write, - .mpo_posixsem_check_getvalue = mac_mls_posixsem_check_rdonly, - .mpo_posixsem_check_open = mac_mls_posixsem_check_write, - .mpo_posixsem_check_post = mac_mls_posixsem_check_write, - .mpo_posixsem_check_unlink = mac_mls_posixsem_check_write, - .mpo_posixsem_check_wait = mac_mls_posixsem_check_write, - .mpo_proc_check_debug = mac_mls_proc_check_debug, - .mpo_proc_check_sched = mac_mls_proc_check_sched, - .mpo_proc_check_signal = mac_mls_proc_check_signal, - .mpo_socket_check_deliver = mac_mls_socket_check_deliver, - .mpo_socket_check_relabel = mac_mls_socket_check_relabel, - .mpo_socket_check_visible = mac_mls_socket_check_visible, - .mpo_system_check_acct = mac_mls_system_check_acct, - .mpo_system_check_auditctl = mac_mls_system_check_auditctl, - .mpo_system_check_swapon = mac_mls_system_check_swapon, - .mpo_vnode_check_access = mac_mls_vnode_check_open, - .mpo_vnode_check_chdir = mac_mls_vnode_check_chdir, - .mpo_vnode_check_chroot = mac_mls_vnode_check_chroot, - .mpo_vnode_check_create = mac_mls_vnode_check_create, - .mpo_vnode_check_deleteacl = mac_mls_vnode_check_deleteacl, - .mpo_vnode_check_deleteextattr = mac_mls_vnode_check_deleteextattr, - .mpo_vnode_check_exec = mac_mls_vnode_check_exec, - .mpo_vnode_check_getacl = mac_mls_vnode_check_getacl, - .mpo_vnode_check_getextattr = mac_mls_vnode_check_getextattr, - .mpo_vnode_check_link = mac_mls_vnode_check_link, - .mpo_vnode_check_listextattr = mac_mls_vnode_check_listextattr, - .mpo_vnode_check_lookup = mac_mls_vnode_check_lookup, - .mpo_vnode_check_mmap = mac_mls_vnode_check_mmap, - .mpo_vnode_check_open = mac_mls_vnode_check_open, - .mpo_vnode_check_poll = mac_mls_vnode_check_poll, - .mpo_vnode_check_read = mac_mls_vnode_check_read, - .mpo_vnode_check_readdir = mac_mls_vnode_check_readdir, - .mpo_vnode_check_readlink = mac_mls_vnode_check_readlink, - .mpo_vnode_check_relabel = mac_mls_vnode_check_relabel, - .mpo_vnode_check_rename_from = mac_mls_vnode_check_rename_from, - .mpo_vnode_check_rename_to = mac_mls_vnode_check_rename_to, - .mpo_vnode_check_revoke = mac_mls_vnode_check_revoke, - .mpo_vnode_check_setacl = mac_mls_vnode_check_setacl, - .mpo_vnode_check_setextattr = mac_mls_vnode_check_setextattr, - .mpo_vnode_check_setflags = mac_mls_vnode_check_setflags, - .mpo_vnode_check_setmode = mac_mls_vnode_check_setmode, - .mpo_vnode_check_setowner = mac_mls_vnode_check_setowner, - .mpo_vnode_check_setutimes = mac_mls_vnode_check_setutimes, - .mpo_vnode_check_stat = mac_mls_vnode_check_stat, - .mpo_vnode_check_unlink = mac_mls_vnode_check_unlink, - .mpo_vnode_check_write = mac_mls_vnode_check_write, - .mpo_associate_nfsd_label = mac_mls_associate_nfsd_label, - .mpo_mbuf_create_from_firewall = mac_mls_mbuf_create_from_firewall, + mls_set_effective(label, MAC_MLS_TYPE_LOW, 0, NULL); + mls_set_range(label, MAC_MLS_TYPE_LOW, 0, NULL, MAC_MLS_TYPE_HIGH, 0, + NULL); +} + +static struct mac_policy_ops mls_ops = +{ + .mpo_init = mls_init, + .mpo_bpfdesc_init_label = mls_init_label, + .mpo_cred_init_label = mls_init_label, + .mpo_devfs_init_label = mls_init_label, + .mpo_ifnet_init_label = mls_init_label, + .mpo_inpcb_init_label = mls_init_label_waitcheck, + .mpo_init_syncache_label = mls_init_label_waitcheck, + .mpo_sysvmsg_init_label = mls_init_label, + .mpo_sysvmsq_init_label = mls_init_label, + .mpo_sysvsem_init_label = mls_init_label, + .mpo_sysvshm_init_label = mls_init_label, + .mpo_ipq_init_label = mls_init_label_waitcheck, + .mpo_mbuf_init_label = mls_init_label_waitcheck, + .mpo_mount_init_label = mls_init_label, + .mpo_pipe_init_label = mls_init_label, + .mpo_posixsem_init_label = mls_init_label, + .mpo_socket_init_label = mls_init_label_waitcheck, + .mpo_socketpeer_init_label = mls_init_label_waitcheck, + .mpo_vnode_init_label = mls_init_label, + .mpo_bpfdesc_destroy_label = mls_destroy_label, + .mpo_cred_destroy_label = mls_destroy_label, + .mpo_devfs_destroy_label = mls_destroy_label, + .mpo_ifnet_destroy_label = mls_destroy_label, + .mpo_inpcb_destroy_label = mls_destroy_label, + .mpo_destroy_syncache_label = mls_destroy_label, + .mpo_sysvmsg_destroy_label = mls_destroy_label, + .mpo_sysvmsq_destroy_label = mls_destroy_label, + .mpo_sysvsem_destroy_label = mls_destroy_label, + .mpo_sysvshm_destroy_label = mls_destroy_label, + .mpo_ipq_destroy_label = mls_destroy_label, + .mpo_mbuf_destroy_label = mls_destroy_label, + .mpo_mount_destroy_label = mls_destroy_label, + .mpo_pipe_destroy_label = mls_destroy_label, + .mpo_posixsem_destroy_label = mls_destroy_label, + .mpo_socket_destroy_label = mls_destroy_label, + .mpo_socketpeer_destroy_label = mls_destroy_label, + .mpo_vnode_destroy_label = mls_destroy_label, + .mpo_cred_copy_label = mls_copy_label, + .mpo_ifnet_copy_label = mls_copy_label, + .mpo_mbuf_copy_label = mls_copy_label, + .mpo_pipe_copy_label = mls_copy_label, + .mpo_socket_copy_label = mls_copy_label, + .mpo_vnode_copy_label = mls_copy_label, + .mpo_cred_externalize_label = mls_externalize_label, + .mpo_ifnet_externalize_label = mls_externalize_label, + .mpo_pipe_externalize_label = mls_externalize_label, + .mpo_socket_externalize_label = mls_externalize_label, + .mpo_socketpeer_externalize_label = mls_externalize_label, + .mpo_vnode_externalize_label = mls_externalize_label, + .mpo_cred_internalize_label = mls_internalize_label, + .mpo_ifnet_internalize_label = mls_internalize_label, + .mpo_pipe_internalize_label = mls_internalize_label, + .mpo_socket_internalize_label = mls_internalize_label, + .mpo_vnode_internalize_label = mls_internalize_label, + .mpo_devfs_create_device = mls_devfs_create_device, + .mpo_devfs_create_directory = mls_devfs_create_directory, + .mpo_devfs_create_symlink = mls_devfs_create_symlink, + .mpo_mount_create = mls_mount_create, + .mpo_vnode_relabel = mls_vnode_relabel, + .mpo_devfs_update = mls_devfs_update, + .mpo_devfs_vnode_associate = mls_devfs_vnode_associate, + .mpo_vnode_associate_extattr = mls_vnode_associate_extattr, + .mpo_vnode_associate_singlelabel = mls_vnode_associate_singlelabel, + .mpo_vnode_create_extattr = mls_vnode_create_extattr, + .mpo_vnode_setlabel_extattr = mls_vnode_setlabel_extattr, + .mpo_socket_create_mbuf = mls_socket_create_mbuf, + .mpo_create_mbuf_from_syncache = mls_create_mbuf_from_syncache, + .mpo_pipe_create = mls_pipe_create, + .mpo_posixsem_create = mls_posixsem_create, + .mpo_socket_create = mls_socket_create, + .mpo_socket_newconn = mls_socket_newconn, + .mpo_pipe_relabel = mls_pipe_relabel, + .mpo_socket_relabel = mls_socket_relabel, + .mpo_socketpeer_set_from_mbuf = mls_socketpeer_set_from_mbuf, + .mpo_socketpeer_set_from_socket = mls_socketpeer_set_from_socket, + .mpo_bpfdesc_create = mls_bpfdesc_create, + .mpo_ipq_reassemble = mls_ipq_reassemble, + .mpo_netinet_fragment = mls_netinet_fragment, + .mpo_ifnet_create = mls_ifnet_create, + .mpo_inpcb_create = mls_inpcb_create, + .mpo_init_syncache_from_inpcb = mls_init_syncache_from_inpcb, + .mpo_ipq_create = mls_ipq_create, + .mpo_sysvmsg_create = mls_sysvmsg_create, + .mpo_sysvmsq_create = mls_sysvmsq_create, + .mpo_sysvsem_create = mls_sysvsem_create, + .mpo_sysvshm_create = mls_sysvshm_create, + .mpo_inpcb_create_mbuf = mls_inpcb_create_mbuf, + .mpo_create_mbuf_linklayer = mls_create_mbuf_linklayer, + .mpo_bpfdesc_create_mbuf = mls_bpfdesc_create_mbuf, + .mpo_ifnet_create_mbuf = mls_ifnet_create_mbuf, + .mpo_mbuf_create_multicast_encap = mls_mbuf_create_multicast_encap, + .mpo_mbuf_create_netlayer = mls_mbuf_create_netlayer, + .mpo_ipq_match = mls_ipq_match, + .mpo_ifnet_relabel = mls_ifnet_relabel, + .mpo_ipq_update = mls_ipq_update, + .mpo_inpcb_sosetlabel = mls_inpcb_sosetlabel, + .mpo_proc_create_swapper = mls_proc_create_swapper, + .mpo_proc_create_init = mls_proc_create_init, + .mpo_cred_relabel = mls_cred_relabel, + .mpo_sysvmsg_cleanup = mls_sysvmsg_cleanup, + .mpo_sysvmsq_cleanup = mls_sysvmsq_cleanup, + .mpo_sysvsem_cleanup = mls_sysvsem_cleanup, + .mpo_sysvshm_cleanup = mls_sysvshm_cleanup, + .mpo_bpfdesc_check_receive = mls_bpfdesc_check_receive, + .mpo_cred_check_relabel = mls_cred_check_relabel, + .mpo_cred_check_visible = mls_cred_check_visible, + .mpo_ifnet_check_relabel = mls_ifnet_check_relabel, + .mpo_ifnet_check_transmit = mls_ifnet_check_transmit, + .mpo_inpcb_check_deliver = mls_inpcb_check_deliver, + .mpo_sysvmsq_check_msgrcv = mls_sysvmsq_check_msgrcv, + .mpo_sysvmsq_check_msgrmid = mls_sysvmsq_check_msgrmid, + .mpo_sysvmsq_check_msqget = mls_sysvmsq_check_msqget, + .mpo_sysvmsq_check_msqsnd = mls_sysvmsq_check_msqsnd, + .mpo_sysvmsq_check_msqrcv = mls_sysvmsq_check_msqrcv, + .mpo_sysvmsq_check_msqctl = mls_sysvmsq_check_msqctl, + .mpo_sysvsem_check_semctl = mls_sysvsem_check_semctl, + .mpo_sysvsem_check_semget = mls_sysvsem_check_semget, + .mpo_sysvsem_check_semop = mls_sysvsem_check_semop, + .mpo_sysvshm_check_shmat = mls_sysvshm_check_shmat, + .mpo_sysvshm_check_shmctl = mls_sysvshm_check_shmctl, + .mpo_sysvshm_check_shmget = mls_sysvshm_check_shmget, + .mpo_mount_check_stat = mls_mount_check_stat, + .mpo_pipe_check_ioctl = mls_pipe_check_ioctl, + .mpo_pipe_check_poll = mls_pipe_check_poll, + .mpo_pipe_check_read = mls_pipe_check_read, + .mpo_pipe_check_relabel = mls_pipe_check_relabel, + .mpo_pipe_check_stat = mls_pipe_check_stat, + .mpo_pipe_check_write = mls_pipe_check_write, + .mpo_posixsem_check_destroy = mls_posixsem_check_write, + .mpo_posixsem_check_getvalue = mls_posixsem_check_rdonly, + .mpo_posixsem_check_open = mls_posixsem_check_write, + .mpo_posixsem_check_post = mls_posixsem_check_write, + .mpo_posixsem_check_unlink = mls_posixsem_check_write, + .mpo_posixsem_check_wait = mls_posixsem_check_write, + .mpo_proc_check_debug = mls_proc_check_debug, + .mpo_proc_check_sched = mls_proc_check_sched, + .mpo_proc_check_signal = mls_proc_check_signal, + .mpo_socket_check_deliver = mls_socket_check_deliver, + .mpo_socket_check_relabel = mls_socket_check_relabel, + .mpo_socket_check_visible = mls_socket_check_visible, + .mpo_system_check_acct = mls_system_check_acct, + .mpo_system_check_auditctl = mls_system_check_auditctl, + .mpo_system_check_swapon = mls_system_check_swapon, + .mpo_vnode_check_access = mls_vnode_check_open, + .mpo_vnode_check_chdir = mls_vnode_check_chdir, + .mpo_vnode_check_chroot = mls_vnode_check_chroot, + .mpo_vnode_check_create = mls_vnode_check_create, + .mpo_vnode_check_deleteacl = mls_vnode_check_deleteacl, + .mpo_vnode_check_deleteextattr = mls_vnode_check_deleteextattr, + .mpo_vnode_check_exec = mls_vnode_check_exec, + .mpo_vnode_check_getacl = mls_vnode_check_getacl, + .mpo_vnode_check_getextattr = mls_vnode_check_getextattr, + .mpo_vnode_check_link = mls_vnode_check_link, + .mpo_vnode_check_listextattr = mls_vnode_check_listextattr, + .mpo_vnode_check_lookup = mls_vnode_check_lookup, + .mpo_vnode_check_mmap = mls_vnode_check_mmap, + .mpo_vnode_check_open = mls_vnode_check_open, + .mpo_vnode_check_poll = mls_vnode_check_poll, + .mpo_vnode_check_read = mls_vnode_check_read, + .mpo_vnode_check_readdir = mls_vnode_check_readdir, + .mpo_vnode_check_readlink = mls_vnode_check_readlink, + .mpo_vnode_check_relabel = mls_vnode_check_relabel, + .mpo_vnode_check_rename_from = mls_vnode_check_rename_from, + .mpo_vnode_check_rename_to = mls_vnode_check_rename_to, + .mpo_vnode_check_revoke = mls_vnode_check_revoke, + .mpo_vnode_check_setacl = mls_vnode_check_setacl, + .mpo_vnode_check_setextattr = mls_vnode_check_setextattr, + .mpo_vnode_check_setflags = mls_vnode_check_setflags, + .mpo_vnode_check_setmode = mls_vnode_check_setmode, + .mpo_vnode_check_setowner = mls_vnode_check_setowner, + .mpo_vnode_check_setutimes = mls_vnode_check_setutimes, + .mpo_vnode_check_stat = mls_vnode_check_stat, + .mpo_vnode_check_unlink = mls_vnode_check_unlink, + .mpo_vnode_check_write = mls_vnode_check_write, + .mpo_associate_nfsd_label = mls_associate_nfsd_label, + .mpo_mbuf_create_from_firewall = mls_mbuf_create_from_firewall, }; -MAC_POLICY_SET(&mac_mls_ops, mac_mls, "TrustedBSD MAC/MLS", - MPC_LOADTIME_FLAG_NOTLATE | MPC_LOADTIME_FLAG_LABELMBUFS, &mac_mls_slot); +MAC_POLICY_SET(&mls_ops, mac_mls, "TrustedBSD MAC/MLS", + MPC_LOADTIME_FLAG_NOTLATE | MPC_LOADTIME_FLAG_LABELMBUFS, &mls_slot); diff --git a/sys/security/mac_none/mac_none.c b/sys/security/mac_none/mac_none.c index d1036d8..8577c73 100644 --- a/sys/security/mac_none/mac_none.c +++ b/sys/security/mac_none/mac_none.c @@ -48,9 +48,9 @@ #include <security/mac/mac_policy.h> -static struct mac_policy_ops mac_none_ops = +static struct mac_policy_ops none_ops = { }; -MAC_POLICY_SET(&mac_none_ops, mac_none, "TrustedBSD MAC/None", +MAC_POLICY_SET(&none_ops, mac_none, "TrustedBSD MAC/None", MPC_LOADTIME_FLAG_UNLOADOK, NULL); diff --git a/sys/security/mac_partition/mac_partition.c b/sys/security/mac_partition/mac_partition.c index 986406a..a3bfbe4 100644 --- a/sys/security/mac_partition/mac_partition.c +++ b/sys/security/mac_partition/mac_partition.c @@ -40,6 +40,7 @@ /* * Developed by the TrustedBSD Project. + * * Experiment with a partition-like model. */ @@ -69,28 +70,28 @@ static int partition_slot; #define SLOT_SET(l, v) mac_label_set((l), partition_slot, (v)) static void -mac_partition_init_label(struct label *label) +partition_init_label(struct label *label) { SLOT_SET(label, 0); } static void -mac_partition_destroy_label(struct label *label) +partition_destroy_label(struct label *label) { SLOT_SET(label, 0); } static void -mac_partition_copy_label(struct label *src, struct label *dest) +partition_copy_label(struct label *src, struct label *dest) { SLOT_SET(dest, SLOT(src)); } static int -mac_partition_externalize_label(struct label *label, char *element_name, +partition_externalize_label(struct label *label, char *element_name, struct sbuf *sb, int *claimed) { @@ -106,7 +107,7 @@ mac_partition_externalize_label(struct label *label, char *element_name, } static int -mac_partition_internalize_label(struct label *label, char *element_name, +partition_internalize_label(struct label *label, char *element_name, char *element_data, int *claimed) { @@ -119,21 +120,21 @@ mac_partition_internalize_label(struct label *label, char *element_name, } static void -mac_partition_proc_create_swapper(struct ucred *cred) +partition_proc_create_swapper(struct ucred *cred) { SLOT_SET(cred->cr_label, 0); } static void -mac_partition_proc_create_init(struct ucred *cred) +partition_proc_create_init(struct ucred *cred) { SLOT_SET(cred->cr_label, 0); } static void -mac_partition_cred_relabel(struct ucred *cred, struct label *newlabel) +partition_cred_relabel(struct ucred *cred, struct label *newlabel) { if (SLOT(newlabel) != 0) @@ -157,7 +158,7 @@ label_on_label(struct label *subject, struct label *object) } static int -mac_partition_cred_check_relabel(struct ucred *cred, struct label *newlabel) +partition_cred_check_relabel(struct ucred *cred, struct label *newlabel) { int error; @@ -167,9 +168,9 @@ mac_partition_cred_check_relabel(struct ucred *cred, struct label *newlabel) if (SLOT(newlabel) != 0) { /* * Require BSD privilege in order to change the partition. - * Originally we also required that the process not be - * in a partition in the first place, but this didn't - * interact well with sendmail. + * Originally we also required that the process not be in a + * partition in the first place, but this didn't interact + * well with sendmail. */ error = priv_check_cred(cred, PRIV_MAC_PARTITION, 0); } @@ -178,7 +179,7 @@ mac_partition_cred_check_relabel(struct ucred *cred, struct label *newlabel) } static int -mac_partition_cred_check_visible(struct ucred *cr1, struct ucred *cr2) +partition_cred_check_visible(struct ucred *cr1, struct ucred *cr2) { int error; @@ -188,7 +189,7 @@ mac_partition_cred_check_visible(struct ucred *cr1, struct ucred *cr2) } static int -mac_partition_proc_check_debug(struct ucred *cred, struct proc *p) +partition_proc_check_debug(struct ucred *cred, struct proc *p) { int error; @@ -198,7 +199,7 @@ mac_partition_proc_check_debug(struct ucred *cred, struct proc *p) } static int -mac_partition_proc_check_sched(struct ucred *cred, struct proc *p) +partition_proc_check_sched(struct ucred *cred, struct proc *p) { int error; @@ -208,7 +209,7 @@ mac_partition_proc_check_sched(struct ucred *cred, struct proc *p) } static int -mac_partition_proc_check_signal(struct ucred *cred, struct proc *p, +partition_proc_check_signal(struct ucred *cred, struct proc *p, int signum) { int error; @@ -219,7 +220,7 @@ mac_partition_proc_check_signal(struct ucred *cred, struct proc *p, } static int -mac_partition_socket_check_visible(struct ucred *cred, struct socket *so, +partition_socket_check_visible(struct ucred *cred, struct socket *so, struct label *solabel) { int error; @@ -230,7 +231,7 @@ mac_partition_socket_check_visible(struct ucred *cred, struct socket *so, } static int -mac_partition_vnode_check_exec(struct ucred *cred, struct vnode *vp, +partition_vnode_check_exec(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct image_params *imgp, struct label *execlabel) { @@ -248,24 +249,24 @@ mac_partition_vnode_check_exec(struct ucred *cred, struct vnode *vp, return (0); } -static struct mac_policy_ops mac_partition_ops = +static struct mac_policy_ops partition_ops = { - .mpo_cred_init_label = mac_partition_init_label, - .mpo_cred_destroy_label = mac_partition_destroy_label, - .mpo_cred_copy_label = mac_partition_copy_label, - .mpo_cred_externalize_label = mac_partition_externalize_label, - .mpo_cred_internalize_label = mac_partition_internalize_label, - .mpo_proc_create_swapper = mac_partition_proc_create_swapper, - .mpo_proc_create_init = mac_partition_proc_create_init, - .mpo_cred_relabel = mac_partition_cred_relabel, - .mpo_cred_check_relabel = mac_partition_cred_check_relabel, - .mpo_cred_check_visible = mac_partition_cred_check_visible, - .mpo_proc_check_debug = mac_partition_proc_check_debug, - .mpo_proc_check_sched = mac_partition_proc_check_sched, - .mpo_proc_check_signal = mac_partition_proc_check_signal, - .mpo_socket_check_visible = mac_partition_socket_check_visible, - .mpo_vnode_check_exec = mac_partition_vnode_check_exec, + .mpo_cred_init_label = partition_init_label, + .mpo_cred_destroy_label = partition_destroy_label, + .mpo_cred_copy_label = partition_copy_label, + .mpo_cred_externalize_label = partition_externalize_label, + .mpo_cred_internalize_label = partition_internalize_label, + .mpo_proc_create_swapper = partition_proc_create_swapper, + .mpo_proc_create_init = partition_proc_create_init, + .mpo_cred_relabel = partition_cred_relabel, + .mpo_cred_check_relabel = partition_cred_check_relabel, + .mpo_cred_check_visible = partition_cred_check_visible, + .mpo_proc_check_debug = partition_proc_check_debug, + .mpo_proc_check_sched = partition_proc_check_sched, + .mpo_proc_check_signal = partition_proc_check_signal, + .mpo_socket_check_visible = partition_socket_check_visible, + .mpo_vnode_check_exec = partition_vnode_check_exec, }; -MAC_POLICY_SET(&mac_partition_ops, mac_partition, "TrustedBSD MAC/Partition", +MAC_POLICY_SET(&partition_ops, mac_partition, "TrustedBSD MAC/Partition", MPC_LOADTIME_FLAG_UNLOADOK, &partition_slot); diff --git a/sys/security/mac_portacl/mac_portacl.c b/sys/security/mac_portacl/mac_portacl.c index 0d4428d..7afc63b 100644 --- a/sys/security/mac_portacl/mac_portacl.c +++ b/sys/security/mac_portacl/mac_portacl.c @@ -48,15 +48,15 @@ * out-going connections where the process hasn't explicitly selected a port: * these are automatically selected by the IP stack. * - * To use this module, security.mac.enforce_socket must be enabled, and - * you will probably want to twiddle the net.inet sysctl listed above. - * Then use sysctl(8) to modify the rules string: + * To use this module, security.mac.enforce_socket must be enabled, and you + * will probably want to twiddle the net.inet sysctl listed above. Then use + * sysctl(8) to modify the rules string: * * # sysctl security.mac.portacl.rules="uid:425:tcp:80,uid:425:tcp:79" * - * This ruleset, for example, permits uid 425 to bind TCP ports 80 (http) - * and 79 (finger). User names and group names can't be used directly - * because the kernel only knows about uids and gids. + * This ruleset, for example, permits uid 425 to bind TCP ports 80 (http) and + * 79 (finger). User names and group names can't be used directly because + * the kernel only knows about uids and gids. */ #include <sys/param.h> @@ -86,30 +86,30 @@ SYSCTL_DECL(_security_mac); SYSCTL_NODE(_security_mac, OID_AUTO, portacl, CTLFLAG_RW, 0, "TrustedBSD mac_portacl policy controls"); -static int mac_portacl_enabled = 1; +static int portacl_enabled = 1; SYSCTL_INT(_security_mac_portacl, OID_AUTO, enabled, CTLFLAG_RW, - &mac_portacl_enabled, 0, "Enforce portacl policy"); -TUNABLE_INT("security.mac.portacl.enabled", &mac_portacl_enabled); + &portacl_enabled, 0, "Enforce portacl policy"); +TUNABLE_INT("security.mac.portacl.enabled", &portacl_enabled); -static int mac_portacl_suser_exempt = 1; +static int portacl_suser_exempt = 1; SYSCTL_INT(_security_mac_portacl, OID_AUTO, suser_exempt, CTLFLAG_RW, - &mac_portacl_suser_exempt, 0, "Privilege permits binding of any port"); + &portacl_suser_exempt, 0, "Privilege permits binding of any port"); TUNABLE_INT("security.mac.portacl.suser_exempt", - &mac_portacl_suser_exempt); + &portacl_suser_exempt); -static int mac_portacl_autoport_exempt = 1; +static int portacl_autoport_exempt = 1; SYSCTL_INT(_security_mac_portacl, OID_AUTO, autoport_exempt, CTLFLAG_RW, - &mac_portacl_autoport_exempt, 0, "Allow automatic allocation through " + &portacl_autoport_exempt, 0, "Allow automatic allocation through " "binding port 0 if not IP_PORTRANGELOW"); TUNABLE_INT("security.mac.portacl.autoport_exempt", - &mac_portacl_autoport_exempt); + &portacl_autoport_exempt); -static int mac_portacl_port_high = 1023; +static int portacl_port_high = 1023; SYSCTL_INT(_security_mac_portacl, OID_AUTO, port_high, CTLFLAG_RW, - &mac_portacl_port_high, 0, "Highest port to enforce for"); -TUNABLE_INT("security.mac.portacl.port_high", &mac_portacl_port_high); + &portacl_port_high, 0, "Highest port to enforce for"); +TUNABLE_INT("security.mac.portacl.port_high", &portacl_port_high); -MALLOC_DEFINE(M_PORTACL, "mac_portacl_rule", "Rules for mac_portacl"); +MALLOC_DEFINE(M_PORTACL, "portacl_rule", "Rules for mac_portacl"); #define MAC_RULE_STRING_LEN 1024 @@ -389,7 +389,7 @@ rules_check(struct ucred *cred, int family, int type, u_int16_t port) cred->cr_uid, family, type, port); #endif - if (port > mac_portacl_port_high) + if (port > portacl_port_high) return (0); error = EPERM; @@ -422,7 +422,7 @@ rules_check(struct ucred *cred, int family, int type, u_int16_t port) } mtx_unlock(&rule_mtx); - if (error != 0 && mac_portacl_suser_exempt != 0) + if (error != 0 && portacl_suser_exempt != 0) error = priv_check_cred(cred, PRIV_NETINET_RESERVEDPORT, 0); return (error); @@ -443,7 +443,7 @@ socket_check_bind(struct ucred *cred, struct socket *so, u_int16_t port; /* Only run if we are enabled. */ - if (mac_portacl_enabled == 0) + if (portacl_enabled == 0) return (0); /* Only interested in IPv4 and IPv6 sockets. */ @@ -473,7 +473,7 @@ socket_check_bind(struct ucred *cred, struct socket *so, * flag exempts port 0 allocation from rule checking as long as a low * port isn't required. */ - if (mac_portacl_autoport_exempt && port == 0) { + if (portacl_autoport_exempt && port == 0) { inp = sotoinpcb(so); if ((inp->inp_flags & INP_LOWPORT) == 0) return (0); @@ -482,12 +482,12 @@ socket_check_bind(struct ucred *cred, struct socket *so, return (rules_check(cred, family, type, port)); } -static struct mac_policy_ops mac_portacl_ops = +static struct mac_policy_ops portacl_ops = { .mpo_destroy = destroy, .mpo_init = init, .mpo_socket_check_bind = socket_check_bind, }; -MAC_POLICY_SET(&mac_portacl_ops, trustedbsd_mac_portacl, - "TrustedBSD MAC/portacl", MPC_LOADTIME_FLAG_UNLOADOK, NULL); +MAC_POLICY_SET(&portacl_ops, mac_portacl, "TrustedBSD MAC/portacl", + MPC_LOADTIME_FLAG_UNLOADOK, NULL); diff --git a/sys/security/mac_seeotheruids/mac_seeotheruids.c b/sys/security/mac_seeotheruids/mac_seeotheruids.c index 8681b86..ae88ac3 100644 --- a/sys/security/mac_seeotheruids/mac_seeotheruids.c +++ b/sys/security/mac_seeotheruids/mac_seeotheruids.c @@ -61,9 +61,9 @@ SYSCTL_DECL(_security_mac); SYSCTL_NODE(_security_mac, OID_AUTO, seeotheruids, CTLFLAG_RW, 0, "TrustedBSD mac_seeotheruids policy controls"); -static int mac_seeotheruids_enabled = 1; +static int seeotheruids_enabled = 1; SYSCTL_INT(_security_mac_seeotheruids, OID_AUTO, enabled, CTLFLAG_RW, - &mac_seeotheruids_enabled, 0, "Enforce seeotheruids policy"); + &seeotheruids_enabled, 0, "Enforce seeotheruids policy"); /* * Exception: allow credentials to be aware of other credentials with the @@ -97,10 +97,10 @@ SYSCTL_INT(_security_mac_seeotheruids, OID_AUTO, specificgid, CTLFLAG_RW, &specificgid, 0, "Specific gid to be exempt from seeotheruids policy"); static int -mac_seeotheruids_check(struct ucred *cr1, struct ucred *cr2) +seeotheruids_check(struct ucred *cr1, struct ucred *cr2) { - if (!mac_seeotheruids_enabled) + if (!seeotheruids_enabled) return (0); if (primarygroup_enabled) { @@ -126,50 +126,50 @@ mac_seeotheruids_check(struct ucred *cr1, struct ucred *cr2) } static int -mac_seeotheruids_cred_check_visible(struct ucred *cr1, struct ucred *cr2) +seeotheruids_cred_check_visible(struct ucred *cr1, struct ucred *cr2) { - return (mac_seeotheruids_check(cr1, cr2)); + return (seeotheruids_check(cr1, cr2)); } static int -mac_seeotheruids_proc_check_signal(struct ucred *cred, struct proc *p, +seeotheruids_proc_check_signal(struct ucred *cred, struct proc *p, int signum) { - return (mac_seeotheruids_check(cred, p->p_ucred)); + return (seeotheruids_check(cred, p->p_ucred)); } static int -mac_seeotheruids_proc_check_sched(struct ucred *cred, struct proc *p) +seeotheruids_proc_check_sched(struct ucred *cred, struct proc *p) { - return (mac_seeotheruids_check(cred, p->p_ucred)); + return (seeotheruids_check(cred, p->p_ucred)); } static int -mac_seeotheruids_proc_check_debug(struct ucred *cred, struct proc *p) +seeotheruids_proc_check_debug(struct ucred *cred, struct proc *p) { - return (mac_seeotheruids_check(cred, p->p_ucred)); + return (seeotheruids_check(cred, p->p_ucred)); } static int -mac_seeotheruids_socket_check_visible(struct ucred *cred, struct socket *so, +seeotheruids_socket_check_visible(struct ucred *cred, struct socket *so, struct label *solabel) { - return (mac_seeotheruids_check(cred, so->so_cred)); + return (seeotheruids_check(cred, so->so_cred)); } -static struct mac_policy_ops mac_seeotheruids_ops = +static struct mac_policy_ops seeotheruids_ops = { - .mpo_cred_check_visible = mac_seeotheruids_cred_check_visible, - .mpo_proc_check_debug = mac_seeotheruids_proc_check_debug, - .mpo_proc_check_sched = mac_seeotheruids_proc_check_sched, - .mpo_proc_check_signal = mac_seeotheruids_proc_check_signal, - .mpo_socket_check_visible = mac_seeotheruids_socket_check_visible, + .mpo_cred_check_visible = seeotheruids_cred_check_visible, + .mpo_proc_check_debug = seeotheruids_proc_check_debug, + .mpo_proc_check_sched = seeotheruids_proc_check_sched, + .mpo_proc_check_signal = seeotheruids_proc_check_signal, + .mpo_socket_check_visible = seeotheruids_socket_check_visible, }; -MAC_POLICY_SET(&mac_seeotheruids_ops, mac_seeotheruids, +MAC_POLICY_SET(&seeotheruids_ops, mac_seeotheruids, "TrustedBSD MAC/seeotheruids", MPC_LOADTIME_FLAG_UNLOADOK, NULL); diff --git a/sys/security/mac_stub/mac_stub.c b/sys/security/mac_stub/mac_stub.c index 584053b..40b4e6c 100644 --- a/sys/security/mac_stub/mac_stub.c +++ b/sys/security/mac_stub/mac_stub.c @@ -1434,7 +1434,7 @@ stub_priv_grant(struct ucred *cred, int priv) return (EPERM); } -static struct mac_policy_ops mac_stub_ops = +static struct mac_policy_ops stub_ops = { .mpo_destroy = stub_destroy, .mpo_init = stub_init, @@ -1660,5 +1660,5 @@ static struct mac_policy_ops mac_stub_ops = .mpo_create_mbuf_from_syncache = stub_create_mbuf_from_syncache, }; -MAC_POLICY_SET(&mac_stub_ops, mac_stub, "TrustedBSD MAC/Stub", +MAC_POLICY_SET(&stub_ops, mac_stub, "TrustedBSD MAC/Stub", MPC_LOADTIME_FLAG_UNLOADOK, NULL); diff --git a/sys/security/mac_test/mac_test.c b/sys/security/mac_test/mac_test.c index 944fb8b..5369ff6 100644 --- a/sys/security/mac_test/mac_test.c +++ b/sys/security/mac_test/mac_test.c @@ -152,7 +152,7 @@ SYSCTL_NODE(_security_mac_test, OID_AUTO, counter, CTLFLAG_RW, 0, */ COUNTER_DECL(bpfdesc_init_label); static void -mac_test_bpfdesc_init_label(struct label *label) +test_bpfdesc_init_label(struct label *label) { LABEL_INIT(label, MAGIC_BPF); @@ -161,7 +161,7 @@ mac_test_bpfdesc_init_label(struct label *label) COUNTER_DECL(cred_init_label); static void -mac_test_cred_init_label(struct label *label) +test_cred_init_label(struct label *label) { LABEL_INIT(label, MAGIC_CRED); @@ -170,7 +170,7 @@ mac_test_cred_init_label(struct label *label) COUNTER_DECL(devfs_init_label); static void -mac_test_devfs_init_label(struct label *label) +test_devfs_init_label(struct label *label) { LABEL_INIT(label, MAGIC_DEVFS); @@ -179,7 +179,7 @@ mac_test_devfs_init_label(struct label *label) COUNTER_DECL(ifnet_init_label); static void -mac_test_ifnet_init_label(struct label *label) +test_ifnet_init_label(struct label *label) { LABEL_INIT(label, MAGIC_IFNET); @@ -188,12 +188,12 @@ mac_test_ifnet_init_label(struct label *label) COUNTER_DECL(inpcb_init_label); static int -mac_test_inpcb_init_label(struct label *label, int flag) +test_inpcb_init_label(struct label *label, int flag) { if (flag & M_WAITOK) WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "mac_test_inpcb_init_label() at %s:%d", __FILE__, + "test_inpcb_init_label() at %s:%d", __FILE__, __LINE__); LABEL_INIT(label, MAGIC_INPCB); @@ -203,7 +203,7 @@ mac_test_inpcb_init_label(struct label *label, int flag) COUNTER_DECL(sysvmsg_init_label); static void -mac_test_sysvmsg_init_label(struct label *label) +test_sysvmsg_init_label(struct label *label) { LABEL_INIT(label, MAGIC_SYSV_MSG); COUNTER_INC(sysvmsg_init_label); @@ -211,7 +211,7 @@ mac_test_sysvmsg_init_label(struct label *label) COUNTER_DECL(sysvmsq_init_label); static void -mac_test_sysvmsq_init_label(struct label *label) +test_sysvmsq_init_label(struct label *label) { LABEL_INIT(label, MAGIC_SYSV_MSQ); COUNTER_INC(sysvmsq_init_label); @@ -219,7 +219,7 @@ mac_test_sysvmsq_init_label(struct label *label) COUNTER_DECL(sysvsem_init_label); static void -mac_test_sysvsem_init_label(struct label *label) +test_sysvsem_init_label(struct label *label) { LABEL_INIT(label, MAGIC_SYSV_SEM); COUNTER_INC(sysvsem_init_label); @@ -227,7 +227,7 @@ mac_test_sysvsem_init_label(struct label *label) COUNTER_DECL(sysvshm_init_label); static void -mac_test_sysvshm_init_label(struct label *label) +test_sysvshm_init_label(struct label *label) { LABEL_INIT(label, MAGIC_SYSV_SHM); COUNTER_INC(sysvshm_init_label); @@ -235,12 +235,12 @@ mac_test_sysvshm_init_label(struct label *label) COUNTER_DECL(ipq_init_label); static int -mac_test_ipq_init_label(struct label *label, int flag) +test_ipq_init_label(struct label *label, int flag) { if (flag & M_WAITOK) WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "mac_test_ipq_init_label() at %s:%d", __FILE__, + "test_ipq_init_label() at %s:%d", __FILE__, __LINE__); LABEL_INIT(label, MAGIC_IPQ); @@ -250,12 +250,12 @@ mac_test_ipq_init_label(struct label *label, int flag) COUNTER_DECL(mbuf_init_label); static int -mac_test_mbuf_init_label(struct label *label, int flag) +test_mbuf_init_label(struct label *label, int flag) { if (flag & M_WAITOK) WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "mac_test_mbuf_init_label() at %s:%d", __FILE__, + "test_mbuf_init_label() at %s:%d", __FILE__, __LINE__); LABEL_INIT(label, MAGIC_MBUF); @@ -265,7 +265,7 @@ mac_test_mbuf_init_label(struct label *label, int flag) COUNTER_DECL(mount_init_label); static void -mac_test_mount_init_label(struct label *label) +test_mount_init_label(struct label *label) { LABEL_INIT(label, MAGIC_MOUNT); @@ -274,12 +274,12 @@ mac_test_mount_init_label(struct label *label) COUNTER_DECL(socket_init_label); static int -mac_test_socket_init_label(struct label *label, int flag) +test_socket_init_label(struct label *label, int flag) { if (flag & M_WAITOK) WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "mac_test_socket_init_label() at %s:%d", __FILE__, + "test_socket_init_label() at %s:%d", __FILE__, __LINE__); LABEL_INIT(label, MAGIC_SOCKET); @@ -289,12 +289,12 @@ mac_test_socket_init_label(struct label *label, int flag) COUNTER_DECL(socketpeer_init_label); static int -mac_test_socketpeer_init_label(struct label *label, int flag) +test_socketpeer_init_label(struct label *label, int flag) { if (flag & M_WAITOK) WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, - "mac_test_socketpeer_init_label() at %s:%d", __FILE__, + "test_socketpeer_init_label() at %s:%d", __FILE__, __LINE__); LABEL_INIT(label, MAGIC_SOCKET); @@ -304,7 +304,7 @@ mac_test_socketpeer_init_label(struct label *label, int flag) COUNTER_DECL(pipe_init_label); static void -mac_test_pipe_init_label(struct label *label) +test_pipe_init_label(struct label *label) { LABEL_INIT(label, MAGIC_PIPE); @@ -313,7 +313,7 @@ mac_test_pipe_init_label(struct label *label) COUNTER_DECL(posixsem_init_label); static void -mac_test_posixsem_init_label(struct label *label) +test_posixsem_init_label(struct label *label) { LABEL_INIT(label, MAGIC_POSIX_SEM); @@ -322,7 +322,7 @@ mac_test_posixsem_init_label(struct label *label) COUNTER_DECL(proc_init_label); static void -mac_test_proc_init_label(struct label *label) +test_proc_init_label(struct label *label) { LABEL_INIT(label, MAGIC_PROC); @@ -331,7 +331,7 @@ mac_test_proc_init_label(struct label *label) COUNTER_DECL(vnode_init_label); static void -mac_test_vnode_init_label(struct label *label) +test_vnode_init_label(struct label *label) { LABEL_INIT(label, MAGIC_VNODE); @@ -340,7 +340,7 @@ mac_test_vnode_init_label(struct label *label) COUNTER_DECL(bpfdesc_destroy_label); static void -mac_test_bpfdesc_destroy_label(struct label *label) +test_bpfdesc_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_BPF); @@ -349,7 +349,7 @@ mac_test_bpfdesc_destroy_label(struct label *label) COUNTER_DECL(cred_destroy_label); static void -mac_test_cred_destroy_label(struct label *label) +test_cred_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_CRED); @@ -358,7 +358,7 @@ mac_test_cred_destroy_label(struct label *label) COUNTER_DECL(devfs_destroy_label); static void -mac_test_devfs_destroy_label(struct label *label) +test_devfs_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_DEVFS); @@ -367,7 +367,7 @@ mac_test_devfs_destroy_label(struct label *label) COUNTER_DECL(ifnet_destroy_label); static void -mac_test_ifnet_destroy_label(struct label *label) +test_ifnet_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_IFNET); @@ -376,7 +376,7 @@ mac_test_ifnet_destroy_label(struct label *label) COUNTER_DECL(inpcb_destroy_label); static void -mac_test_inpcb_destroy_label(struct label *label) +test_inpcb_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_INPCB); @@ -385,7 +385,7 @@ mac_test_inpcb_destroy_label(struct label *label) COUNTER_DECL(sysvmsg_destroy_label); static void -mac_test_sysvmsg_destroy_label(struct label *label) +test_sysvmsg_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_SYSV_MSG); @@ -394,7 +394,7 @@ mac_test_sysvmsg_destroy_label(struct label *label) COUNTER_DECL(sysvmsq_destroy_label); static void -mac_test_sysvmsq_destroy_label(struct label *label) +test_sysvmsq_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_SYSV_MSQ); @@ -403,7 +403,7 @@ mac_test_sysvmsq_destroy_label(struct label *label) COUNTER_DECL(sysvsem_destroy_label); static void -mac_test_sysvsem_destroy_label(struct label *label) +test_sysvsem_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_SYSV_SEM); @@ -412,7 +412,7 @@ mac_test_sysvsem_destroy_label(struct label *label) COUNTER_DECL(sysvshm_destroy_label); static void -mac_test_sysvshm_destroy_label(struct label *label) +test_sysvshm_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_SYSV_SHM); @@ -421,7 +421,7 @@ mac_test_sysvshm_destroy_label(struct label *label) COUNTER_DECL(ipq_destroy_label); static void -mac_test_ipq_destroy_label(struct label *label) +test_ipq_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_IPQ); @@ -430,7 +430,7 @@ mac_test_ipq_destroy_label(struct label *label) COUNTER_DECL(mbuf_destroy_label); static void -mac_test_mbuf_destroy_label(struct label *label) +test_mbuf_destroy_label(struct label *label) { /* @@ -447,7 +447,7 @@ mac_test_mbuf_destroy_label(struct label *label) COUNTER_DECL(mount_destroy_label); static void -mac_test_mount_destroy_label(struct label *label) +test_mount_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_MOUNT); @@ -456,7 +456,7 @@ mac_test_mount_destroy_label(struct label *label) COUNTER_DECL(socket_destroy_label); static void -mac_test_socket_destroy_label(struct label *label) +test_socket_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_SOCKET); @@ -465,7 +465,7 @@ mac_test_socket_destroy_label(struct label *label) COUNTER_DECL(socketpeer_destroy_label); static void -mac_test_socketpeer_destroy_label(struct label *label) +test_socketpeer_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_SOCKET); @@ -474,7 +474,7 @@ mac_test_socketpeer_destroy_label(struct label *label) COUNTER_DECL(pipe_destroy_label); static void -mac_test_pipe_destroy_label(struct label *label) +test_pipe_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_PIPE); @@ -483,7 +483,7 @@ mac_test_pipe_destroy_label(struct label *label) COUNTER_DECL(posixsem_destroy_label); static void -mac_test_posixsem_destroy_label(struct label *label) +test_posixsem_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_POSIX_SEM); @@ -492,7 +492,7 @@ mac_test_posixsem_destroy_label(struct label *label) COUNTER_DECL(proc_destroy_label); static void -mac_test_proc_destroy_label(struct label *label) +test_proc_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_PROC); @@ -501,7 +501,7 @@ mac_test_proc_destroy_label(struct label *label) COUNTER_DECL(vnode_destroy_label); static void -mac_test_vnode_destroy_label(struct label *label) +test_vnode_destroy_label(struct label *label) { LABEL_DESTROY(label, MAGIC_VNODE); @@ -510,7 +510,7 @@ mac_test_vnode_destroy_label(struct label *label) COUNTER_DECL(cred_copy_label); static void -mac_test_cred_copy_label(struct label *src, struct label *dest) +test_cred_copy_label(struct label *src, struct label *dest) { LABEL_CHECK(src, MAGIC_CRED); @@ -520,7 +520,7 @@ mac_test_cred_copy_label(struct label *src, struct label *dest) COUNTER_DECL(ifnet_copy_label); static void -mac_test_ifnet_copy_label(struct label *src, struct label *dest) +test_ifnet_copy_label(struct label *src, struct label *dest) { LABEL_CHECK(src, MAGIC_IFNET); @@ -530,7 +530,7 @@ mac_test_ifnet_copy_label(struct label *src, struct label *dest) COUNTER_DECL(mbuf_copy_label); static void -mac_test_mbuf_copy_label(struct label *src, struct label *dest) +test_mbuf_copy_label(struct label *src, struct label *dest) { LABEL_CHECK(src, MAGIC_MBUF); @@ -540,7 +540,7 @@ mac_test_mbuf_copy_label(struct label *src, struct label *dest) COUNTER_DECL(pipe_copy_label); static void -mac_test_pipe_copy_label(struct label *src, struct label *dest) +test_pipe_copy_label(struct label *src, struct label *dest) { LABEL_CHECK(src, MAGIC_PIPE); @@ -550,7 +550,7 @@ mac_test_pipe_copy_label(struct label *src, struct label *dest) COUNTER_DECL(socket_copy_label); static void -mac_test_socket_copy_label(struct label *src, struct label *dest) +test_socket_copy_label(struct label *src, struct label *dest) { LABEL_CHECK(src, MAGIC_SOCKET); @@ -560,7 +560,7 @@ mac_test_socket_copy_label(struct label *src, struct label *dest) COUNTER_DECL(vnode_copy_label); static void -mac_test_vnode_copy_label(struct label *src, struct label *dest) +test_vnode_copy_label(struct label *src, struct label *dest) { LABEL_CHECK(src, MAGIC_VNODE); @@ -570,7 +570,7 @@ mac_test_vnode_copy_label(struct label *src, struct label *dest) COUNTER_DECL(externalize_label); static int -mac_test_externalize_label(struct label *label, char *element_name, +test_externalize_label(struct label *label, char *element_name, struct sbuf *sb, int *claimed) { @@ -582,7 +582,7 @@ mac_test_externalize_label(struct label *label, char *element_name, COUNTER_DECL(internalize_label); static int -mac_test_internalize_label(struct label *label, char *element_name, +test_internalize_label(struct label *label, char *element_name, char *element_data, int *claimed) { @@ -598,7 +598,7 @@ mac_test_internalize_label(struct label *label, char *element_name, */ COUNTER_DECL(devfs_vnode_associate); static void -mac_test_devfs_vnode_associate(struct mount *mp, struct label *mplabel, +test_devfs_vnode_associate(struct mount *mp, struct label *mplabel, struct devfs_dirent *de, struct label *delabel, struct vnode *vp, struct label *vplabel) { @@ -611,7 +611,7 @@ mac_test_devfs_vnode_associate(struct mount *mp, struct label *mplabel, COUNTER_DECL(vnode_associate_extattr); static int -mac_test_vnode_associate_extattr(struct mount *mp, struct label *mplabel, +test_vnode_associate_extattr(struct mount *mp, struct label *mplabel, struct vnode *vp, struct label *vplabel) { @@ -624,7 +624,7 @@ mac_test_vnode_associate_extattr(struct mount *mp, struct label *mplabel, COUNTER_DECL(vnode_associate_singlelabel); static void -mac_test_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, +test_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, struct vnode *vp, struct label *vplabel) { @@ -635,7 +635,7 @@ mac_test_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, COUNTER_DECL(devfs_create_device); static void -mac_test_devfs_create_device(struct ucred *cred, struct mount *mp, +test_devfs_create_device(struct ucred *cred, struct mount *mp, struct cdev *dev, struct devfs_dirent *de, struct label *delabel) { @@ -647,7 +647,7 @@ mac_test_devfs_create_device(struct ucred *cred, struct mount *mp, COUNTER_DECL(devfs_create_directory); static void -mac_test_devfs_create_directory(struct mount *mp, char *dirname, +test_devfs_create_directory(struct mount *mp, char *dirname, int dirnamelen, struct devfs_dirent *de, struct label *delabel) { @@ -657,7 +657,7 @@ mac_test_devfs_create_directory(struct mount *mp, char *dirname, COUNTER_DECL(devfs_create_symlink); static void -mac_test_devfs_create_symlink(struct ucred *cred, struct mount *mp, +test_devfs_create_symlink(struct ucred *cred, struct mount *mp, struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de, struct label *delabel) { @@ -670,7 +670,7 @@ mac_test_devfs_create_symlink(struct ucred *cred, struct mount *mp, COUNTER_DECL(vnode_create_extattr); static int -mac_test_vnode_create_extattr(struct ucred *cred, struct mount *mp, +test_vnode_create_extattr(struct ucred *cred, struct mount *mp, struct label *mplabel, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { @@ -685,7 +685,7 @@ mac_test_vnode_create_extattr(struct ucred *cred, struct mount *mp, COUNTER_DECL(mount_create); static void -mac_test_mount_create(struct ucred *cred, struct mount *mp, +test_mount_create(struct ucred *cred, struct mount *mp, struct label *mplabel) { @@ -696,7 +696,7 @@ mac_test_mount_create(struct ucred *cred, struct mount *mp, COUNTER_DECL(vnode_relabel); static void -mac_test_vnode_relabel(struct ucred *cred, struct vnode *vp, +test_vnode_relabel(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *label) { @@ -708,7 +708,7 @@ mac_test_vnode_relabel(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_setlabel_extattr); static int -mac_test_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, +test_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *intlabel) { @@ -722,7 +722,7 @@ mac_test_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, COUNTER_DECL(devfs_update); static void -mac_test_devfs_update(struct mount *mp, struct devfs_dirent *devfs_dirent, +test_devfs_update(struct mount *mp, struct devfs_dirent *devfs_dirent, struct label *direntlabel, struct vnode *vp, struct label *vplabel) { @@ -736,7 +736,7 @@ mac_test_devfs_update(struct mount *mp, struct devfs_dirent *devfs_dirent, */ COUNTER_DECL(socket_create_mbuf); static void -mac_test_socket_create_mbuf(struct socket *so, struct label *socketlabel, +test_socket_create_mbuf(struct socket *so, struct label *socketlabel, struct mbuf *m, struct label *mbuflabel) { @@ -747,7 +747,7 @@ mac_test_socket_create_mbuf(struct socket *so, struct label *socketlabel, COUNTER_DECL(socket_create); static void -mac_test_socket_create(struct ucred *cred, struct socket *socket, +test_socket_create(struct ucred *cred, struct socket *socket, struct label *socketlabel) { @@ -758,7 +758,7 @@ mac_test_socket_create(struct ucred *cred, struct socket *socket, COUNTER_DECL(pipe_create); static void -mac_test_pipe_create(struct ucred *cred, struct pipepair *pp, +test_pipe_create(struct ucred *cred, struct pipepair *pp, struct label *pipelabel) { @@ -769,7 +769,7 @@ mac_test_pipe_create(struct ucred *cred, struct pipepair *pp, COUNTER_DECL(posixsem_create); static void -mac_test_posixsem_create(struct ucred *cred, struct ksem *ks, +test_posixsem_create(struct ucred *cred, struct ksem *ks, struct label *kslabel) { @@ -780,7 +780,7 @@ mac_test_posixsem_create(struct ucred *cred, struct ksem *ks, COUNTER_DECL(socket_newconn); static void -mac_test_socket_newconn(struct socket *oldsocket, +test_socket_newconn(struct socket *oldsocket, struct label *oldsocketlabel, struct socket *newsocket, struct label *newsocketlabel) { @@ -792,7 +792,7 @@ mac_test_socket_newconn(struct socket *oldsocket, COUNTER_DECL(socket_relabel); static void -mac_test_socket_relabel(struct ucred *cred, struct socket *socket, +test_socket_relabel(struct ucred *cred, struct socket *socket, struct label *socketlabel, struct label *newlabel) { @@ -803,7 +803,7 @@ mac_test_socket_relabel(struct ucred *cred, struct socket *socket, COUNTER_DECL(pipe_relabel); static void -mac_test_pipe_relabel(struct ucred *cred, struct pipepair *pp, +test_pipe_relabel(struct ucred *cred, struct pipepair *pp, struct label *pipelabel, struct label *newlabel) { @@ -815,7 +815,7 @@ mac_test_pipe_relabel(struct ucred *cred, struct pipepair *pp, COUNTER_DECL(socketpeer_set_from_mbuf); static void -mac_test_socketpeer_set_from_mbuf(struct mbuf *mbuf, struct label *mbuflabel, +test_socketpeer_set_from_mbuf(struct mbuf *mbuf, struct label *mbuflabel, struct socket *socket, struct label *socketpeerlabel) { @@ -829,7 +829,7 @@ mac_test_socketpeer_set_from_mbuf(struct mbuf *mbuf, struct label *mbuflabel, */ COUNTER_DECL(socketpeer_set_from_socket); static void -mac_test_socketpeer_set_from_socket(struct socket *oldsocket, +test_socketpeer_set_from_socket(struct socket *oldsocket, struct label *oldsocketlabel, struct socket *newsocket, struct label *newsocketpeerlabel) { @@ -841,7 +841,7 @@ mac_test_socketpeer_set_from_socket(struct socket *oldsocket, COUNTER_DECL(bpfdesc_create); static void -mac_test_bpfdesc_create(struct ucred *cred, struct bpf_d *bpf_d, +test_bpfdesc_create(struct ucred *cred, struct bpf_d *bpf_d, struct label *bpflabel) { @@ -852,7 +852,7 @@ mac_test_bpfdesc_create(struct ucred *cred, struct bpf_d *bpf_d, COUNTER_DECL(ipq_reassemble); static void -mac_test_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, +test_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, struct mbuf *datagram, struct label *datagramlabel) { @@ -863,7 +863,7 @@ mac_test_ipq_reassemble(struct ipq *ipq, struct label *ipqlabel, COUNTER_DECL(netinet_fragment); static void -mac_test_netinet_fragment(struct mbuf *datagram, struct label *datagramlabel, +test_netinet_fragment(struct mbuf *datagram, struct label *datagramlabel, struct mbuf *fragment, struct label *fragmentlabel) { @@ -874,7 +874,7 @@ mac_test_netinet_fragment(struct mbuf *datagram, struct label *datagramlabel, COUNTER_DECL(ifnet_create); static void -mac_test_ifnet_create(struct ifnet *ifp, struct label *ifplabel) +test_ifnet_create(struct ifnet *ifp, struct label *ifplabel) { LABEL_CHECK(ifplabel, MAGIC_IFNET); @@ -883,7 +883,7 @@ mac_test_ifnet_create(struct ifnet *ifp, struct label *ifplabel) COUNTER_DECL(inpcb_create); static void -mac_test_inpcb_create(struct socket *so, struct label *solabel, +test_inpcb_create(struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel) { @@ -894,7 +894,7 @@ mac_test_inpcb_create(struct socket *so, struct label *solabel, COUNTER_DECL(sysvmsg_create); static void -mac_test_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, +test_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqlabel, struct msg *msgptr, struct label *msglabel) { @@ -905,7 +905,7 @@ mac_test_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, COUNTER_DECL(sysvmsq_create); static void -mac_test_sysvmsq_create(struct ucred *cred, +test_sysvmsq_create(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqlabel) { @@ -915,7 +915,7 @@ mac_test_sysvmsq_create(struct ucred *cred, COUNTER_DECL(sysvsem_create); static void -mac_test_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, +test_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, struct label *semalabel) { @@ -925,7 +925,7 @@ mac_test_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, COUNTER_DECL(sysvshm_create); static void -mac_test_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, +test_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, struct label *shmlabel) { @@ -935,7 +935,7 @@ mac_test_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, COUNTER_DECL(ipq_create); static void -mac_test_ipq_create(struct mbuf *fragment, struct label *fragmentlabel, +test_ipq_create(struct mbuf *fragment, struct label *fragmentlabel, struct ipq *ipq, struct label *ipqlabel) { @@ -946,7 +946,7 @@ mac_test_ipq_create(struct mbuf *fragment, struct label *fragmentlabel, COUNTER_DECL(inpcb_create_mbuf); static void -mac_test_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, +test_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { @@ -957,7 +957,7 @@ mac_test_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, COUNTER_DECL(create_mbuf_linklayer); static void -mac_test_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, +test_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, struct mbuf *mbuf, struct label *mbuflabel) { @@ -968,7 +968,7 @@ mac_test_create_mbuf_linklayer(struct ifnet *ifp, struct label *ifplabel, COUNTER_DECL(bpfdesc_create_mbuf); static void -mac_test_bpfdesc_create_mbuf(struct bpf_d *bpf_d, struct label *bpflabel, +test_bpfdesc_create_mbuf(struct bpf_d *bpf_d, struct label *bpflabel, struct mbuf *mbuf, struct label *mbuflabel) { @@ -979,7 +979,7 @@ mac_test_bpfdesc_create_mbuf(struct bpf_d *bpf_d, struct label *bpflabel, COUNTER_DECL(ifnet_create_mbuf); static void -mac_test_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, +test_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mbuflabel) { @@ -990,7 +990,7 @@ mac_test_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, COUNTER_DECL(mbuf_create_multicast_encap); static void -mac_test_mbuf_create_multicast_encap(struct mbuf *oldmbuf, +test_mbuf_create_multicast_encap(struct mbuf *oldmbuf, struct label *oldmbuflabel, struct ifnet *ifp, struct label *ifplabel, struct mbuf *newmbuf, struct label *newmbuflabel) { @@ -1003,7 +1003,7 @@ mac_test_mbuf_create_multicast_encap(struct mbuf *oldmbuf, COUNTER_DECL(mbuf_create_netlayer); static void -mac_test_mbuf_create_netlayer(struct mbuf *oldmbuf, +test_mbuf_create_netlayer(struct mbuf *oldmbuf, struct label *oldmbuflabel, struct mbuf *newmbuf, struct label *newmbuflabel) { @@ -1015,7 +1015,7 @@ mac_test_mbuf_create_netlayer(struct mbuf *oldmbuf, COUNTER_DECL(ipq_match); static int -mac_test_ipq_match(struct mbuf *fragment, struct label *fragmentlabel, +test_ipq_match(struct mbuf *fragment, struct label *fragmentlabel, struct ipq *ipq, struct label *ipqlabel) { @@ -1028,7 +1028,7 @@ mac_test_ipq_match(struct mbuf *fragment, struct label *fragmentlabel, COUNTER_DECL(netinet_icmp_reply); static void -mac_test_netinet_icmp_reply(struct mbuf *m, struct label *mlabel) +test_netinet_icmp_reply(struct mbuf *m, struct label *mlabel) { LABEL_CHECK(mlabel, MAGIC_MBUF); @@ -1037,7 +1037,7 @@ mac_test_netinet_icmp_reply(struct mbuf *m, struct label *mlabel) COUNTER_DECL(netinet_tcp_reply); static void -mac_test_netinet_tcp_reply(struct mbuf *m, struct label *mlabel) +test_netinet_tcp_reply(struct mbuf *m, struct label *mlabel) { LABEL_CHECK(mlabel, MAGIC_MBUF); @@ -1046,7 +1046,7 @@ mac_test_netinet_tcp_reply(struct mbuf *m, struct label *mlabel) COUNTER_DECL(ifnet_relabel); static void -mac_test_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, +test_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, struct label *ifplabel, struct label *newlabel) { @@ -1058,7 +1058,7 @@ mac_test_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, COUNTER_DECL(ipq_update); static void -mac_test_ipq_update(struct mbuf *fragment, struct label *fragmentlabel, +test_ipq_update(struct mbuf *fragment, struct label *fragmentlabel, struct ipq *ipq, struct label *ipqlabel) { @@ -1069,7 +1069,7 @@ mac_test_ipq_update(struct mbuf *fragment, struct label *fragmentlabel, COUNTER_DECL(inpcb_sosetlabel); static void -mac_test_inpcb_sosetlabel(struct socket *so, struct label *solabel, +test_inpcb_sosetlabel(struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel) { @@ -1083,7 +1083,7 @@ mac_test_inpcb_sosetlabel(struct socket *so, struct label *solabel, */ COUNTER_DECL(vnode_execve_transition); static void -mac_test_vnode_execve_transition(struct ucred *old, struct ucred *new, +test_vnode_execve_transition(struct ucred *old, struct ucred *new, struct vnode *vp, struct label *filelabel, struct label *interpvplabel, struct image_params *imgp, struct label *execlabel) @@ -1099,7 +1099,7 @@ mac_test_vnode_execve_transition(struct ucred *old, struct ucred *new, COUNTER_DECL(vnode_execve_will_transition); static int -mac_test_vnode_execve_will_transition(struct ucred *old, struct vnode *vp, +test_vnode_execve_will_transition(struct ucred *old, struct vnode *vp, struct label *filelabel, struct label *interpvplabel, struct image_params *imgp, struct label *execlabel) { @@ -1115,7 +1115,7 @@ mac_test_vnode_execve_will_transition(struct ucred *old, struct vnode *vp, COUNTER_DECL(proc_create_swapper); static void -mac_test_proc_create_swapper(struct ucred *cred) +test_proc_create_swapper(struct ucred *cred) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1124,7 +1124,7 @@ mac_test_proc_create_swapper(struct ucred *cred) COUNTER_DECL(proc_create_init); static void -mac_test_proc_create_init(struct ucred *cred) +test_proc_create_init(struct ucred *cred) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1133,7 +1133,7 @@ mac_test_proc_create_init(struct ucred *cred) COUNTER_DECL(cred_relabel); static void -mac_test_cred_relabel(struct ucred *cred, struct label *newlabel) +test_cred_relabel(struct ucred *cred, struct label *newlabel) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1143,7 +1143,7 @@ mac_test_cred_relabel(struct ucred *cred, struct label *newlabel) COUNTER_DECL(thread_userret); static void -mac_test_thread_userret(struct thread *td) +test_thread_userret(struct thread *td) { COUNTER_INC(thread_userret); @@ -1154,7 +1154,7 @@ mac_test_thread_userret(struct thread *td) */ COUNTER_DECL(sysvmsg_cleanup); static void -mac_test_sysvmsg_cleanup(struct label *msglabel) +test_sysvmsg_cleanup(struct label *msglabel) { LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); @@ -1163,7 +1163,7 @@ mac_test_sysvmsg_cleanup(struct label *msglabel) COUNTER_DECL(sysvmsq_cleanup); static void -mac_test_sysvmsq_cleanup(struct label *msqlabel) +test_sysvmsq_cleanup(struct label *msqlabel) { LABEL_CHECK(msqlabel, MAGIC_SYSV_MSQ); @@ -1172,7 +1172,7 @@ mac_test_sysvmsq_cleanup(struct label *msqlabel) COUNTER_DECL(sysvsem_cleanup); static void -mac_test_sysvsem_cleanup(struct label *semalabel) +test_sysvsem_cleanup(struct label *semalabel) { LABEL_CHECK(semalabel, MAGIC_SYSV_SEM); @@ -1181,7 +1181,7 @@ mac_test_sysvsem_cleanup(struct label *semalabel) COUNTER_DECL(sysvshm_cleanup); static void -mac_test_sysvshm_cleanup(struct label *shmlabel) +test_sysvshm_cleanup(struct label *shmlabel) { LABEL_CHECK(shmlabel, MAGIC_SYSV_SHM); @@ -1193,7 +1193,7 @@ mac_test_sysvshm_cleanup(struct label *shmlabel) */ COUNTER_DECL(bpfdesc_check_receive); static int -mac_test_bpfdesc_check_receive(struct bpf_d *bpf_d, struct label *bpflabel, +test_bpfdesc_check_receive(struct bpf_d *bpf_d, struct label *bpflabel, struct ifnet *ifp, struct label *ifplabel) { @@ -1206,7 +1206,7 @@ mac_test_bpfdesc_check_receive(struct bpf_d *bpf_d, struct label *bpflabel, COUNTER_DECL(cred_check_relabel); static int -mac_test_cred_check_relabel(struct ucred *cred, struct label *newlabel) +test_cred_check_relabel(struct ucred *cred, struct label *newlabel) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1218,7 +1218,7 @@ mac_test_cred_check_relabel(struct ucred *cred, struct label *newlabel) COUNTER_DECL(cred_check_visible); static int -mac_test_cred_check_visible(struct ucred *u1, struct ucred *u2) +test_cred_check_visible(struct ucred *u1, struct ucred *u2) { LABEL_CHECK(u1->cr_label, MAGIC_CRED); @@ -1230,7 +1230,7 @@ mac_test_cred_check_visible(struct ucred *u1, struct ucred *u2) COUNTER_DECL(ifnet_check_relabel); static int -mac_test_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, +test_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, struct label *ifplabel, struct label *newlabel) { @@ -1244,7 +1244,7 @@ mac_test_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, COUNTER_DECL(ifnet_check_transmit); static int -mac_test_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, +test_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, struct mbuf *m, struct label *mbuflabel) { @@ -1257,7 +1257,7 @@ mac_test_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, COUNTER_DECL(inpcb_check_deliver); static int -mac_test_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, +test_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mlabel) { @@ -1270,7 +1270,7 @@ mac_test_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, COUNTER_DECL(sysvmsq_check_msgmsq); static int -mac_test_sysvmsq_check_msgmsq(struct ucred *cred, struct msg *msgptr, +test_sysvmsq_check_msgmsq(struct ucred *cred, struct msg *msgptr, struct label *msglabel, struct msqid_kernel *msqkptr, struct label *msqklabel) { @@ -1285,7 +1285,7 @@ mac_test_sysvmsq_check_msgmsq(struct ucred *cred, struct msg *msgptr, COUNTER_DECL(sysvmsq_check_msgrcv); static int -mac_test_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, +test_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, struct label *msglabel) { @@ -1298,7 +1298,7 @@ mac_test_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, COUNTER_DECL(sysvmsq_check_msgrmid); static int -mac_test_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, +test_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, struct label *msglabel) { @@ -1311,7 +1311,7 @@ mac_test_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, COUNTER_DECL(sysvmsq_check_msqget); static int -mac_test_sysvmsq_check_msqget(struct ucred *cred, +test_sysvmsq_check_msqget(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqklabel) { @@ -1324,7 +1324,7 @@ mac_test_sysvmsq_check_msqget(struct ucred *cred, COUNTER_DECL(sysvmsq_check_msqsnd); static int -mac_test_sysvmsq_check_msqsnd(struct ucred *cred, +test_sysvmsq_check_msqsnd(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqklabel) { @@ -1337,7 +1337,7 @@ mac_test_sysvmsq_check_msqsnd(struct ucred *cred, COUNTER_DECL(sysvmsq_check_msqrcv); static int -mac_test_sysvmsq_check_msqrcv(struct ucred *cred, +test_sysvmsq_check_msqrcv(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqklabel) { @@ -1350,7 +1350,7 @@ mac_test_sysvmsq_check_msqrcv(struct ucred *cred, COUNTER_DECL(sysvmsq_check_msqctl); static int -mac_test_sysvmsq_check_msqctl(struct ucred *cred, +test_sysvmsq_check_msqctl(struct ucred *cred, struct msqid_kernel *msqkptr, struct label *msqklabel, int cmd) { @@ -1363,7 +1363,7 @@ mac_test_sysvmsq_check_msqctl(struct ucred *cred, COUNTER_DECL(sysvsem_check_semctl); static int -mac_test_sysvsem_check_semctl(struct ucred *cred, +test_sysvsem_check_semctl(struct ucred *cred, struct semid_kernel *semakptr, struct label *semaklabel, int cmd) { @@ -1376,7 +1376,7 @@ mac_test_sysvsem_check_semctl(struct ucred *cred, COUNTER_DECL(sysvsem_check_semget); static int -mac_test_sysvsem_check_semget(struct ucred *cred, +test_sysvsem_check_semget(struct ucred *cred, struct semid_kernel *semakptr, struct label *semaklabel) { @@ -1389,7 +1389,7 @@ mac_test_sysvsem_check_semget(struct ucred *cred, COUNTER_DECL(sysvsem_check_semop); static int -mac_test_sysvsem_check_semop(struct ucred *cred, +test_sysvsem_check_semop(struct ucred *cred, struct semid_kernel *semakptr, struct label *semaklabel, size_t accesstype) { @@ -1402,7 +1402,7 @@ mac_test_sysvsem_check_semop(struct ucred *cred, COUNTER_DECL(sysvshm_check_shmat); static int -mac_test_sysvshm_check_shmat(struct ucred *cred, +test_sysvshm_check_shmat(struct ucred *cred, struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) { @@ -1415,7 +1415,7 @@ mac_test_sysvshm_check_shmat(struct ucred *cred, COUNTER_DECL(sysvshm_check_shmctl); static int -mac_test_sysvshm_check_shmctl(struct ucred *cred, +test_sysvshm_check_shmctl(struct ucred *cred, struct shmid_kernel *shmsegptr, struct label *shmseglabel, int cmd) { @@ -1428,7 +1428,7 @@ mac_test_sysvshm_check_shmctl(struct ucred *cred, COUNTER_DECL(sysvshm_check_shmdt); static int -mac_test_sysvshm_check_shmdt(struct ucred *cred, +test_sysvshm_check_shmdt(struct ucred *cred, struct shmid_kernel *shmsegptr, struct label *shmseglabel) { @@ -1441,7 +1441,7 @@ mac_test_sysvshm_check_shmdt(struct ucred *cred, COUNTER_DECL(sysvshm_check_shmget); static int -mac_test_sysvshm_check_shmget(struct ucred *cred, +test_sysvshm_check_shmget(struct ucred *cred, struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) { @@ -1454,7 +1454,7 @@ mac_test_sysvshm_check_shmget(struct ucred *cred, COUNTER_DECL(kenv_check_dump); static int -mac_test_kenv_check_dump(struct ucred *cred) +test_kenv_check_dump(struct ucred *cred) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1465,7 +1465,7 @@ mac_test_kenv_check_dump(struct ucred *cred) COUNTER_DECL(kenv_check_get); static int -mac_test_kenv_check_get(struct ucred *cred, char *name) +test_kenv_check_get(struct ucred *cred, char *name) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1476,7 +1476,7 @@ mac_test_kenv_check_get(struct ucred *cred, char *name) COUNTER_DECL(kenv_check_set); static int -mac_test_kenv_check_set(struct ucred *cred, char *name, char *value) +test_kenv_check_set(struct ucred *cred, char *name, char *value) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1487,7 +1487,7 @@ mac_test_kenv_check_set(struct ucred *cred, char *name, char *value) COUNTER_DECL(kenv_check_unset); static int -mac_test_kenv_check_unset(struct ucred *cred, char *name) +test_kenv_check_unset(struct ucred *cred, char *name) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1498,7 +1498,7 @@ mac_test_kenv_check_unset(struct ucred *cred, char *name) COUNTER_DECL(kld_check_load); static int -mac_test_kld_check_load(struct ucred *cred, struct vnode *vp, +test_kld_check_load(struct ucred *cred, struct vnode *vp, struct label *label) { @@ -1511,7 +1511,7 @@ mac_test_kld_check_load(struct ucred *cred, struct vnode *vp, COUNTER_DECL(kld_check_stat); static int -mac_test_kld_check_stat(struct ucred *cred) +test_kld_check_stat(struct ucred *cred) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1522,7 +1522,7 @@ mac_test_kld_check_stat(struct ucred *cred) COUNTER_DECL(mount_check_stat); static int -mac_test_mount_check_stat(struct ucred *cred, struct mount *mp, +test_mount_check_stat(struct ucred *cred, struct mount *mp, struct label *mplabel) { @@ -1535,7 +1535,7 @@ mac_test_mount_check_stat(struct ucred *cred, struct mount *mp, COUNTER_DECL(pipe_check_ioctl); static int -mac_test_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, +test_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, struct label *pipelabel, unsigned long cmd, void /* caddr_t */ *data) { @@ -1548,7 +1548,7 @@ mac_test_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, COUNTER_DECL(pipe_check_poll); static int -mac_test_pipe_check_poll(struct ucred *cred, struct pipepair *pp, +test_pipe_check_poll(struct ucred *cred, struct pipepair *pp, struct label *pipelabel) { @@ -1561,7 +1561,7 @@ mac_test_pipe_check_poll(struct ucred *cred, struct pipepair *pp, COUNTER_DECL(pipe_check_read); static int -mac_test_pipe_check_read(struct ucred *cred, struct pipepair *pp, +test_pipe_check_read(struct ucred *cred, struct pipepair *pp, struct label *pipelabel) { @@ -1574,7 +1574,7 @@ mac_test_pipe_check_read(struct ucred *cred, struct pipepair *pp, COUNTER_DECL(pipe_check_relabel); static int -mac_test_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, +test_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, struct label *pipelabel, struct label *newlabel) { @@ -1588,7 +1588,7 @@ mac_test_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, COUNTER_DECL(pipe_check_stat); static int -mac_test_pipe_check_stat(struct ucred *cred, struct pipepair *pp, +test_pipe_check_stat(struct ucred *cred, struct pipepair *pp, struct label *pipelabel) { @@ -1601,7 +1601,7 @@ mac_test_pipe_check_stat(struct ucred *cred, struct pipepair *pp, COUNTER_DECL(pipe_check_write); static int -mac_test_pipe_check_write(struct ucred *cred, struct pipepair *pp, +test_pipe_check_write(struct ucred *cred, struct pipepair *pp, struct label *pipelabel) { @@ -1614,7 +1614,7 @@ mac_test_pipe_check_write(struct ucred *cred, struct pipepair *pp, COUNTER_DECL(posixsem_check); static int -mac_test_posixsem_check(struct ucred *cred, struct ksem *ks, +test_posixsem_check(struct ucred *cred, struct ksem *ks, struct label *kslabel) { @@ -1627,7 +1627,7 @@ mac_test_posixsem_check(struct ucred *cred, struct ksem *ks, COUNTER_DECL(proc_check_debug); static int -mac_test_proc_check_debug(struct ucred *cred, struct proc *p) +test_proc_check_debug(struct ucred *cred, struct proc *p) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1639,7 +1639,7 @@ mac_test_proc_check_debug(struct ucred *cred, struct proc *p) COUNTER_DECL(proc_check_sched); static int -mac_test_proc_check_sched(struct ucred *cred, struct proc *p) +test_proc_check_sched(struct ucred *cred, struct proc *p) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1651,7 +1651,7 @@ mac_test_proc_check_sched(struct ucred *cred, struct proc *p) COUNTER_DECL(proc_check_signal); static int -mac_test_proc_check_signal(struct ucred *cred, struct proc *p, int signum) +test_proc_check_signal(struct ucred *cred, struct proc *p, int signum) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1663,7 +1663,7 @@ mac_test_proc_check_signal(struct ucred *cred, struct proc *p, int signum) COUNTER_DECL(proc_check_setaudit); static int -mac_test_proc_check_setaudit(struct ucred *cred, struct auditinfo *ai) +test_proc_check_setaudit(struct ucred *cred, struct auditinfo *ai) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1674,7 +1674,7 @@ mac_test_proc_check_setaudit(struct ucred *cred, struct auditinfo *ai) COUNTER_DECL(proc_check_setaudit_addr); static int -mac_test_proc_check_setaudit_addr(struct ucred *cred, +test_proc_check_setaudit_addr(struct ucred *cred, struct auditinfo_addr *aia) { @@ -1686,7 +1686,7 @@ mac_test_proc_check_setaudit_addr(struct ucred *cred, COUNTER_DECL(proc_check_setauid); static int -mac_test_proc_check_setauid(struct ucred *cred, uid_t auid) +test_proc_check_setauid(struct ucred *cred, uid_t auid) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1697,7 +1697,7 @@ mac_test_proc_check_setauid(struct ucred *cred, uid_t auid) COUNTER_DECL(proc_check_setuid); static int -mac_test_proc_check_setuid(struct ucred *cred, uid_t uid) +test_proc_check_setuid(struct ucred *cred, uid_t uid) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1708,7 +1708,7 @@ mac_test_proc_check_setuid(struct ucred *cred, uid_t uid) COUNTER_DECL(proc_check_euid); static int -mac_test_proc_check_seteuid(struct ucred *cred, uid_t euid) +test_proc_check_seteuid(struct ucred *cred, uid_t euid) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1719,7 +1719,7 @@ mac_test_proc_check_seteuid(struct ucred *cred, uid_t euid) COUNTER_DECL(proc_check_setgid); static int -mac_test_proc_check_setgid(struct ucred *cred, gid_t gid) +test_proc_check_setgid(struct ucred *cred, gid_t gid) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1730,7 +1730,7 @@ mac_test_proc_check_setgid(struct ucred *cred, gid_t gid) COUNTER_DECL(proc_check_setegid); static int -mac_test_proc_check_setegid(struct ucred *cred, gid_t egid) +test_proc_check_setegid(struct ucred *cred, gid_t egid) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1741,7 +1741,7 @@ mac_test_proc_check_setegid(struct ucred *cred, gid_t egid) COUNTER_DECL(proc_check_setgroups); static int -mac_test_proc_check_setgroups(struct ucred *cred, int ngroups, +test_proc_check_setgroups(struct ucred *cred, int ngroups, gid_t *gidset) { @@ -1753,7 +1753,7 @@ mac_test_proc_check_setgroups(struct ucred *cred, int ngroups, COUNTER_DECL(proc_check_setreuid); static int -mac_test_proc_check_setreuid(struct ucred *cred, uid_t ruid, uid_t euid) +test_proc_check_setreuid(struct ucred *cred, uid_t ruid, uid_t euid) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1764,7 +1764,7 @@ mac_test_proc_check_setreuid(struct ucred *cred, uid_t ruid, uid_t euid) COUNTER_DECL(proc_check_setregid); static int -mac_test_proc_check_setregid(struct ucred *cred, gid_t rgid, gid_t egid) +test_proc_check_setregid(struct ucred *cred, gid_t rgid, gid_t egid) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1775,7 +1775,7 @@ mac_test_proc_check_setregid(struct ucred *cred, gid_t rgid, gid_t egid) COUNTER_DECL(proc_check_setresuid); static int -mac_test_proc_check_setresuid(struct ucred *cred, uid_t ruid, uid_t euid, +test_proc_check_setresuid(struct ucred *cred, uid_t ruid, uid_t euid, uid_t suid) { @@ -1787,7 +1787,7 @@ mac_test_proc_check_setresuid(struct ucred *cred, uid_t ruid, uid_t euid, COUNTER_DECL(proc_check_setresgid); static int -mac_test_proc_check_setresgid(struct ucred *cred, gid_t rgid, gid_t egid, +test_proc_check_setresgid(struct ucred *cred, gid_t rgid, gid_t egid, gid_t sgid) { @@ -1799,7 +1799,7 @@ mac_test_proc_check_setresgid(struct ucred *cred, gid_t rgid, gid_t egid, COUNTER_DECL(proc_check_wait); static int -mac_test_proc_check_wait(struct ucred *cred, struct proc *p) +test_proc_check_wait(struct ucred *cred, struct proc *p) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1811,7 +1811,7 @@ mac_test_proc_check_wait(struct ucred *cred, struct proc *p) COUNTER_DECL(socket_check_accept); static int -mac_test_socket_check_accept(struct ucred *cred, struct socket *so, +test_socket_check_accept(struct ucred *cred, struct socket *so, struct label *solabel) { @@ -1824,7 +1824,7 @@ mac_test_socket_check_accept(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_bind); static int -mac_test_socket_check_bind(struct ucred *cred, struct socket *so, +test_socket_check_bind(struct ucred *cred, struct socket *so, struct label *solabel, struct sockaddr *sa) { @@ -1837,7 +1837,7 @@ mac_test_socket_check_bind(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_connect); static int -mac_test_socket_check_connect(struct ucred *cred, struct socket *so, +test_socket_check_connect(struct ucred *cred, struct socket *so, struct label *solabel, struct sockaddr *sa) { @@ -1850,7 +1850,7 @@ mac_test_socket_check_connect(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_deliver); static int -mac_test_socket_check_deliver(struct socket *so, struct label *solabel, +test_socket_check_deliver(struct socket *so, struct label *solabel, struct mbuf *m, struct label *mlabel) { @@ -1863,7 +1863,7 @@ mac_test_socket_check_deliver(struct socket *so, struct label *solabel, COUNTER_DECL(socket_check_listen); static int -mac_test_socket_check_listen(struct ucred *cred, struct socket *so, +test_socket_check_listen(struct ucred *cred, struct socket *so, struct label *solabel) { @@ -1876,7 +1876,7 @@ mac_test_socket_check_listen(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_poll); static int -mac_test_socket_check_poll(struct ucred *cred, struct socket *so, +test_socket_check_poll(struct ucred *cred, struct socket *so, struct label *solabel) { @@ -1889,7 +1889,7 @@ mac_test_socket_check_poll(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_receive); static int -mac_test_socket_check_receive(struct ucred *cred, struct socket *so, +test_socket_check_receive(struct ucred *cred, struct socket *so, struct label *solabel) { @@ -1902,7 +1902,7 @@ mac_test_socket_check_receive(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_relabel); static int -mac_test_socket_check_relabel(struct ucred *cred, struct socket *so, +test_socket_check_relabel(struct ucred *cred, struct socket *so, struct label *solabel, struct label *newlabel) { @@ -1916,7 +1916,7 @@ mac_test_socket_check_relabel(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_send); static int -mac_test_socket_check_send(struct ucred *cred, struct socket *so, +test_socket_check_send(struct ucred *cred, struct socket *so, struct label *solabel) { @@ -1929,7 +1929,7 @@ mac_test_socket_check_send(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_stat); static int -mac_test_socket_check_stat(struct ucred *cred, struct socket *so, +test_socket_check_stat(struct ucred *cred, struct socket *so, struct label *solabel) { @@ -1942,7 +1942,7 @@ mac_test_socket_check_stat(struct ucred *cred, struct socket *so, COUNTER_DECL(socket_check_visible); static int -mac_test_socket_check_visible(struct ucred *cred, struct socket *so, +test_socket_check_visible(struct ucred *cred, struct socket *so, struct label *solabel) { @@ -1955,7 +1955,7 @@ mac_test_socket_check_visible(struct ucred *cred, struct socket *so, COUNTER_DECL(system_check_acct); static int -mac_test_system_check_acct(struct ucred *cred, struct vnode *vp, +test_system_check_acct(struct ucred *cred, struct vnode *vp, struct label *vplabel) { @@ -1968,7 +1968,7 @@ mac_test_system_check_acct(struct ucred *cred, struct vnode *vp, COUNTER_DECL(system_check_audit); static int -mac_test_system_check_audit(struct ucred *cred, void *record, int length) +test_system_check_audit(struct ucred *cred, void *record, int length) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -1979,7 +1979,7 @@ mac_test_system_check_audit(struct ucred *cred, void *record, int length) COUNTER_DECL(system_check_auditctl); static int -mac_test_system_check_auditctl(struct ucred *cred, struct vnode *vp, +test_system_check_auditctl(struct ucred *cred, struct vnode *vp, struct label *vplabel) { @@ -1992,7 +1992,7 @@ mac_test_system_check_auditctl(struct ucred *cred, struct vnode *vp, COUNTER_DECL(system_check_auditon); static int -mac_test_system_check_auditon(struct ucred *cred, int cmd) +test_system_check_auditon(struct ucred *cred, int cmd) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -2003,7 +2003,7 @@ mac_test_system_check_auditon(struct ucred *cred, int cmd) COUNTER_DECL(system_check_reboot); static int -mac_test_system_check_reboot(struct ucred *cred, int how) +test_system_check_reboot(struct ucred *cred, int how) { LABEL_CHECK(cred->cr_label, MAGIC_CRED); @@ -2014,7 +2014,7 @@ mac_test_system_check_reboot(struct ucred *cred, int how) COUNTER_DECL(system_check_swapoff); static int -mac_test_system_check_swapoff(struct ucred *cred, struct vnode *vp, +test_system_check_swapoff(struct ucred *cred, struct vnode *vp, struct label *vplabel) { @@ -2027,7 +2027,7 @@ mac_test_system_check_swapoff(struct ucred *cred, struct vnode *vp, COUNTER_DECL(system_check_swapon); static int -mac_test_system_check_swapon(struct ucred *cred, struct vnode *vp, +test_system_check_swapon(struct ucred *cred, struct vnode *vp, struct label *vplabel) { @@ -2040,7 +2040,7 @@ mac_test_system_check_swapon(struct ucred *cred, struct vnode *vp, COUNTER_DECL(system_check_sysctl); static int -mac_test_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, +test_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req) { @@ -2052,7 +2052,7 @@ mac_test_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, COUNTER_DECL(vnode_check_access); static int -mac_test_vnode_check_access(struct ucred *cred, struct vnode *vp, +test_vnode_check_access(struct ucred *cred, struct vnode *vp, struct label *vplabel, int acc_mode) { @@ -2065,7 +2065,7 @@ mac_test_vnode_check_access(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_chdir); static int -mac_test_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, +test_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { @@ -2078,7 +2078,7 @@ mac_test_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_chroot); static int -mac_test_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, +test_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { @@ -2091,7 +2091,7 @@ mac_test_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_create); static int -mac_test_vnode_check_create(struct ucred *cred, struct vnode *dvp, +test_vnode_check_create(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp, struct vattr *vap) { @@ -2104,7 +2104,7 @@ mac_test_vnode_check_create(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_deleteacl); static int -mac_test_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, +test_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { @@ -2117,7 +2117,7 @@ mac_test_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_deleteextattr); static int -mac_test_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, +test_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name) { @@ -2130,7 +2130,7 @@ mac_test_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_exec); static int -mac_test_vnode_check_exec(struct ucred *cred, struct vnode *vp, +test_vnode_check_exec(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct image_params *imgp, struct label *execlabel) { @@ -2145,7 +2145,7 @@ mac_test_vnode_check_exec(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_getacl); static int -mac_test_vnode_check_getacl(struct ucred *cred, struct vnode *vp, +test_vnode_check_getacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type) { @@ -2158,7 +2158,7 @@ mac_test_vnode_check_getacl(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_getextattr); static int -mac_test_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, +test_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { @@ -2172,7 +2172,7 @@ mac_test_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_link); static int -mac_test_vnode_check_link(struct ucred *cred, struct vnode *dvp, +test_vnode_check_link(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { @@ -2187,7 +2187,7 @@ mac_test_vnode_check_link(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_listextattr); static int -mac_test_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, +test_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace) { @@ -2200,7 +2200,7 @@ mac_test_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_lookup); static int -mac_test_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, +test_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct componentname *cnp) { @@ -2213,7 +2213,7 @@ mac_test_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_mmap); static int -mac_test_vnode_check_mmap(struct ucred *cred, struct vnode *vp, +test_vnode_check_mmap(struct ucred *cred, struct vnode *vp, struct label *vplabel, int prot, int flags) { @@ -2226,7 +2226,7 @@ mac_test_vnode_check_mmap(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_open); static int -mac_test_vnode_check_open(struct ucred *cred, struct vnode *vp, +test_vnode_check_open(struct ucred *cred, struct vnode *vp, struct label *vplabel, int acc_mode) { @@ -2239,7 +2239,7 @@ mac_test_vnode_check_open(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_poll); static int -mac_test_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, +test_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { @@ -2254,7 +2254,7 @@ mac_test_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, COUNTER_DECL(vnode_check_read); static int -mac_test_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, +test_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { @@ -2269,7 +2269,7 @@ mac_test_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, COUNTER_DECL(vnode_check_readdir); static int -mac_test_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, +test_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, struct label *dvplabel) { @@ -2282,7 +2282,7 @@ mac_test_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_readlink); static int -mac_test_vnode_check_readlink(struct ucred *cred, struct vnode *vp, +test_vnode_check_readlink(struct ucred *cred, struct vnode *vp, struct label *vplabel) { @@ -2295,7 +2295,7 @@ mac_test_vnode_check_readlink(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_relabel); static int -mac_test_vnode_check_relabel(struct ucred *cred, struct vnode *vp, +test_vnode_check_relabel(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct label *newlabel) { @@ -2309,7 +2309,7 @@ mac_test_vnode_check_relabel(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_rename_from); static int -mac_test_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, +test_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { @@ -2324,7 +2324,7 @@ mac_test_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_rename_to); static int -mac_test_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, +test_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, int samedir, struct componentname *cnp) { @@ -2339,7 +2339,7 @@ mac_test_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_revoke); static int -mac_test_vnode_check_revoke(struct ucred *cred, struct vnode *vp, +test_vnode_check_revoke(struct ucred *cred, struct vnode *vp, struct label *vplabel) { @@ -2352,7 +2352,7 @@ mac_test_vnode_check_revoke(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_setacl); static int -mac_test_vnode_check_setacl(struct ucred *cred, struct vnode *vp, +test_vnode_check_setacl(struct ucred *cred, struct vnode *vp, struct label *vplabel, acl_type_t type, struct acl *acl) { @@ -2365,7 +2365,7 @@ mac_test_vnode_check_setacl(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_setextattr); static int -mac_test_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, +test_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, struct label *vplabel, int attrnamespace, const char *name, struct uio *uio) { @@ -2379,7 +2379,7 @@ mac_test_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_setflags); static int -mac_test_vnode_check_setflags(struct ucred *cred, struct vnode *vp, +test_vnode_check_setflags(struct ucred *cred, struct vnode *vp, struct label *vplabel, u_long flags) { @@ -2392,7 +2392,7 @@ mac_test_vnode_check_setflags(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_setmode); static int -mac_test_vnode_check_setmode(struct ucred *cred, struct vnode *vp, +test_vnode_check_setmode(struct ucred *cred, struct vnode *vp, struct label *vplabel, mode_t mode) { @@ -2405,7 +2405,7 @@ mac_test_vnode_check_setmode(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_setowner); static int -mac_test_vnode_check_setowner(struct ucred *cred, struct vnode *vp, +test_vnode_check_setowner(struct ucred *cred, struct vnode *vp, struct label *vplabel, uid_t uid, gid_t gid) { @@ -2418,7 +2418,7 @@ mac_test_vnode_check_setowner(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_setutimes); static int -mac_test_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, +test_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, struct label *vplabel, struct timespec atime, struct timespec mtime) { @@ -2431,7 +2431,7 @@ mac_test_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, COUNTER_DECL(vnode_check_stat); static int -mac_test_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, +test_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { @@ -2446,7 +2446,7 @@ mac_test_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, COUNTER_DECL(vnode_check_unlink); static int -mac_test_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, +test_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, struct label *dvplabel, struct vnode *vp, struct label *vplabel, struct componentname *cnp) { @@ -2461,7 +2461,7 @@ mac_test_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, COUNTER_DECL(vnode_check_write); static int -mac_test_vnode_check_write(struct ucred *active_cred, +test_vnode_check_write(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp, struct label *vplabel) { @@ -2474,221 +2474,221 @@ mac_test_vnode_check_write(struct ucred *active_cred, return (0); } -static struct mac_policy_ops mac_test_ops = -{ - .mpo_bpfdesc_init_label = mac_test_bpfdesc_init_label, - .mpo_cred_init_label = mac_test_cred_init_label, - .mpo_devfs_init_label = mac_test_devfs_init_label, - .mpo_ifnet_init_label = mac_test_ifnet_init_label, - .mpo_sysvmsg_init_label = mac_test_sysvmsg_init_label, - .mpo_sysvmsq_init_label = mac_test_sysvmsq_init_label, - .mpo_sysvsem_init_label = mac_test_sysvsem_init_label, - .mpo_sysvshm_init_label = mac_test_sysvshm_init_label, - .mpo_inpcb_init_label = mac_test_inpcb_init_label, - .mpo_ipq_init_label = mac_test_ipq_init_label, - .mpo_mbuf_init_label = mac_test_mbuf_init_label, - .mpo_mount_init_label = mac_test_mount_init_label, - .mpo_pipe_init_label = mac_test_pipe_init_label, - .mpo_posixsem_init_label = mac_test_posixsem_init_label, - .mpo_proc_init_label = mac_test_proc_init_label, - .mpo_socket_init_label = mac_test_socket_init_label, - .mpo_socketpeer_init_label = mac_test_socketpeer_init_label, - .mpo_vnode_init_label = mac_test_vnode_init_label, - .mpo_bpfdesc_destroy_label = mac_test_bpfdesc_destroy_label, - .mpo_cred_destroy_label = mac_test_cred_destroy_label, - .mpo_devfs_destroy_label = mac_test_devfs_destroy_label, - .mpo_ifnet_destroy_label = mac_test_ifnet_destroy_label, - .mpo_sysvmsg_destroy_label = mac_test_sysvmsg_destroy_label, +static struct mac_policy_ops test_ops = +{ + .mpo_bpfdesc_init_label = test_bpfdesc_init_label, + .mpo_cred_init_label = test_cred_init_label, + .mpo_devfs_init_label = test_devfs_init_label, + .mpo_ifnet_init_label = test_ifnet_init_label, + .mpo_sysvmsg_init_label = test_sysvmsg_init_label, + .mpo_sysvmsq_init_label = test_sysvmsq_init_label, + .mpo_sysvsem_init_label = test_sysvsem_init_label, + .mpo_sysvshm_init_label = test_sysvshm_init_label, + .mpo_inpcb_init_label = test_inpcb_init_label, + .mpo_ipq_init_label = test_ipq_init_label, + .mpo_mbuf_init_label = test_mbuf_init_label, + .mpo_mount_init_label = test_mount_init_label, + .mpo_pipe_init_label = test_pipe_init_label, + .mpo_posixsem_init_label = test_posixsem_init_label, + .mpo_proc_init_label = test_proc_init_label, + .mpo_socket_init_label = test_socket_init_label, + .mpo_socketpeer_init_label = test_socketpeer_init_label, + .mpo_vnode_init_label = test_vnode_init_label, + .mpo_bpfdesc_destroy_label = test_bpfdesc_destroy_label, + .mpo_cred_destroy_label = test_cred_destroy_label, + .mpo_devfs_destroy_label = test_devfs_destroy_label, + .mpo_ifnet_destroy_label = test_ifnet_destroy_label, + .mpo_sysvmsg_destroy_label = test_sysvmsg_destroy_label, .mpo_sysvmsq_destroy_label = - mac_test_sysvmsq_destroy_label, - .mpo_sysvsem_destroy_label = mac_test_sysvsem_destroy_label, - .mpo_sysvshm_destroy_label = mac_test_sysvshm_destroy_label, - .mpo_inpcb_destroy_label = mac_test_inpcb_destroy_label, - .mpo_ipq_destroy_label = mac_test_ipq_destroy_label, - .mpo_mbuf_destroy_label = mac_test_mbuf_destroy_label, - .mpo_mount_destroy_label = mac_test_mount_destroy_label, - .mpo_pipe_destroy_label = mac_test_pipe_destroy_label, - .mpo_posixsem_destroy_label = mac_test_posixsem_destroy_label, - .mpo_proc_destroy_label = mac_test_proc_destroy_label, - .mpo_socket_destroy_label = mac_test_socket_destroy_label, - .mpo_socketpeer_destroy_label = mac_test_socketpeer_destroy_label, - .mpo_vnode_destroy_label = mac_test_vnode_destroy_label, - .mpo_cred_copy_label = mac_test_cred_copy_label, - .mpo_ifnet_copy_label = mac_test_ifnet_copy_label, - .mpo_mbuf_copy_label = mac_test_mbuf_copy_label, - .mpo_pipe_copy_label = mac_test_pipe_copy_label, - .mpo_socket_copy_label = mac_test_socket_copy_label, - .mpo_vnode_copy_label = mac_test_vnode_copy_label, - .mpo_cred_externalize_label = mac_test_externalize_label, - .mpo_ifnet_externalize_label = mac_test_externalize_label, - .mpo_pipe_externalize_label = mac_test_externalize_label, - .mpo_socket_externalize_label = mac_test_externalize_label, - .mpo_socketpeer_externalize_label = mac_test_externalize_label, - .mpo_vnode_externalize_label = mac_test_externalize_label, - .mpo_cred_internalize_label = mac_test_internalize_label, - .mpo_ifnet_internalize_label = mac_test_internalize_label, - .mpo_pipe_internalize_label = mac_test_internalize_label, - .mpo_socket_internalize_label = mac_test_internalize_label, - .mpo_vnode_internalize_label = mac_test_internalize_label, - .mpo_devfs_vnode_associate = mac_test_devfs_vnode_associate, - .mpo_vnode_associate_extattr = mac_test_vnode_associate_extattr, - .mpo_vnode_associate_singlelabel = mac_test_vnode_associate_singlelabel, - .mpo_devfs_create_device = mac_test_devfs_create_device, - .mpo_devfs_create_directory = mac_test_devfs_create_directory, - .mpo_devfs_create_symlink = mac_test_devfs_create_symlink, - .mpo_vnode_create_extattr = mac_test_vnode_create_extattr, - .mpo_mount_create = mac_test_mount_create, - .mpo_vnode_relabel = mac_test_vnode_relabel, - .mpo_vnode_setlabel_extattr = mac_test_vnode_setlabel_extattr, - .mpo_devfs_update = mac_test_devfs_update, - .mpo_socket_create_mbuf = mac_test_socket_create_mbuf, - .mpo_pipe_create = mac_test_pipe_create, - .mpo_posixsem_create = mac_test_posixsem_create, - .mpo_socket_create = mac_test_socket_create, - .mpo_socket_newconn = mac_test_socket_newconn, - .mpo_pipe_relabel = mac_test_pipe_relabel, - .mpo_socket_relabel = mac_test_socket_relabel, - .mpo_socketpeer_set_from_mbuf = mac_test_socketpeer_set_from_mbuf, - .mpo_socketpeer_set_from_socket = mac_test_socketpeer_set_from_socket, - .mpo_bpfdesc_create = mac_test_bpfdesc_create, - .mpo_ifnet_create = mac_test_ifnet_create, - .mpo_inpcb_create = mac_test_inpcb_create, - .mpo_sysvmsg_create = mac_test_sysvmsg_create, - .mpo_sysvmsq_create = mac_test_sysvmsq_create, - .mpo_sysvsem_create = mac_test_sysvsem_create, - .mpo_sysvshm_create = mac_test_sysvshm_create, - .mpo_ipq_reassemble = mac_test_ipq_reassemble, - .mpo_netinet_fragment = mac_test_netinet_fragment, - .mpo_ipq_create = mac_test_ipq_create, - .mpo_inpcb_create_mbuf = mac_test_inpcb_create_mbuf, - .mpo_create_mbuf_linklayer = mac_test_create_mbuf_linklayer, - .mpo_bpfdesc_create_mbuf = mac_test_bpfdesc_create_mbuf, - .mpo_ifnet_create_mbuf = mac_test_ifnet_create_mbuf, - .mpo_mbuf_create_multicast_encap = mac_test_mbuf_create_multicast_encap, - .mpo_mbuf_create_netlayer = mac_test_mbuf_create_netlayer, - .mpo_ipq_match = mac_test_ipq_match, - .mpo_netinet_icmp_reply = mac_test_netinet_icmp_reply, - .mpo_netinet_tcp_reply = mac_test_netinet_tcp_reply, - .mpo_ifnet_relabel = mac_test_ifnet_relabel, - .mpo_ipq_update = mac_test_ipq_update, - .mpo_inpcb_sosetlabel = mac_test_inpcb_sosetlabel, - .mpo_vnode_execve_transition = mac_test_vnode_execve_transition, + test_sysvmsq_destroy_label, + .mpo_sysvsem_destroy_label = test_sysvsem_destroy_label, + .mpo_sysvshm_destroy_label = test_sysvshm_destroy_label, + .mpo_inpcb_destroy_label = test_inpcb_destroy_label, + .mpo_ipq_destroy_label = test_ipq_destroy_label, + .mpo_mbuf_destroy_label = test_mbuf_destroy_label, + .mpo_mount_destroy_label = test_mount_destroy_label, + .mpo_pipe_destroy_label = test_pipe_destroy_label, + .mpo_posixsem_destroy_label = test_posixsem_destroy_label, + .mpo_proc_destroy_label = test_proc_destroy_label, + .mpo_socket_destroy_label = test_socket_destroy_label, + .mpo_socketpeer_destroy_label = test_socketpeer_destroy_label, + .mpo_vnode_destroy_label = test_vnode_destroy_label, + .mpo_cred_copy_label = test_cred_copy_label, + .mpo_ifnet_copy_label = test_ifnet_copy_label, + .mpo_mbuf_copy_label = test_mbuf_copy_label, + .mpo_pipe_copy_label = test_pipe_copy_label, + .mpo_socket_copy_label = test_socket_copy_label, + .mpo_vnode_copy_label = test_vnode_copy_label, + .mpo_cred_externalize_label = test_externalize_label, + .mpo_ifnet_externalize_label = test_externalize_label, + .mpo_pipe_externalize_label = test_externalize_label, + .mpo_socket_externalize_label = test_externalize_label, + .mpo_socketpeer_externalize_label = test_externalize_label, + .mpo_vnode_externalize_label = test_externalize_label, + .mpo_cred_internalize_label = test_internalize_label, + .mpo_ifnet_internalize_label = test_internalize_label, + .mpo_pipe_internalize_label = test_internalize_label, + .mpo_socket_internalize_label = test_internalize_label, + .mpo_vnode_internalize_label = test_internalize_label, + .mpo_devfs_vnode_associate = test_devfs_vnode_associate, + .mpo_vnode_associate_extattr = test_vnode_associate_extattr, + .mpo_vnode_associate_singlelabel = test_vnode_associate_singlelabel, + .mpo_devfs_create_device = test_devfs_create_device, + .mpo_devfs_create_directory = test_devfs_create_directory, + .mpo_devfs_create_symlink = test_devfs_create_symlink, + .mpo_vnode_create_extattr = test_vnode_create_extattr, + .mpo_mount_create = test_mount_create, + .mpo_vnode_relabel = test_vnode_relabel, + .mpo_vnode_setlabel_extattr = test_vnode_setlabel_extattr, + .mpo_devfs_update = test_devfs_update, + .mpo_socket_create_mbuf = test_socket_create_mbuf, + .mpo_pipe_create = test_pipe_create, + .mpo_posixsem_create = test_posixsem_create, + .mpo_socket_create = test_socket_create, + .mpo_socket_newconn = test_socket_newconn, + .mpo_pipe_relabel = test_pipe_relabel, + .mpo_socket_relabel = test_socket_relabel, + .mpo_socketpeer_set_from_mbuf = test_socketpeer_set_from_mbuf, + .mpo_socketpeer_set_from_socket = test_socketpeer_set_from_socket, + .mpo_bpfdesc_create = test_bpfdesc_create, + .mpo_ifnet_create = test_ifnet_create, + .mpo_inpcb_create = test_inpcb_create, + .mpo_sysvmsg_create = test_sysvmsg_create, + .mpo_sysvmsq_create = test_sysvmsq_create, + .mpo_sysvsem_create = test_sysvsem_create, + .mpo_sysvshm_create = test_sysvshm_create, + .mpo_ipq_reassemble = test_ipq_reassemble, + .mpo_netinet_fragment = test_netinet_fragment, + .mpo_ipq_create = test_ipq_create, + .mpo_inpcb_create_mbuf = test_inpcb_create_mbuf, + .mpo_create_mbuf_linklayer = test_create_mbuf_linklayer, + .mpo_bpfdesc_create_mbuf = test_bpfdesc_create_mbuf, + .mpo_ifnet_create_mbuf = test_ifnet_create_mbuf, + .mpo_mbuf_create_multicast_encap = test_mbuf_create_multicast_encap, + .mpo_mbuf_create_netlayer = test_mbuf_create_netlayer, + .mpo_ipq_match = test_ipq_match, + .mpo_netinet_icmp_reply = test_netinet_icmp_reply, + .mpo_netinet_tcp_reply = test_netinet_tcp_reply, + .mpo_ifnet_relabel = test_ifnet_relabel, + .mpo_ipq_update = test_ipq_update, + .mpo_inpcb_sosetlabel = test_inpcb_sosetlabel, + .mpo_vnode_execve_transition = test_vnode_execve_transition, .mpo_vnode_execve_will_transition = - mac_test_vnode_execve_will_transition, - .mpo_proc_create_swapper = mac_test_proc_create_swapper, - .mpo_proc_create_init = mac_test_proc_create_init, - .mpo_cred_relabel = mac_test_cred_relabel, - .mpo_thread_userret = mac_test_thread_userret, - .mpo_sysvmsg_cleanup = mac_test_sysvmsg_cleanup, - .mpo_sysvmsq_cleanup = mac_test_sysvmsq_cleanup, - .mpo_sysvsem_cleanup = mac_test_sysvsem_cleanup, - .mpo_sysvshm_cleanup = mac_test_sysvshm_cleanup, - .mpo_bpfdesc_check_receive = mac_test_bpfdesc_check_receive, - .mpo_cred_check_relabel = mac_test_cred_check_relabel, - .mpo_cred_check_visible = mac_test_cred_check_visible, - .mpo_ifnet_check_relabel = mac_test_ifnet_check_relabel, - .mpo_ifnet_check_transmit = mac_test_ifnet_check_transmit, - .mpo_inpcb_check_deliver = mac_test_inpcb_check_deliver, - .mpo_sysvmsq_check_msgmsq = mac_test_sysvmsq_check_msgmsq, - .mpo_sysvmsq_check_msgrcv = mac_test_sysvmsq_check_msgrcv, - .mpo_sysvmsq_check_msgrmid = mac_test_sysvmsq_check_msgrmid, - .mpo_sysvmsq_check_msqget = mac_test_sysvmsq_check_msqget, - .mpo_sysvmsq_check_msqsnd = mac_test_sysvmsq_check_msqsnd, - .mpo_sysvmsq_check_msqrcv = mac_test_sysvmsq_check_msqrcv, - .mpo_sysvmsq_check_msqctl = mac_test_sysvmsq_check_msqctl, - .mpo_sysvsem_check_semctl = mac_test_sysvsem_check_semctl, - .mpo_sysvsem_check_semget = mac_test_sysvsem_check_semget, - .mpo_sysvsem_check_semop = mac_test_sysvsem_check_semop, - .mpo_sysvshm_check_shmat = mac_test_sysvshm_check_shmat, - .mpo_sysvshm_check_shmctl = mac_test_sysvshm_check_shmctl, - .mpo_sysvshm_check_shmdt = mac_test_sysvshm_check_shmdt, - .mpo_sysvshm_check_shmget = mac_test_sysvshm_check_shmget, - .mpo_kenv_check_dump = mac_test_kenv_check_dump, - .mpo_kenv_check_get = mac_test_kenv_check_get, - .mpo_kenv_check_set = mac_test_kenv_check_set, - .mpo_kenv_check_unset = mac_test_kenv_check_unset, - .mpo_kld_check_load = mac_test_kld_check_load, - .mpo_kld_check_stat = mac_test_kld_check_stat, - .mpo_mount_check_stat = mac_test_mount_check_stat, - .mpo_pipe_check_ioctl = mac_test_pipe_check_ioctl, - .mpo_pipe_check_poll = mac_test_pipe_check_poll, - .mpo_pipe_check_read = mac_test_pipe_check_read, - .mpo_pipe_check_relabel = mac_test_pipe_check_relabel, - .mpo_pipe_check_stat = mac_test_pipe_check_stat, - .mpo_pipe_check_write = mac_test_pipe_check_write, - .mpo_posixsem_check_destroy = mac_test_posixsem_check, - .mpo_posixsem_check_getvalue = mac_test_posixsem_check, - .mpo_posixsem_check_open = mac_test_posixsem_check, - .mpo_posixsem_check_post = mac_test_posixsem_check, - .mpo_posixsem_check_unlink = mac_test_posixsem_check, - .mpo_posixsem_check_wait = mac_test_posixsem_check, - .mpo_proc_check_debug = mac_test_proc_check_debug, - .mpo_proc_check_sched = mac_test_proc_check_sched, - .mpo_proc_check_setaudit = mac_test_proc_check_setaudit, - .mpo_proc_check_setaudit_addr = mac_test_proc_check_setaudit_addr, - .mpo_proc_check_setauid = mac_test_proc_check_setauid, - .mpo_proc_check_setuid = mac_test_proc_check_setuid, - .mpo_proc_check_seteuid = mac_test_proc_check_seteuid, - .mpo_proc_check_setgid = mac_test_proc_check_setgid, - .mpo_proc_check_setegid = mac_test_proc_check_setegid, - .mpo_proc_check_setgroups = mac_test_proc_check_setgroups, - .mpo_proc_check_setreuid = mac_test_proc_check_setreuid, - .mpo_proc_check_setregid = mac_test_proc_check_setregid, - .mpo_proc_check_setresuid = mac_test_proc_check_setresuid, - .mpo_proc_check_setresgid = mac_test_proc_check_setresgid, - .mpo_proc_check_signal = mac_test_proc_check_signal, - .mpo_proc_check_wait = mac_test_proc_check_wait, - .mpo_socket_check_accept = mac_test_socket_check_accept, - .mpo_socket_check_bind = mac_test_socket_check_bind, - .mpo_socket_check_connect = mac_test_socket_check_connect, - .mpo_socket_check_deliver = mac_test_socket_check_deliver, - .mpo_socket_check_listen = mac_test_socket_check_listen, - .mpo_socket_check_poll = mac_test_socket_check_poll, - .mpo_socket_check_receive = mac_test_socket_check_receive, - .mpo_socket_check_relabel = mac_test_socket_check_relabel, - .mpo_socket_check_send = mac_test_socket_check_send, - .mpo_socket_check_stat = mac_test_socket_check_stat, - .mpo_socket_check_visible = mac_test_socket_check_visible, - .mpo_system_check_acct = mac_test_system_check_acct, - .mpo_system_check_audit = mac_test_system_check_audit, - .mpo_system_check_auditctl = mac_test_system_check_auditctl, - .mpo_system_check_auditon = mac_test_system_check_auditon, - .mpo_system_check_reboot = mac_test_system_check_reboot, - .mpo_system_check_swapoff = mac_test_system_check_swapoff, - .mpo_system_check_swapon = mac_test_system_check_swapon, - .mpo_system_check_sysctl = mac_test_system_check_sysctl, - .mpo_vnode_check_access = mac_test_vnode_check_access, - .mpo_vnode_check_chdir = mac_test_vnode_check_chdir, - .mpo_vnode_check_chroot = mac_test_vnode_check_chroot, - .mpo_vnode_check_create = mac_test_vnode_check_create, - .mpo_vnode_check_deleteacl = mac_test_vnode_check_deleteacl, - .mpo_vnode_check_deleteextattr = mac_test_vnode_check_deleteextattr, - .mpo_vnode_check_exec = mac_test_vnode_check_exec, - .mpo_vnode_check_getacl = mac_test_vnode_check_getacl, - .mpo_vnode_check_getextattr = mac_test_vnode_check_getextattr, - .mpo_vnode_check_link = mac_test_vnode_check_link, - .mpo_vnode_check_listextattr = mac_test_vnode_check_listextattr, - .mpo_vnode_check_lookup = mac_test_vnode_check_lookup, - .mpo_vnode_check_mmap = mac_test_vnode_check_mmap, - .mpo_vnode_check_open = mac_test_vnode_check_open, - .mpo_vnode_check_poll = mac_test_vnode_check_poll, - .mpo_vnode_check_read = mac_test_vnode_check_read, - .mpo_vnode_check_readdir = mac_test_vnode_check_readdir, - .mpo_vnode_check_readlink = mac_test_vnode_check_readlink, - .mpo_vnode_check_relabel = mac_test_vnode_check_relabel, - .mpo_vnode_check_rename_from = mac_test_vnode_check_rename_from, - .mpo_vnode_check_rename_to = mac_test_vnode_check_rename_to, - .mpo_vnode_check_revoke = mac_test_vnode_check_revoke, - .mpo_vnode_check_setacl = mac_test_vnode_check_setacl, - .mpo_vnode_check_setextattr = mac_test_vnode_check_setextattr, - .mpo_vnode_check_setflags = mac_test_vnode_check_setflags, - .mpo_vnode_check_setmode = mac_test_vnode_check_setmode, - .mpo_vnode_check_setowner = mac_test_vnode_check_setowner, - .mpo_vnode_check_setutimes = mac_test_vnode_check_setutimes, - .mpo_vnode_check_stat = mac_test_vnode_check_stat, - .mpo_vnode_check_unlink = mac_test_vnode_check_unlink, - .mpo_vnode_check_write = mac_test_vnode_check_write, + test_vnode_execve_will_transition, + .mpo_proc_create_swapper = test_proc_create_swapper, + .mpo_proc_create_init = test_proc_create_init, + .mpo_cred_relabel = test_cred_relabel, + .mpo_thread_userret = test_thread_userret, + .mpo_sysvmsg_cleanup = test_sysvmsg_cleanup, + .mpo_sysvmsq_cleanup = test_sysvmsq_cleanup, + .mpo_sysvsem_cleanup = test_sysvsem_cleanup, + .mpo_sysvshm_cleanup = test_sysvshm_cleanup, + .mpo_bpfdesc_check_receive = test_bpfdesc_check_receive, + .mpo_cred_check_relabel = test_cred_check_relabel, + .mpo_cred_check_visible = test_cred_check_visible, + .mpo_ifnet_check_relabel = test_ifnet_check_relabel, + .mpo_ifnet_check_transmit = test_ifnet_check_transmit, + .mpo_inpcb_check_deliver = test_inpcb_check_deliver, + .mpo_sysvmsq_check_msgmsq = test_sysvmsq_check_msgmsq, + .mpo_sysvmsq_check_msgrcv = test_sysvmsq_check_msgrcv, + .mpo_sysvmsq_check_msgrmid = test_sysvmsq_check_msgrmid, + .mpo_sysvmsq_check_msqget = test_sysvmsq_check_msqget, + .mpo_sysvmsq_check_msqsnd = test_sysvmsq_check_msqsnd, + .mpo_sysvmsq_check_msqrcv = test_sysvmsq_check_msqrcv, + .mpo_sysvmsq_check_msqctl = test_sysvmsq_check_msqctl, + .mpo_sysvsem_check_semctl = test_sysvsem_check_semctl, + .mpo_sysvsem_check_semget = test_sysvsem_check_semget, + .mpo_sysvsem_check_semop = test_sysvsem_check_semop, + .mpo_sysvshm_check_shmat = test_sysvshm_check_shmat, + .mpo_sysvshm_check_shmctl = test_sysvshm_check_shmctl, + .mpo_sysvshm_check_shmdt = test_sysvshm_check_shmdt, + .mpo_sysvshm_check_shmget = test_sysvshm_check_shmget, + .mpo_kenv_check_dump = test_kenv_check_dump, + .mpo_kenv_check_get = test_kenv_check_get, + .mpo_kenv_check_set = test_kenv_check_set, + .mpo_kenv_check_unset = test_kenv_check_unset, + .mpo_kld_check_load = test_kld_check_load, + .mpo_kld_check_stat = test_kld_check_stat, + .mpo_mount_check_stat = test_mount_check_stat, + .mpo_pipe_check_ioctl = test_pipe_check_ioctl, + .mpo_pipe_check_poll = test_pipe_check_poll, + .mpo_pipe_check_read = test_pipe_check_read, + .mpo_pipe_check_relabel = test_pipe_check_relabel, + .mpo_pipe_check_stat = test_pipe_check_stat, + .mpo_pipe_check_write = test_pipe_check_write, + .mpo_posixsem_check_destroy = test_posixsem_check, + .mpo_posixsem_check_getvalue = test_posixsem_check, + .mpo_posixsem_check_open = test_posixsem_check, + .mpo_posixsem_check_post = test_posixsem_check, + .mpo_posixsem_check_unlink = test_posixsem_check, + .mpo_posixsem_check_wait = test_posixsem_check, + .mpo_proc_check_debug = test_proc_check_debug, + .mpo_proc_check_sched = test_proc_check_sched, + .mpo_proc_check_setaudit = test_proc_check_setaudit, + .mpo_proc_check_setaudit_addr = test_proc_check_setaudit_addr, + .mpo_proc_check_setauid = test_proc_check_setauid, + .mpo_proc_check_setuid = test_proc_check_setuid, + .mpo_proc_check_seteuid = test_proc_check_seteuid, + .mpo_proc_check_setgid = test_proc_check_setgid, + .mpo_proc_check_setegid = test_proc_check_setegid, + .mpo_proc_check_setgroups = test_proc_check_setgroups, + .mpo_proc_check_setreuid = test_proc_check_setreuid, + .mpo_proc_check_setregid = test_proc_check_setregid, + .mpo_proc_check_setresuid = test_proc_check_setresuid, + .mpo_proc_check_setresgid = test_proc_check_setresgid, + .mpo_proc_check_signal = test_proc_check_signal, + .mpo_proc_check_wait = test_proc_check_wait, + .mpo_socket_check_accept = test_socket_check_accept, + .mpo_socket_check_bind = test_socket_check_bind, + .mpo_socket_check_connect = test_socket_check_connect, + .mpo_socket_check_deliver = test_socket_check_deliver, + .mpo_socket_check_listen = test_socket_check_listen, + .mpo_socket_check_poll = test_socket_check_poll, + .mpo_socket_check_receive = test_socket_check_receive, + .mpo_socket_check_relabel = test_socket_check_relabel, + .mpo_socket_check_send = test_socket_check_send, + .mpo_socket_check_stat = test_socket_check_stat, + .mpo_socket_check_visible = test_socket_check_visible, + .mpo_system_check_acct = test_system_check_acct, + .mpo_system_check_audit = test_system_check_audit, + .mpo_system_check_auditctl = test_system_check_auditctl, + .mpo_system_check_auditon = test_system_check_auditon, + .mpo_system_check_reboot = test_system_check_reboot, + .mpo_system_check_swapoff = test_system_check_swapoff, + .mpo_system_check_swapon = test_system_check_swapon, + .mpo_system_check_sysctl = test_system_check_sysctl, + .mpo_vnode_check_access = test_vnode_check_access, + .mpo_vnode_check_chdir = test_vnode_check_chdir, + .mpo_vnode_check_chroot = test_vnode_check_chroot, + .mpo_vnode_check_create = test_vnode_check_create, + .mpo_vnode_check_deleteacl = test_vnode_check_deleteacl, + .mpo_vnode_check_deleteextattr = test_vnode_check_deleteextattr, + .mpo_vnode_check_exec = test_vnode_check_exec, + .mpo_vnode_check_getacl = test_vnode_check_getacl, + .mpo_vnode_check_getextattr = test_vnode_check_getextattr, + .mpo_vnode_check_link = test_vnode_check_link, + .mpo_vnode_check_listextattr = test_vnode_check_listextattr, + .mpo_vnode_check_lookup = test_vnode_check_lookup, + .mpo_vnode_check_mmap = test_vnode_check_mmap, + .mpo_vnode_check_open = test_vnode_check_open, + .mpo_vnode_check_poll = test_vnode_check_poll, + .mpo_vnode_check_read = test_vnode_check_read, + .mpo_vnode_check_readdir = test_vnode_check_readdir, + .mpo_vnode_check_readlink = test_vnode_check_readlink, + .mpo_vnode_check_relabel = test_vnode_check_relabel, + .mpo_vnode_check_rename_from = test_vnode_check_rename_from, + .mpo_vnode_check_rename_to = test_vnode_check_rename_to, + .mpo_vnode_check_revoke = test_vnode_check_revoke, + .mpo_vnode_check_setacl = test_vnode_check_setacl, + .mpo_vnode_check_setextattr = test_vnode_check_setextattr, + .mpo_vnode_check_setflags = test_vnode_check_setflags, + .mpo_vnode_check_setmode = test_vnode_check_setmode, + .mpo_vnode_check_setowner = test_vnode_check_setowner, + .mpo_vnode_check_setutimes = test_vnode_check_setutimes, + .mpo_vnode_check_stat = test_vnode_check_stat, + .mpo_vnode_check_unlink = test_vnode_check_unlink, + .mpo_vnode_check_write = test_vnode_check_write, }; -MAC_POLICY_SET(&mac_test_ops, mac_test, "TrustedBSD MAC/Test", +MAC_POLICY_SET(&test_ops, mac_test, "TrustedBSD MAC/Test", MPC_LOADTIME_FLAG_UNLOADOK | MPC_LOADTIME_FLAG_LABELMBUFS, &test_slot); |