diff options
Diffstat (limited to 'security/apparmor/label.c')
-rw-r--r-- | security/apparmor/label.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/security/apparmor/label.c b/security/apparmor/label.c index e052eaba1cf6..c5b99b954580 100644 --- a/security/apparmor/label.c +++ b/security/apparmor/label.c | |||
@@ -49,7 +49,7 @@ static void free_proxy(struct aa_proxy *proxy) | |||
49 | /* p->label will not updated any more as p is dead */ | 49 | /* p->label will not updated any more as p is dead */ |
50 | aa_put_label(rcu_dereference_protected(proxy->label, true)); | 50 | aa_put_label(rcu_dereference_protected(proxy->label, true)); |
51 | memset(proxy, 0, sizeof(*proxy)); | 51 | memset(proxy, 0, sizeof(*proxy)); |
52 | proxy->label = (struct aa_label *) PROXY_POISON; | 52 | RCU_INIT_POINTER(proxy->label, (struct aa_label *)PROXY_POISON); |
53 | kfree(proxy); | 53 | kfree(proxy); |
54 | } | 54 | } |
55 | } | 55 | } |
@@ -1450,9 +1450,11 @@ bool aa_update_label_name(struct aa_ns *ns, struct aa_label *label, gfp_t gfp) | |||
1450 | * cached label name is present and visible | 1450 | * cached label name is present and visible |
1451 | * @label->hname only exists if label is namespace hierachical | 1451 | * @label->hname only exists if label is namespace hierachical |
1452 | */ | 1452 | */ |
1453 | static inline bool use_label_hname(struct aa_ns *ns, struct aa_label *label) | 1453 | static inline bool use_label_hname(struct aa_ns *ns, struct aa_label *label, |
1454 | int flags) | ||
1454 | { | 1455 | { |
1455 | if (label->hname && labels_ns(label) == ns) | 1456 | if (label->hname && (!ns || labels_ns(label) == ns) && |
1457 | !(flags & ~FLAG_SHOW_MODE)) | ||
1456 | return true; | 1458 | return true; |
1457 | 1459 | ||
1458 | return false; | 1460 | return false; |
@@ -1495,7 +1497,7 @@ static int aa_profile_snxprint(char *str, size_t size, struct aa_ns *view, | |||
1495 | view = profiles_ns(profile); | 1497 | view = profiles_ns(profile); |
1496 | 1498 | ||
1497 | if (view != profile->ns && | 1499 | if (view != profile->ns && |
1498 | (!prev_ns || (prev_ns && *prev_ns != profile->ns))) { | 1500 | (!prev_ns || (*prev_ns != profile->ns))) { |
1499 | if (prev_ns) | 1501 | if (prev_ns) |
1500 | *prev_ns = profile->ns; | 1502 | *prev_ns = profile->ns; |
1501 | ns_name = aa_ns_name(view, profile->ns, | 1503 | ns_name = aa_ns_name(view, profile->ns, |
@@ -1605,8 +1607,13 @@ int aa_label_snxprint(char *str, size_t size, struct aa_ns *ns, | |||
1605 | AA_BUG(!str && size != 0); | 1607 | AA_BUG(!str && size != 0); |
1606 | AA_BUG(!label); | 1608 | AA_BUG(!label); |
1607 | 1609 | ||
1608 | if (!ns) | 1610 | if (flags & FLAG_ABS_ROOT) { |
1611 | ns = root_ns; | ||
1612 | len = snprintf(str, size, "="); | ||
1613 | update_for_len(total, len, size, str); | ||
1614 | } else if (!ns) { | ||
1609 | ns = labels_ns(label); | 1615 | ns = labels_ns(label); |
1616 | } | ||
1610 | 1617 | ||
1611 | label_for_each(i, label, profile) { | 1618 | label_for_each(i, label, profile) { |
1612 | if (aa_ns_visible(ns, profile->ns, flags & FLAG_VIEW_SUBNS)) { | 1619 | if (aa_ns_visible(ns, profile->ns, flags & FLAG_VIEW_SUBNS)) { |
@@ -1710,10 +1717,8 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns, | |||
1710 | AA_BUG(!ab); | 1717 | AA_BUG(!ab); |
1711 | AA_BUG(!label); | 1718 | AA_BUG(!label); |
1712 | 1719 | ||
1713 | if (!ns) | 1720 | if (!use_label_hname(ns, label, flags) || |
1714 | ns = labels_ns(label); | 1721 | display_mode(ns, label, flags)) { |
1715 | |||
1716 | if (!use_label_hname(ns, label) || display_mode(ns, label, flags)) { | ||
1717 | len = aa_label_asxprint(&name, ns, label, flags, gfp); | 1722 | len = aa_label_asxprint(&name, ns, label, flags, gfp); |
1718 | if (len == -1) { | 1723 | if (len == -1) { |
1719 | AA_DEBUG("label print error"); | 1724 | AA_DEBUG("label print error"); |
@@ -1738,10 +1743,7 @@ void aa_label_seq_xprint(struct seq_file *f, struct aa_ns *ns, | |||
1738 | AA_BUG(!f); | 1743 | AA_BUG(!f); |
1739 | AA_BUG(!label); | 1744 | AA_BUG(!label); |
1740 | 1745 | ||
1741 | if (!ns) | 1746 | if (!use_label_hname(ns, label, flags)) { |
1742 | ns = labels_ns(label); | ||
1743 | |||
1744 | if (!use_label_hname(ns, label)) { | ||
1745 | char *str; | 1747 | char *str; |
1746 | int len; | 1748 | int len; |
1747 | 1749 | ||
@@ -1764,10 +1766,7 @@ void aa_label_xprintk(struct aa_ns *ns, struct aa_label *label, int flags, | |||
1764 | { | 1766 | { |
1765 | AA_BUG(!label); | 1767 | AA_BUG(!label); |
1766 | 1768 | ||
1767 | if (!ns) | 1769 | if (!use_label_hname(ns, label, flags)) { |
1768 | ns = labels_ns(label); | ||
1769 | |||
1770 | if (!use_label_hname(ns, label)) { | ||
1771 | char *str; | 1770 | char *str; |
1772 | int len; | 1771 | int len; |
1773 | 1772 | ||
@@ -1874,6 +1873,9 @@ struct aa_label *aa_label_parse(struct aa_label *base, const char *str, | |||
1874 | if (*str == '&') | 1873 | if (*str == '&') |
1875 | str++; | 1874 | str++; |
1876 | } | 1875 | } |
1876 | if (*str == '=') | ||
1877 | base = &root_ns->unconfined->label; | ||
1878 | |||
1877 | error = vec_setup(profile, vec, len, gfp); | 1879 | error = vec_setup(profile, vec, len, gfp); |
1878 | if (error) | 1880 | if (error) |
1879 | return ERR_PTR(error); | 1881 | return ERR_PTR(error); |