diff options
| author | John Johansen <john.johansen@canonical.com> | 2019-01-24 16:53:05 -0500 |
|---|---|---|
| committer | John Johansen <john.johansen@canonical.com> | 2019-02-01 11:01:39 -0500 |
| commit | d6d478aee003e19ef90321176552a8ad2929a47f (patch) | |
| tree | 83b0a5146107db7c386670e32721a5fb9cc15446 | |
| parent | a1a02062ad466052a34a8c4323143ccf9726eb52 (diff) | |
apparmor: Fix aa_label_build() error handling for failed merges
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>
| -rw-r--r-- | security/apparmor/domain.c | 5 |
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: | |||
| 1444 | new = aa_label_merge(label, target, GFP_KERNEL); | 1444 | new = aa_label_merge(label, target, GFP_KERNEL); |
| 1445 | if (IS_ERR_OR_NULL(new)) { | 1445 | if (IS_ERR_OR_NULL(new)) { |
| 1446 | info = "failed to build target label"; | 1446 | info = "failed to build target label"; |
| 1447 | error = PTR_ERR(new); | 1447 | if (!new) |
| 1448 | error = -ENOMEM; | ||
| 1449 | else | ||
| 1450 | error = PTR_ERR(new); | ||
| 1448 | new = NULL; | 1451 | new = NULL; |
| 1449 | perms.allow = 0; | 1452 | perms.allow = 0; |
| 1450 | goto audit; | 1453 | goto audit; |
