selinux: reconcile security_netlbl_secattr_to_sid() and mls_import_netlbl_cat()
authorPaul Moore <pmoore@redhat.com>
Tue, 17 Feb 2015 20:30:23 +0000 (15:30 -0500)
committerPaul Moore <pmoore@redhat.com>
Tue, 7 Apr 2015 00:15:55 +0000 (20:15 -0400)
Move the NetLabel secattr MLS category import logic into
mls_import_netlbl_cat() where it belongs, and use the
mls_import_netlbl_cat() function in security_netlbl_secattr_to_sid().

Reported-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Paul Moore <pmoore@redhat.com>
security/selinux/ss/mls.c
security/selinux/ss/services.c

index d307b37ddc2b3b3a993c5196c9205620433aa379..e1088842232c6aefd334c2bf96c51549d8a55363 100644 (file)
@@ -654,19 +654,15 @@ int mls_import_netlbl_cat(struct context *context,
 
        rc = ebitmap_netlbl_import(&context->range.level[0].cat,
                                   secattr->attr.mls.cat);
-       if (rc != 0)
-               goto import_netlbl_cat_failure;
-
-       rc = ebitmap_cpy(&context->range.level[1].cat,
-                        &context->range.level[0].cat);
-       if (rc != 0)
+       if (rc)
                goto import_netlbl_cat_failure;
+       memcpy(&context->range.level[1].cat, &context->range.level[0].cat,
+              sizeof(context->range.level[0].cat));
 
        return 0;
 
 import_netlbl_cat_failure:
        ebitmap_destroy(&context->range.level[0].cat);
-       ebitmap_destroy(&context->range.level[1].cat);
        return rc;
 }
 #endif /* CONFIG_NETLABEL */
index a1d3944751b9e2fbfd23e18b694b00cd150880dc..9e2d82070915366333e193b99aca5badf16af72c 100644 (file)
@@ -3179,13 +3179,9 @@ int security_netlbl_secattr_to_sid(struct netlbl_lsm_secattr *secattr,
                ctx_new.type = ctx->type;
                mls_import_netlbl_lvl(&ctx_new, secattr);
                if (secattr->flags & NETLBL_SECATTR_MLS_CAT) {
-                       rc = ebitmap_netlbl_import(&ctx_new.range.level[0].cat,
-                                                  secattr->attr.mls.cat);
+                       rc = mls_import_netlbl_cat(&ctx_new, secattr);
                        if (rc)
                                goto out;
-                       memcpy(&ctx_new.range.level[1].cat,
-                              &ctx_new.range.level[0].cat,
-                              sizeof(ctx_new.range.level[0].cat));
                }
                rc = -EIDRM;
                if (!mls_context_isvalid(&policydb, &ctx_new))