]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.29/apparmor-fix-aa_label_build-error-handling-for-faile.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.19.29 / apparmor-fix-aa_label_build-error-handling-for-faile.patch
1 From e86f350e2f3ce09bf77655d83f9231a48be93068 Mon Sep 17 00:00:00 2001
2 From: John Johansen <john.johansen@canonical.com>
3 Date: Thu, 24 Jan 2019 13:53:05 -0800
4 Subject: apparmor: Fix aa_label_build() error handling for failed merges
5
6 [ Upstream commit d6d478aee003e19ef90321176552a8ad2929a47f ]
7
8 aa_label_merge() can return NULL for memory allocations failures
9 make sure to handle and set the correct error in this case.
10
11 Reported-by: Peng Hao <peng.hao2@zte.com.cn>
12 Signed-off-by: John Johansen <john.johansen@canonical.com>
13 Signed-off-by: Sasha Levin <sashal@kernel.org>
14 ---
15 security/apparmor/domain.c | 5 ++++-
16 1 file changed, 4 insertions(+), 1 deletion(-)
17
18 diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
19 index 08c88de0ffda..11975ec8d566 100644
20 --- a/security/apparmor/domain.c
21 +++ b/security/apparmor/domain.c
22 @@ -1444,7 +1444,10 @@ int aa_change_profile(const char *fqname, int flags)
23 new = aa_label_merge(label, target, GFP_KERNEL);
24 if (IS_ERR_OR_NULL(new)) {
25 info = "failed to build target label";
26 - error = PTR_ERR(new);
27 + if (!new)
28 + error = -ENOMEM;
29 + else
30 + error = PTR_ERR(new);
31 new = NULL;
32 perms.allow = 0;
33 goto audit;
34 --
35 2.19.1
36