apparmor: allocate xmatch for nullpdb inside aa_alloc_null
authorRyan Lee <ryan.lee@canonical.com>
Wed, 21 Aug 2024 18:01:56 +0000 (11:01 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Wed, 27 Nov 2024 03:21:04 +0000 (19:21 -0800)
attach->xmatch was not set when allocating a null profile, which is used in
complain mode to allocate a learning profile. This was causing downstream
failures in find_attach, which expected a valid xmatch but did not find
one under a certain sequence of profile transitions in complain mode.

This patch ensures the xmatch is set up properly for null profiles.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy.c

index 14df15e..105706a 100644 (file)
@@ -626,6 +626,7 @@ struct aa_profile *aa_alloc_null(struct aa_profile *parent, const char *name,
 
        /* TODO: ideally we should inherit abi from parent */
        profile->label.flags |= FLAG_NULL;
+       profile->attach.xmatch = aa_get_pdb(nullpdb);
        rules = list_first_entry(&profile->rules, typeof(*rules), list);
        rules->file = aa_get_pdb(nullpdb);
        rules->policy = aa_get_pdb(nullpdb);