diff options
Diffstat (limited to 'security')
| -rw-r--r-- | security/device_cgroup.c | 18 | ||||
| -rw-r--r-- | security/selinux/ss/services.c | 17 |
2 files changed, 16 insertions, 19 deletions
diff --git a/security/device_cgroup.c b/security/device_cgroup.c index 7bd296cca041..46f23971f7e4 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c | |||
| @@ -508,12 +508,11 @@ int devcgroup_inode_permission(struct inode *inode, int mask) | |||
| 508 | return 0; | 508 | return 0; |
| 509 | if (!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode)) | 509 | if (!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode)) |
| 510 | return 0; | 510 | return 0; |
| 511 | dev_cgroup = css_to_devcgroup(task_subsys_state(current, | ||
| 512 | devices_subsys_id)); | ||
| 513 | if (!dev_cgroup) | ||
| 514 | return 0; | ||
| 515 | 511 | ||
| 516 | rcu_read_lock(); | 512 | rcu_read_lock(); |
| 513 | |||
| 514 | dev_cgroup = task_devcgroup(current); | ||
| 515 | |||
| 517 | list_for_each_entry_rcu(wh, &dev_cgroup->whitelist, list) { | 516 | list_for_each_entry_rcu(wh, &dev_cgroup->whitelist, list) { |
| 518 | if (wh->type & DEV_ALL) | 517 | if (wh->type & DEV_ALL) |
| 519 | goto acc_check; | 518 | goto acc_check; |
| @@ -533,6 +532,7 @@ acc_check: | |||
| 533 | rcu_read_unlock(); | 532 | rcu_read_unlock(); |
| 534 | return 0; | 533 | return 0; |
| 535 | } | 534 | } |
| 535 | |||
| 536 | rcu_read_unlock(); | 536 | rcu_read_unlock(); |
| 537 | 537 | ||
| 538 | return -EPERM; | 538 | return -EPERM; |
| @@ -543,12 +543,10 @@ int devcgroup_inode_mknod(int mode, dev_t dev) | |||
| 543 | struct dev_cgroup *dev_cgroup; | 543 | struct dev_cgroup *dev_cgroup; |
| 544 | struct dev_whitelist_item *wh; | 544 | struct dev_whitelist_item *wh; |
| 545 | 545 | ||
| 546 | dev_cgroup = css_to_devcgroup(task_subsys_state(current, | ||
| 547 | devices_subsys_id)); | ||
| 548 | if (!dev_cgroup) | ||
| 549 | return 0; | ||
| 550 | |||
| 551 | rcu_read_lock(); | 546 | rcu_read_lock(); |
| 547 | |||
| 548 | dev_cgroup = task_devcgroup(current); | ||
| 549 | |||
| 552 | list_for_each_entry(wh, &dev_cgroup->whitelist, list) { | 550 | list_for_each_entry(wh, &dev_cgroup->whitelist, list) { |
| 553 | if (wh->type & DEV_ALL) | 551 | if (wh->type & DEV_ALL) |
| 554 | goto acc_check; | 552 | goto acc_check; |
| @@ -566,6 +564,8 @@ acc_check: | |||
| 566 | rcu_read_unlock(); | 564 | rcu_read_unlock(); |
| 567 | return 0; | 565 | return 0; |
| 568 | } | 566 | } |
| 567 | |||
| 569 | rcu_read_unlock(); | 568 | rcu_read_unlock(); |
| 569 | |||
| 570 | return -EPERM; | 570 | return -EPERM; |
| 571 | } | 571 | } |
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index b52f923ce680..8551952ef329 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c | |||
| @@ -811,11 +811,12 @@ static int string_to_context_struct(struct policydb *pol, | |||
| 811 | /* Check the validity of the new context. */ | 811 | /* Check the validity of the new context. */ |
| 812 | if (!policydb_context_isvalid(pol, ctx)) { | 812 | if (!policydb_context_isvalid(pol, ctx)) { |
| 813 | rc = -EINVAL; | 813 | rc = -EINVAL; |
| 814 | context_destroy(ctx); | ||
| 815 | goto out; | 814 | goto out; |
| 816 | } | 815 | } |
| 817 | rc = 0; | 816 | rc = 0; |
| 818 | out: | 817 | out: |
| 818 | if (rc) | ||
| 819 | context_destroy(ctx); | ||
| 819 | return rc; | 820 | return rc; |
| 820 | } | 821 | } |
| 821 | 822 | ||
| @@ -868,8 +869,7 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len, | |||
| 868 | } else if (rc) | 869 | } else if (rc) |
| 869 | goto out; | 870 | goto out; |
| 870 | rc = sidtab_context_to_sid(&sidtab, &context, sid); | 871 | rc = sidtab_context_to_sid(&sidtab, &context, sid); |
| 871 | if (rc) | 872 | context_destroy(&context); |
| 872 | context_destroy(&context); | ||
| 873 | out: | 873 | out: |
| 874 | read_unlock(&policy_rwlock); | 874 | read_unlock(&policy_rwlock); |
| 875 | kfree(scontext2); | 875 | kfree(scontext2); |
| @@ -2737,6 +2737,7 @@ int security_netlbl_secattr_to_sid(struct netlbl_lsm_secattr *secattr, | |||
| 2737 | if (ctx == NULL) | 2737 | if (ctx == NULL) |
| 2738 | goto netlbl_secattr_to_sid_return; | 2738 | goto netlbl_secattr_to_sid_return; |
| 2739 | 2739 | ||
| 2740 | context_init(&ctx_new); | ||
| 2740 | ctx_new.user = ctx->user; | 2741 | ctx_new.user = ctx->user; |
| 2741 | ctx_new.role = ctx->role; | 2742 | ctx_new.role = ctx->role; |
| 2742 | ctx_new.type = ctx->type; | 2743 | ctx_new.type = ctx->type; |
| @@ -2745,13 +2746,9 @@ int security_netlbl_secattr_to_sid(struct netlbl_lsm_secattr *secattr, | |||
| 2745 | if (ebitmap_netlbl_import(&ctx_new.range.level[0].cat, | 2746 | if (ebitmap_netlbl_import(&ctx_new.range.level[0].cat, |
| 2746 | secattr->attr.mls.cat) != 0) | 2747 | secattr->attr.mls.cat) != 0) |
| 2747 | goto netlbl_secattr_to_sid_return; | 2748 | goto netlbl_secattr_to_sid_return; |
| 2748 | ctx_new.range.level[1].cat.highbit = | 2749 | memcpy(&ctx_new.range.level[1].cat, |
| 2749 | ctx_new.range.level[0].cat.highbit; | 2750 | &ctx_new.range.level[0].cat, |
| 2750 | ctx_new.range.level[1].cat.node = | 2751 | sizeof(ctx_new.range.level[0].cat)); |
| 2751 | ctx_new.range.level[0].cat.node; | ||
| 2752 | } else { | ||
| 2753 | ebitmap_init(&ctx_new.range.level[0].cat); | ||
| 2754 | ebitmap_init(&ctx_new.range.level[1].cat); | ||
| 2755 | } | 2752 | } |
| 2756 | if (mls_context_isvalid(&policydb, &ctx_new) != 1) | 2753 | if (mls_context_isvalid(&policydb, &ctx_new) != 1) |
| 2757 | goto netlbl_secattr_to_sid_return_cleanup; | 2754 | goto netlbl_secattr_to_sid_return_cleanup; |
