21 #include <linux/kernel.h>
22 #include <linux/slab.h>
23 #include <linux/string.h>
24 #include <linux/errno.h>
46 for (l = 0; l < 2; l++) {
47 int index_sens = context->
range.level[
l].sens;
53 e = &context->
range.level[
l].cat;
72 if (mls_level_eq(&context->
range.level[0],
73 &context->
range.level[1]))
99 scontextp = *scontext;
104 for (l = 0; l < 2; l++) {
106 context->
range.level[l].sens - 1));
107 scontextp +=
strlen(scontextp);
112 e = &context->
range.level[
l].cat;
148 if (mls_level_eq(&context->
range.level[0],
149 &context->
range.level[1]))
156 *scontext = scontextp;
166 if (!l->
sens || l->
sens > p->p_levels.nprim)
174 if (i > p->p_cats.nprim)
215 if (!c->
user || c->
user > p->p_users.nprim)
251 char *scontextp, *
p, *rngptr;
258 *scontext +=
strlen(*scontext) + 1;
267 struct context *defcon;
276 rc = mls_context_cpy(context, defcon);
281 scontextp = p = *scontext;
282 while (*p && *p !=
':' && *p !=
'-')
289 for (l = 0; l < 2; l++) {
296 context->
range.level[
l].sens = levdatum->
level->sens;
302 while (*p && *p !=
',' && *p !=
'-')
309 rngptr =
strchr(scontextp,
'.');
310 if (rngptr !=
NULL) {
323 catdatum->
value - 1, 1);
342 for (i = catdatum->
value; i < rngdatum->
value; i++) {
356 while (*p && *p !=
':')
367 context->
range.level[1].sens = context->
range.level[0].sens;
369 &context->
range.level[0].cat);
387 char *tmpstr, *freestr;
395 tmpstr = freestr =
kstrdup(str, gfp_mask);
416 for (l = 0; l < 2; l++) {
419 &range->
level[l].cat);
441 *usercon_sen = *user_def;
443 *usercon_sen = *fromcon_sen;
445 *usercon_sen = *user_low;
454 if (mls_level_dom(user_clr, fromcon_clr))
455 *usercon_clr = *fromcon_clr;
456 else if (mls_level_dom(fromcon_clr, user_clr))
457 *usercon_clr = *user_clr;
483 for (l = 0; l < 2; l++) {
486 c->
range.level[l].sens - 1));
492 ebitmap_init(&bitmap);
536 if (tclass && tclass <=
policydb.p_classes.nprim) {
542 switch (default_range) {
544 return mls_context_cpy_low(newcontext, scontext);
546 return mls_context_cpy_high(newcontext, scontext);
548 return mls_context_cpy(newcontext, scontext);
550 return mls_context_cpy_low(newcontext, tcontext);
552 return mls_context_cpy_high(newcontext, tcontext);
554 return mls_context_cpy(newcontext, tcontext);
561 return mls_context_cpy(newcontext, scontext);
564 return mls_context_cpy_low(newcontext, scontext);
567 return mls_context_cpy_low(newcontext, scontext);
574 #ifdef CONFIG_NETLABEL
591 secattr->
attr.mls.lvl = context->
range.level[0].sens - 1;
605 void mls_import_netlbl_lvl(
struct context *context,
611 context->
range.level[0].sens = secattr->
attr.mls.lvl + 1;
612 context->
range.level[1].sens = context->
range.level[0].sens;
625 int mls_export_netlbl_cat(
struct context *context,
633 rc = ebitmap_netlbl_export(&context->
range.level[0].cat,
634 &secattr->
attr.mls.cat);
635 if (rc == 0 && secattr->
attr.mls.cat !=
NULL)
653 int mls_import_netlbl_cat(
struct context *context,
661 rc = ebitmap_netlbl_import(&context->
range.level[0].cat,
662 secattr->
attr.mls.cat);
664 goto import_netlbl_cat_failure;
667 &context->
range.level[0].cat);
669 goto import_netlbl_cat_failure;
673 import_netlbl_cat_failure: