From: Cong Nguyen <congnt264@gmail.com>
To: John Johansen <john.johansen@canonical.com>,
Georgia Garcia <georgia.garcia@canonical.com>
Cc: Guicai Ma <maguicai@kylinos.cn>,
apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2] apparmor: return 0 from unpack_tag_headers() on success
Date: Thu, 3 Dec 2026 00:47:21 +0700 [thread overview]
Message-ID: <20261202174721.3676225-1-congnt264@gmail.com> (raw)
unpack_tag_headers() returns int, where 0 means success and a negative
errno means failure, like unpack_strs_table() and unpack_tagsets() which
unpack_tags() calls next to it. On success it returns true, which is 1.
unpack_tags() tests the result with "if (error)", so a successfully
unpacked "hdrs" array is treated as a failure: unpack_tags() destroys the
tags, rewinds e->pos and returns 1. Its caller, unpack_pdb(), only checks
for "< 0", so it carries on with the tags section unconsumed and the
profile then fails to unpack with -EPROTO.
Return 0 on success.
Cc: stable@vger.kernel.org
Fixes: 3d28e2397af7 ("apparmor: add support loading per permission tagging")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
Reviewed-by: Guicai Ma <maguicai@kylinos.cn>
Tested-by: Guicai Ma <maguicai@kylinos.cn>
---
Changes in v2:
- Add Cc: stable and Guicai Ma Reviewed-by and Tested-by tags.
- Say that the profile fails to unpack with -EPROTO instead of continuing without tags (Guicai Ma).
security/apparmor/policy_unpack.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
index 24fbce2e4322..b6864757e6dd 100644
--- a/security/apparmor/policy_unpack.c
+++ b/security/apparmor/policy_unpack.c
@@ -841,7 +841,7 @@ static int unpack_tag_headers(struct aa_ext *e, struct aa_tags_struct *tags)
tags->hdrs.size = size;
tags->hdrs.table = hdrs;
AA_DEBUG(DEBUG_UNPACK, "headers %ld size %d", (long) hdrs, size);
- return true;
+ return 0;
fail:
kfree_sensitive(hdrs);
--
2.25.1
next reply other threads:[~2026-12-02 17:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 17:47 Cong Nguyen [this message]
2026-12-02 17:50 ` [PATCH v2] apparmor: return 0 from unpack_tag_headers() on success sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202174721.3676225-1-congnt264@gmail.com \
--to=congnt264@gmail.com \
--cc=apparmor@lists.ubuntu.com \
--cc=georgia.garcia@canonical.com \
--cc=john.johansen@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=maguicai@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox