Lines Matching refs:label
40 ZONE_DEFINE_ID(ZONE_ID_MAC_LABEL, "MAC Labels", struct label,
46 const struct label empty_label = {
50 static struct label *
57 struct label *
60 struct label *label; in mac_labelzone_alloc() local
62 label = label_alloc_noinit(flags); in mac_labelzone_alloc()
63 if (label) { in mac_labelzone_alloc()
64 zalloc_ro_update_elem(ZONE_ID_MAC_LABEL, label, &empty_label); in mac_labelzone_alloc()
67 return label; in mac_labelzone_alloc()
70 struct label *
71 mac_labelzone_alloc_for_owner(struct label **labelp, int flags,
72 void (^extra_setup)(struct label *))
74 struct label *label; member
77 struct label tmp_label = empty_label;
79 label = zalloc_ro(ZONE_ID_MAC_LABEL, Z_ZERO | (flags & MAC_NOWAIT));
82 zalloc_ro_update_elem(ZONE_ID_MAC_LABEL, label, &tmp_label);
84 label = mac_labelzone_alloc(flags);
87 if (label && extra_setup) {
88 extra_setup(label);
91 return label;
94 struct label *
95 mac_labelzone_alloc_owned(struct label **labelp, int flags,
96 void (^extra_setup)(struct label *))
98 struct label *label; variable
100 label = mac_labelzone_alloc_for_owner(labelp, flags, extra_setup);
103 *labelp = label;
106 return label;
110 mac_labelzone_free(struct label *label) in mac_labelzone_free() argument
112 if (label == NULL) { in mac_labelzone_free()
116 zfree_ro(ZONE_ID_MAC_LABEL, label); in mac_labelzone_free()
120 mac_labelzone_free_owned(struct label **labelp,
121 void (^extra_deinit)(struct label *))
123 struct label *label; variable
125 label = mac_label_verify(labelp);
126 if (label) {
128 extra_deinit(label);
132 mac_labelzone_free(label);
138 mac_label_verify_panic(struct label **labelp) in mac_label_verify_panic()
144 struct label *
145 mac_label_verify(struct label **labelp) in mac_label_verify()
147 struct label *label = *labelp; in mac_label_verify() local
149 if (label != NULL) { in mac_label_verify()
150 zone_require_ro(ZONE_ID_MAC_LABEL, sizeof(struct label), label); in mac_label_verify()
152 if (__improbable(label->l_owner != labelp)) { in mac_label_verify()
157 return label; in mac_label_verify()
184 mac_label_get(struct label *label, int slot) in mac_label_get() argument
186 KASSERT(label != NULL, ("mac_label_get: NULL label")); in mac_label_get()
188 zone_require_ro(ZONE_ID_MAC_LABEL, sizeof(struct label), label); in mac_label_get()
189 return mac_label_slot_decode((intptr_t) label->l_perpolicy[slot]); in mac_label_get()
200 mac_label_set(struct label *label, int slot, intptr_t v) in mac_label_set() argument
202 KASSERT(label != NULL, ("mac_label_set: NULL label")); in mac_label_set()
206 assertf(label->l_owner != (struct label **)-1, in mac_label_set()
208 label, slot, v); in mac_label_set()
214 zalloc_ro_update_field(ZONE_ID_MAC_LABEL, label, l_perpolicy[slot], &v); in mac_label_set()