From 07aee062c6ecaa7199be583c83a1c74ae9885f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20B=C3=A9lair?= Date: Wed, 19 Aug 2026 10:00:19 +0100 Subject: [PATCH] apparmor: report a label allocation failure as -ENOMEM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aa_label_strn_parse() returns -ENOENT for every failure, so a caller cannot tell "no such profile" from "could not allocate a label". Report an allocation failure as -ENOMEM. Fixes: f1bd904175e8 ("apparmor: add the base fns() for domain labels") Signed-off-by: Maxime Bélair Signed-off-by: John Johansen --- security/apparmor/label.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/security/apparmor/label.c b/security/apparmor/label.c index 42ed476fe89d..fd67262330f9 100644 --- a/security/apparmor/label.c +++ b/security/apparmor/label.c @@ -1954,12 +1954,18 @@ struct aa_label *aa_label_strn_parse(struct aa_label *base, const char *str, goto out; } - if (create) + if (create) { label = aa_vec_find_or_create_label(vec, len, gfp); - else + if (!label) { + /* not absence: creating only fails on allocation */ + label = ERR_PTR(-ENOMEM); + goto out; + } + } else { label = vec_find(vec, len); - if (!label) - goto fail; + if (!label) + goto fail; + } out: /* use adjusted len from after vec_unique, not original */