]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
apparmor: provide separate audit messages for file and policy checks
authorJohn Johansen <john.johansen@canonical.com>
Mon, 17 Apr 2023 10:27:36 +0000 (03:27 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Wed, 18 Oct 2023 22:30:43 +0000 (15:30 -0700)
Improve policy load failure messages by identifying which dfa the
verification check failed in.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy_unpack.c

index cb8b5c497812104f1b20c07f8d509fced8a6791d..1eb98d6994e85db7395bfd573edaa80983e8fc1f 100644 (file)
@@ -1240,12 +1240,18 @@ static int verify_profile(struct aa_profile *profile)
        if (!rules)
                return 0;
 
-       if ((rules->file.dfa && !verify_dfa_accept_index(rules->file.dfa,
-                                                        rules->file.size)) ||
-           (rules->policy.dfa &&
-            !verify_dfa_accept_index(rules->policy.dfa, rules->policy.size))) {
+       if (rules->file.dfa && !verify_dfa_accept_index(rules->file.dfa,
+                                                       rules->file.size)) {
                audit_iface(profile, NULL, NULL,
-                           "Unpack: Invalid named transition", NULL, -EPROTO);
+                           "Unpack: file Invalid named transition", NULL,
+                           -EPROTO);
+               return -EPROTO;
+       }
+       if (rules->policy.dfa &&
+           !verify_dfa_accept_index(rules->policy.dfa, rules->policy.size)) {
+               audit_iface(profile, NULL, NULL,
+                           "Unpack: policy Invalid named transition", NULL,
+                           -EPROTO);
                return -EPROTO;
        }