]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
apparmor: fix setting unconfined mode on a loaded profile
authorJohn Johansen <john.johansen@canonical.com>
Sat, 26 Mar 2022 08:52:06 +0000 (01:52 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Tue, 19 Jul 2022 09:43:12 +0000 (02:43 -0700)
When loading a profile that is set to unconfined mode, that label
flag is not set when it should be. Ensure it is set so that when
used in a label the unconfined check will be applied correctly.

Fixes: 038165070aa5 ("apparmor: allow setting any profile into the unconfined state")
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy_unpack.c

index df4033db0e0f4607a50a951d942532a626b1a3e8..302fecf9b197a42422f64175c2e20797db28242b 100644 (file)
@@ -750,16 +750,18 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name)
                profile->label.flags |= FLAG_HAT;
        if (!unpack_u32(e, &tmp, NULL))
                goto fail;
-       if (tmp == PACKED_MODE_COMPLAIN || (e->version & FORCE_COMPLAIN_FLAG))
+       if (tmp == PACKED_MODE_COMPLAIN || (e->version & FORCE_COMPLAIN_FLAG)) {
                profile->mode = APPARMOR_COMPLAIN;
-       else if (tmp == PACKED_MODE_ENFORCE)
+       } else if (tmp == PACKED_MODE_ENFORCE) {
                profile->mode = APPARMOR_ENFORCE;
-       else if (tmp == PACKED_MODE_KILL)
+       } else if (tmp == PACKED_MODE_KILL) {
                profile->mode = APPARMOR_KILL;
-       else if (tmp == PACKED_MODE_UNCONFINED)
+       } else if (tmp == PACKED_MODE_UNCONFINED) {
                profile->mode = APPARMOR_UNCONFINED;
-       else
+               profile->label.flags |= FLAG_UNCONFINED;
+       } else {
                goto fail;
+       }
        if (!unpack_u32(e, &tmp, NULL))
                goto fail;
        if (tmp)