Commit 0bac2002 authored by John Johansen's avatar John Johansen

apparmor: fix policy_compat permission remap with extended permissions

If the extended permission table is present we should not be attempting
to do a compat_permission remap as the compat_permissions are not
stored in the dfa accept states.

Fixes: fd1b2b95 ("apparmor: add the ability for policy to specify a permission table")
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Reviewed-by: default avatarJon Tourville <jontourville@me.com>
parent ba808cb5
...@@ -849,12 +849,14 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) ...@@ -849,12 +849,14 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
} }
profile->attach.xmatch_len = tmp; profile->attach.xmatch_len = tmp;
profile->attach.xmatch.start[AA_CLASS_XMATCH] = DFA_START; profile->attach.xmatch.start[AA_CLASS_XMATCH] = DFA_START;
if (!profile->attach.xmatch.perms) {
error = aa_compat_map_xmatch(&profile->attach.xmatch); error = aa_compat_map_xmatch(&profile->attach.xmatch);
if (error) { if (error) {
info = "failed to convert xmatch permission table"; info = "failed to convert xmatch permission table";
goto fail; goto fail;
} }
} }
}
/* disconnected attachment string is optional */ /* disconnected attachment string is optional */
(void) aa_unpack_str(e, &profile->disconnected, "disconnected"); (void) aa_unpack_str(e, &profile->disconnected, "disconnected");
...@@ -972,11 +974,14 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) ...@@ -972,11 +974,14 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
AA_CLASS_FILE); AA_CLASS_FILE);
if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL)) if (!aa_unpack_nameX(e, AA_STRUCTEND, NULL))
goto fail; goto fail;
error = aa_compat_map_policy(&rules->policy, e->version); if (!rules->policy.perms) {
error = aa_compat_map_policy(&rules->policy,
e->version);
if (error) { if (error) {
info = "failed to remap policydb permission table"; info = "failed to remap policydb permission table";
goto fail; goto fail;
} }
}
} else } else
rules->policy.dfa = aa_get_dfa(nulldfa); rules->policy.dfa = aa_get_dfa(nulldfa);
...@@ -985,11 +990,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) ...@@ -985,11 +990,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
if (error) { if (error) {
goto fail; goto fail;
} else if (rules->file.dfa) { } else if (rules->file.dfa) {
if (!rules->file.perms) {
error = aa_compat_map_file(&rules->file); error = aa_compat_map_file(&rules->file);
if (error) { if (error) {
info = "failed to remap file permission table"; info = "failed to remap file permission table";
goto fail; goto fail;
} }
}
} else if (rules->policy.dfa && } else if (rules->policy.dfa &&
rules->policy.start[AA_CLASS_FILE]) { rules->policy.start[AA_CLASS_FILE]) {
rules->file.dfa = aa_get_dfa(rules->policy.dfa); rules->file.dfa = aa_get_dfa(rules->policy.dfa);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment