diff options
Diffstat (limited to 'security/selinux')
| -rw-r--r-- | security/selinux/hooks.c | 25 | ||||
| -rw-r--r-- | security/selinux/ss/services.c | 17 |
2 files changed, 25 insertions, 17 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 3ae9bec5a508..03fc6a81ae32 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
| @@ -1738,24 +1738,34 @@ static inline u32 file_to_av(struct file *file) | |||
| 1738 | 1738 | ||
| 1739 | /* Hook functions begin here. */ | 1739 | /* Hook functions begin here. */ |
| 1740 | 1740 | ||
| 1741 | static int selinux_ptrace(struct task_struct *parent, | 1741 | static int selinux_ptrace_may_access(struct task_struct *child, |
| 1742 | struct task_struct *child, | 1742 | unsigned int mode) |
| 1743 | unsigned int mode) | ||
| 1744 | { | 1743 | { |
| 1745 | int rc; | 1744 | int rc; |
| 1746 | 1745 | ||
| 1747 | rc = secondary_ops->ptrace(parent, child, mode); | 1746 | rc = secondary_ops->ptrace_may_access(child, mode); |
| 1748 | if (rc) | 1747 | if (rc) |
| 1749 | return rc; | 1748 | return rc; |
| 1750 | 1749 | ||
| 1751 | if (mode == PTRACE_MODE_READ) { | 1750 | if (mode == PTRACE_MODE_READ) { |
| 1752 | struct task_security_struct *tsec = parent->security; | 1751 | struct task_security_struct *tsec = current->security; |
| 1753 | struct task_security_struct *csec = child->security; | 1752 | struct task_security_struct *csec = child->security; |
| 1754 | return avc_has_perm(tsec->sid, csec->sid, | 1753 | return avc_has_perm(tsec->sid, csec->sid, |
| 1755 | SECCLASS_FILE, FILE__READ, NULL); | 1754 | SECCLASS_FILE, FILE__READ, NULL); |
| 1756 | } | 1755 | } |
| 1757 | 1756 | ||
| 1758 | return task_has_perm(parent, child, PROCESS__PTRACE); | 1757 | return task_has_perm(current, child, PROCESS__PTRACE); |
| 1758 | } | ||
| 1759 | |||
| 1760 | static int selinux_ptrace_traceme(struct task_struct *parent) | ||
| 1761 | { | ||
| 1762 | int rc; | ||
| 1763 | |||
| 1764 | rc = secondary_ops->ptrace_traceme(parent); | ||
| 1765 | if (rc) | ||
| 1766 | return rc; | ||
| 1767 | |||
| 1768 | return task_has_perm(parent, current, PROCESS__PTRACE); | ||
| 1759 | } | 1769 | } |
| 1760 | 1770 | ||
| 1761 | static int selinux_capget(struct task_struct *target, kernel_cap_t *effective, | 1771 | static int selinux_capget(struct task_struct *target, kernel_cap_t *effective, |
| @@ -5346,7 +5356,8 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer) | |||
| 5346 | static struct security_operations selinux_ops = { | 5356 | static struct security_operations selinux_ops = { |
| 5347 | .name = "selinux", | 5357 | .name = "selinux", |
| 5348 | 5358 | ||
| 5349 | .ptrace = selinux_ptrace, | 5359 | .ptrace_may_access = selinux_ptrace_may_access, |
| 5360 | .ptrace_traceme = selinux_ptrace_traceme, | ||
| 5350 | .capget = selinux_capget, | 5361 | .capget = selinux_capget, |
| 5351 | .capset_check = selinux_capset_check, | 5362 | .capset_check = selinux_capset_check, |
| 5352 | .capset_set = selinux_capset_set, | 5363 | .capset_set = selinux_capset_set, |
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; |
