diff options
| author | John Johansen <john.johansen@canonical.com> | 2017-01-16 03:42:52 -0500 |
|---|---|---|
| committer | John Johansen <john.johansen@canonical.com> | 2017-01-16 04:18:40 -0500 |
| commit | 078c73c63fb2878689da334f112507639c72c14f (patch) | |
| tree | a1e4ea3567f70f0863b35faac815e2658af8473e /security/apparmor | |
| parent | fd2a80438d736012129977bec779db093979057e (diff) | |
apparmor: add profile and ns params to aa_may_manage_policy()
Policy management will be expanded beyond traditional unconfined root.
This will require knowning the profile of the task doing the management
and the ns view.
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security/apparmor')
| -rw-r--r-- | security/apparmor/apparmorfs.c | 2 | ||||
| -rw-r--r-- | security/apparmor/include/policy.h | 2 | ||||
| -rw-r--r-- | security/apparmor/policy.c | 22 |
3 files changed, 12 insertions, 14 deletions
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 9fd7f73a4e86..cc6ee1ee2b42 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c | |||
| @@ -100,7 +100,7 @@ static char *aa_simple_write_to_buffer(int op, const char __user *userbuf, | |||
| 100 | * Don't allow profile load/replace/remove from profiles that don't | 100 | * Don't allow profile load/replace/remove from profiles that don't |
| 101 | * have CAP_MAC_ADMIN | 101 | * have CAP_MAC_ADMIN |
| 102 | */ | 102 | */ |
| 103 | if (!aa_may_manage_policy(op)) | 103 | if (!aa_may_manage_policy(__aa_current_profile(), NULL, op)) |
| 104 | return ERR_PTR(-EACCES); | 104 | return ERR_PTR(-EACCES); |
| 105 | 105 | ||
| 106 | /* freed by caller to simple_write_to_buffer */ | 106 | /* freed by caller to simple_write_to_buffer */ |
diff --git a/security/apparmor/include/policy.h b/security/apparmor/include/policy.h index 27f9171fa31f..95641e235d47 100644 --- a/security/apparmor/include/policy.h +++ b/security/apparmor/include/policy.h | |||
| @@ -301,6 +301,6 @@ static inline int AUDIT_MODE(struct aa_profile *profile) | |||
| 301 | 301 | ||
| 302 | bool policy_view_capable(struct aa_ns *ns); | 302 | bool policy_view_capable(struct aa_ns *ns); |
| 303 | bool policy_admin_capable(struct aa_ns *ns); | 303 | bool policy_admin_capable(struct aa_ns *ns); |
| 304 | bool aa_may_manage_policy(int op); | 304 | int aa_may_manage_policy(struct aa_profile *profile, struct aa_ns *ns, int op); |
| 305 | 305 | ||
| 306 | #endif /* __AA_POLICY_H */ | 306 | #endif /* __AA_POLICY_H */ |
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c index ef64c25b2a45..27d93aa58016 100644 --- a/security/apparmor/policy.c +++ b/security/apparmor/policy.c | |||
| @@ -650,26 +650,24 @@ bool policy_admin_capable(struct aa_ns *ns) | |||
| 650 | 650 | ||
| 651 | /** | 651 | /** |
| 652 | * aa_may_manage_policy - can the current task manage policy | 652 | * aa_may_manage_policy - can the current task manage policy |
| 653 | * @profile: profile to check if it can manage policy | ||
| 653 | * @op: the policy manipulation operation being done | 654 | * @op: the policy manipulation operation being done |
| 654 | * | 655 | * |
| 655 | * Returns: true if the task is allowed to manipulate policy | 656 | * Returns: 0 if the task is allowed to manipulate policy else error |
| 656 | */ | 657 | */ |
| 657 | bool aa_may_manage_policy(int op) | 658 | int aa_may_manage_policy(struct aa_profile *profile, struct aa_ns *ns, int op) |
| 658 | { | 659 | { |
| 659 | /* check if loading policy is locked out */ | 660 | /* check if loading policy is locked out */ |
| 660 | if (aa_g_lock_policy) { | 661 | if (aa_g_lock_policy) |
| 661 | audit_policy(__aa_current_profile(), op, GFP_KERNEL, NULL, | 662 | return audit_policy(profile, op, GFP_KERNEL, NULL, |
| 662 | "policy_locked", -EACCES); | 663 | "policy_locked", -EACCES); |
| 663 | return 0; | ||
| 664 | } | ||
| 665 | 664 | ||
| 666 | if (!policy_admin_capable(NULL)) { | 665 | if (!policy_admin_capable(ns)) |
| 667 | audit_policy(__aa_current_profile(), op, GFP_KERNEL, NULL, | 666 | return audit_policy(profile, op, GFP_KERNEL, NULL, |
| 668 | "not policy admin", -EACCES); | 667 | "not policy admin", -EACCES); |
| 669 | return 0; | ||
| 670 | } | ||
| 671 | 668 | ||
| 672 | return 1; | 669 | /* TODO: add fine grained mediation of policy loads */ |
| 670 | return 0; | ||
| 673 | } | 671 | } |
| 674 | 672 | ||
| 675 | static struct aa_profile *__list_lookup_parent(struct list_head *lh, | 673 | static struct aa_profile *__list_lookup_parent(struct list_head *lh, |
