Lines Matching +full:user +full:- +full:level

1 /* SPDX-License-Identifier: GPL-2.0 */
6 * externally represented as variable-length strings
7 * that can be interpreted by a user or application
24 * A security context consists of an authenticated user
28 u32 user; member
38 memset(&c->range, 0, sizeof(c->range)); in mls_context_init()
45 dst->range.level[0].sens = src->range.level[0].sens; in mls_context_cpy()
46 rc = ebitmap_cpy(&dst->range.level[0].cat, &src->range.level[0].cat); in mls_context_cpy()
50 dst->range.level[1].sens = src->range.level[1].sens; in mls_context_cpy()
51 rc = ebitmap_cpy(&dst->range.level[1].cat, &src->range.level[1].cat); in mls_context_cpy()
53 ebitmap_destroy(&dst->range.level[0].cat); in mls_context_cpy()
59 * Sets both levels in the MLS range of 'dst' to the low level of 'src'.
65 dst->range.level[0].sens = src->range.level[0].sens; in mls_context_cpy_low()
66 rc = ebitmap_cpy(&dst->range.level[0].cat, &src->range.level[0].cat); in mls_context_cpy_low()
70 dst->range.level[1].sens = src->range.level[0].sens; in mls_context_cpy_low()
71 rc = ebitmap_cpy(&dst->range.level[1].cat, &src->range.level[0].cat); in mls_context_cpy_low()
73 ebitmap_destroy(&dst->range.level[0].cat); in mls_context_cpy_low()
79 * Sets both levels in the MLS range of 'dst' to the high level of 'src'.
85 dst->range.level[0].sens = src->range.level[1].sens; in mls_context_cpy_high()
86 rc = ebitmap_cpy(&dst->range.level[0].cat, &src->range.level[1].cat); in mls_context_cpy_high()
90 dst->range.level[1].sens = src->range.level[1].sens; in mls_context_cpy_high()
91 rc = ebitmap_cpy(&dst->range.level[1].cat, &src->range.level[1].cat); in mls_context_cpy_high()
93 ebitmap_destroy(&dst->range.level[0].cat); in mls_context_cpy_high()
102 struct mls_range *dr = &dst->range; in mls_context_glblub()
103 const struct mls_range *r1 = &c1->range, *r2 = &c2->range; in mls_context_glblub()
106 if (r1->level[1].sens < r2->level[0].sens || in mls_context_glblub()
107 r2->level[1].sens < r1->level[0].sens) in mls_context_glblub()
109 return -EINVAL; in mls_context_glblub()
112 dr->level[0].sens = max(r1->level[0].sens, r2->level[0].sens); in mls_context_glblub()
115 dr->level[1].sens = min(r1->level[1].sens, r2->level[1].sens); in mls_context_glblub()
117 rc = ebitmap_and(&dr->level[0].cat, in mls_context_glblub()
118 &r1->level[0].cat, &r2->level[0].cat); in mls_context_glblub()
122 rc = ebitmap_and(&dr->level[1].cat, in mls_context_glblub()
123 &r1->level[1].cat, &r2->level[1].cat); in mls_context_glblub()
133 return ((c1->range.level[0].sens == c2->range.level[0].sens) && in mls_context_cmp()
134 ebitmap_cmp(&c1->range.level[0].cat, &c2->range.level[0].cat) && in mls_context_cmp()
135 (c1->range.level[1].sens == c2->range.level[1].sens) && in mls_context_cmp()
136 ebitmap_cmp(&c1->range.level[1].cat, &c2->range.level[1].cat)); in mls_context_cmp()
141 ebitmap_destroy(&c->range.level[0].cat); in mls_context_destroy()
142 ebitmap_destroy(&c->range.level[1].cat); in mls_context_destroy()
155 dst->user = src->user; in context_cpy()
156 dst->role = src->role; in context_cpy()
157 dst->type = src->type; in context_cpy()
158 if (src->str) { in context_cpy()
159 dst->str = kstrdup(src->str, GFP_ATOMIC); in context_cpy()
160 if (!dst->str) in context_cpy()
161 return -ENOMEM; in context_cpy()
162 dst->len = src->len; in context_cpy()
164 dst->str = NULL; in context_cpy()
165 dst->len = 0; in context_cpy()
169 kfree(dst->str); in context_cpy()
177 c->user = c->role = c->type = 0; in context_destroy()
178 kfree(c->str); in context_destroy()
179 c->str = NULL; in context_destroy()
180 c->len = 0; in context_destroy()
186 if (c1->len && c2->len) in context_cmp()
187 return (c1->len == c2->len && !strcmp(c1->str, c2->str)); in context_cmp()
188 if (c1->len || c2->len) in context_cmp()
190 return ((c1->user == c2->user) && in context_cmp()
191 (c1->role == c2->role) && in context_cmp()
192 (c1->type == c2->type) && in context_cmp()