Skip to content

Commit 26b7899

Browse files
committed
apparmor: add support for absolute root view based labels
With apparmor policy virtualization based on policy namespace View's we don't generally want/need absolute root based views, however there are cases like debugging and some secid based conversions where using a root based view is important. Signed-off-by: John Johansen <[email protected]> Acked-by: Seth Arnold <[email protected]>
1 parent f872af7 commit 26b7899

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

security/apparmor/include/label.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ bool aa_update_label_name(struct aa_ns *ns, struct aa_label *label, gfp_t gfp);
310310
#define FLAG_SHOW_MODE 1
311311
#define FLAG_VIEW_SUBNS 2
312312
#define FLAG_HIDDEN_UNCONFINED 4
313+
#define FLAG_ABS_ROOT 8
313314
int aa_label_snxprint(char *str, size_t size, struct aa_ns *view,
314315
struct aa_label *label, int flags);
315316
int aa_label_asxprint(char **strp, struct aa_ns *ns, struct aa_label *label,

security/apparmor/label.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,8 +1607,13 @@ int aa_label_snxprint(char *str, size_t size, struct aa_ns *ns,
16071607
AA_BUG(!str && size != 0);
16081608
AA_BUG(!label);
16091609

1610-
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) {
16111615
ns = labels_ns(label);
1616+
}
16121617

16131618
label_for_each(i, label, profile) {
16141619
if (aa_ns_visible(ns, profile->ns, flags & FLAG_VIEW_SUBNS)) {
@@ -1868,6 +1873,9 @@ struct aa_label *aa_label_parse(struct aa_label *base, const char *str,
18681873
if (*str == '&')
18691874
str++;
18701875
}
1876+
if (*str == '=')
1877+
base = &root_ns->unconfined->label;
1878+
18711879
error = vec_setup(profile, vec, len, gfp);
18721880
if (error)
18731881
return ERR_PTR(error);

0 commit comments

Comments
 (0)