Skip to content
/ linux Public

Commit aebd195

Browse files
jrjohansengregkh
authored andcommitted
apparmor: fix aa_label to return state from compount and component match
[ Upstream commit 9058798 ] aa-label_match is not correctly returning the state in all cases. The only reason this didn't cause a error is that all callers currently ignore the return value. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202602020631.wXgZosyU-lkp@intel.com/ Fixes: a4c9efa ("apparmor: make label_match return a consistent value") Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1d2b2b5 commit aebd195

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

security/apparmor/label.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ static int label_compound_match(struct aa_profile *profile,
13341334
* @request: permissions to request
13351335
* @perms: an initialized perms struct to add accumulation to
13361336
*
1337-
* Returns: 0 on success else ERROR
1337+
* Returns: the state the match finished in, may be the none matching state
13381338
*
13391339
* For the label A//&B//&C this does the perm match for each of A and B and C
13401340
* @perms should be preinitialized with allperms OR a previous permission
@@ -1362,7 +1362,7 @@ static int label_components_match(struct aa_profile *profile,
13621362
}
13631363

13641364
/* no subcomponents visible - no change in perms */
1365-
return 0;
1365+
return state;
13661366

13671367
next:
13681368
tmp = *aa_lookup_perms(rules->policy, state);
@@ -1378,13 +1378,13 @@ static int label_components_match(struct aa_profile *profile,
13781378
}
13791379

13801380
if ((perms->allow & request) != request)
1381-
return -EACCES;
1381+
return DFA_NOMATCH;
13821382

1383-
return 0;
1383+
return state;
13841384

13851385
fail:
13861386
*perms = nullperms;
1387-
return -EACCES;
1387+
return DFA_NOMATCH;
13881388
}
13891389

13901390
/**
@@ -1406,7 +1406,7 @@ int aa_label_match(struct aa_profile *profile, struct aa_ruleset *rules,
14061406
aa_state_t tmp = label_compound_match(profile, rules, label, state, subns,
14071407
request, perms);
14081408
if ((perms->allow & request) == request)
1409-
return 0;
1409+
return tmp;
14101410

14111411
/* failed compound_match try component matches */
14121412
*perms = allperms;

0 commit comments

Comments
 (0)