From: Qihang <q.h.hack.winter@gmail.com>
To: john.johansen@canonical.com, georgia.garcia@canonical.com
Cc: security@kernel.org, Qihang <q.h.hack.winter@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] apparmor: bounds-check the OWNER companion perms entry at load time
Date: Thu, 3 Sep 2026 00:18:40 +0800 [thread overview]
Message-ID: <20260902161840.75210-1-q.h.hack.winter@gmail.com> (raw)
In-Reply-To: <CAH78Gvtz15Q1icWZFpB68CY3xhdyddw41XCDR8BRS9zwA8EyWw@mail.gmail.com>
For OWNER-flagged DFA states, aa_lookup_condperms() may access
perms[index + 1] for non-owner lookups. verify_dfa_accept_index()
only checks that index is within the perms table, allowing the
companion entry to be read past the end.
Reject OWNER states whose companion perms entry is out of bounds.
Fixes: 6f442d42c0d89 ("apparmor: fix profile verification and enable it")
Cc: stable@vger.kernel.org
Signed-off-by: Qihang <q.h.hack.winter@gmail.com>
---
security/apparmor/policy_unpack.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
index d9dcff167c480..e53f92b34725f 100644
--- a/security/apparmor/policy_unpack.c
+++ b/security/apparmor/policy_unpack.c
@@ -1485,8 +1485,24 @@ static int verify_header(struct aa_ext *e, int required, const char **ns)
static bool verify_dfa_accept_index(struct aa_dfa *dfa, int table_size)
{
int i;
+
+ /* the OWNER companion entry needs one extra table slot */
+ if (table_size <= 0)
+ return false;
+
for (i = 0; i < dfa->tables[YYTD_ID_ACCEPT]->td_lolen; i++) {
- if (ACCEPT_TABLE(dfa)[i] >= table_size)
+ int limit = table_size;
+
+ /*
+ * OWNER-flagged states are indexed as perms pairs:
+ * aa_lookup_condperms() returns &perms[index + 1]
+ * for non-owner lookups, so the companion entry must
+ * stay in bounds too.
+ */
+ if (dfa->tables[YYTD_ID_ACCEPT2] &&
+ (ACCEPT_TABLE2(dfa)[i] & ACCEPT_FLAG_OWNER))
+ limit--;
+ if (ACCEPT_TABLE(dfa)[i] >= limit)
return false;
}
return true;
--
2.50.1 (Apple Git-155)
next parent reply other threads:[~2026-09-02 16:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAH78Gvtz15Q1icWZFpB68CY3xhdyddw41XCDR8BRS9zwA8EyWw@mail.gmail.com>
2026-09-02 16:18 ` Qihang [this message]
2026-11-03 17:28 ` [PATCH] apparmor: bounds-check the OWNER companion perms entry at load time Qihang
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=20260902161840.75210-1-q.h.hack.winter@gmail.com \
--to=q.h.hack.winter@gmail.com \
--cc=georgia.garcia@canonical.com \
--cc=john.johansen@canonical.com \
--cc=security@kernel.org \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.