summaryrefslogtreecommitdiff
path: root/security/apparmor
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2019-01-24 13:53:05 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-03-13 14:02:32 -0700
commitd7807b62276efdb49d9ade2af39fcc409c568f7b (patch)
tree7c92fc419f51eb7f2e9a0b34e4760b8faaf96152 /security/apparmor
parentd92d3caf818dd9b78bdbef179d68647305a01678 (diff)
apparmor: Fix aa_label_build() error handling for failed merges
[ Upstream commit d6d478aee003e19ef90321176552a8ad2929a47f ] 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 <peng.hao2@zte.com.cn> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'security/apparmor')
-rw-r--r--security/apparmor/domain.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
index 08c88de0ffda..11975ec8d566 100644
--- a/security/apparmor/domain.c
+++ b/security/apparmor/domain.c
@@ -1444,7 +1444,10 @@ check:
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;