]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
apparmor: add missing failure check in compute_xmatch_perms
authorJohn Johansen <john.johansen@canonical.com>
Fri, 14 Apr 2023 07:24:47 +0000 (00:24 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Thu, 6 Jul 2023 17:58:49 +0000 (10:58 -0700)
Add check for failure to allocate the permission table.

Fixes: caa9f579ca72 ("apparmor: isolate policy backwards compatibility to its own file")
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy_compat.c

index 9e52e218bf308161c7fcc0d190a2bacea7b0e3b0..b2ec7fb04e831bf76fba63648ef1927f7abb80fc 100644 (file)
@@ -180,6 +180,8 @@ static struct aa_perms *compute_xmatch_perms(struct aa_dfa *xmatch)
        state_count = xmatch->tables[YYTD_ID_BASE]->td_lolen;
        /* DFAs are restricted from having a state_count of less than 2 */
        perms = kvcalloc(state_count, sizeof(struct aa_perms), GFP_KERNEL);
+       if (!perms)
+               return NULL;
 
        /* zero init so skip the trap state (state == 0) */
        for (state = 1; state < state_count; state++)