Skip to content

Commit

Permalink
apparmor: Fix aa_label_build() error handling for failed merges
Browse files Browse the repository at this point in the history
aa_label_merge() can return NULL for memory allocations failures
make sure to handle and set the correct error in this case.

Reported-by: Peng Hao <[email protected]>
Signed-off-by: John Johansen <[email protected]>
  • Loading branch information
John Johansen committed Feb 1, 2019
1 parent a1a0206 commit d6d478a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion security/apparmor/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,10 @@ int aa_change_profile(const char *fqname, int flags)
new = aa_label_merge(label, target, GFP_KERNEL);
if (IS_ERR_OR_NULL(new)) {
info = "failed to build target label";
error = PTR_ERR(new);
if (!new)
error = -ENOMEM;
else
error = PTR_ERR(new);
new = NULL;
perms.allow = 0;
goto audit;
Expand Down

0 comments on commit d6d478a

Please sign in to comment.