summaryrefslogtreecommitdiff
path: root/security/apparmor/include/lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'security/apparmor/include/lib.h')
-rw-r--r--security/apparmor/include/lib.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
index 8c6ce8484552..e3c8cb044a90 100644
--- a/security/apparmor/include/lib.h
+++ b/security/apparmor/include/lib.h
@@ -281,15 +281,15 @@ void aa_policy_destroy(struct aa_policy *policy);
* @FN: fn to call for each profile transition. @P is set to the profile
*
* Returns: new label on success
+ * NULL if all callbacks decline to specify a transition
* ERR_PTR if build @FN fails
- * NULL if label_build fails due to low memory conditions
*
- * @FN must return a label or ERR_PTR on failure. NULL is not allowed
+ * @FN must return a label or ERR_PTR on failure.
*/
#define fn_label_build(L, P, GFP, FN) \
({ \
__label__ __do_cleanup, __done; \
- struct aa_label *__new_; \
+ struct aa_label *__new_ = NULL; \
\
if ((L)->size > 1) { \
/* TODO: add cache of transitions already done */ \
@@ -298,17 +298,21 @@ void aa_policy_destroy(struct aa_policy *policy);
DEFINE_VEC(label, __lvec); \
DEFINE_VEC(profile, __pvec); \
if (vec_setup(label, __lvec, (L)->size, (GFP))) { \
- __new_ = NULL; \
+ __new_ = ERR_PTR(-ENOMEM); \
goto __done; \
} \
__j = 0; \
label_for_each(__i, (L), (P)) { \
__new_ = (FN); \
- AA_BUG(!__new_); \
+ if (!__new_) \
+ continue; \
if (IS_ERR(__new_)) \
goto __do_cleanup; \
__lvec[__j++] = __new_; \
} \
+ if (__j == 0) \
+ /* no components adding to build */ \
+ goto __do_cleanup; \
for (__j = __count = 0; __j < (L)->size; __j++) \
__count += __lvec[__j]->size; \
if (!vec_setup(profile, __pvec, __count, (GFP))) { \
@@ -320,14 +324,13 @@ void aa_policy_destroy(struct aa_policy *policy);
if (__count > 1) { \
__new_ = aa_vec_find_or_create_label(__pvec,\
__count, (GFP)); \
- /* only fails if out of Mem */ \
if (!__new_) \
- __new_ = NULL; \
+ __new_ = ERR_PTR(-ENOMEM); \
} else \
__new_ = aa_get_label(&__pvec[0]->label); \
vec_cleanup(profile, __pvec, __count); \
} else \
- __new_ = NULL; \
+ __new_ = ERR_PTR(-ENOMEM); \
__do_cleanup: \
vec_cleanup(label, __lvec, (L)->size); \
} else { \
@@ -335,7 +338,7 @@ __do_cleanup: \
__new_ = (FN); \
} \
__done: \
- if (!__new_) \
+ if (PTR_ERR(__new_)) \
AA_DEBUG(DEBUG_LABEL, "label build failed\n"); \
(__new_); \
})