Commit e06504d6 authored by Jann Horn's avatar Jann Horn Committed by Stefan Bader

apparmor: enforce nullbyte at end of tag string

BugLink: https://bugs.launchpad.net/bugs/1836668

commit 8404d7a6 upstream.

A packed AppArmor policy contains null-terminated tag strings that are read
by unpack_nameX(). However, unpack_nameX() uses string functions on them
without ensuring that they are actually null-terminated, potentially
leading to out-of-bounds accesses.

Make sure that the tag string is null-terminated before passing it to
strcmp().

Cc: stable@vger.kernel.org
Fixes: 736ec752 ("AppArmor: policy routines for loading and unpacking policy")
Signed-off-by: default avatarJann Horn <jannh@google.com>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 33299257
...@@ -203,7 +203,7 @@ static bool unpack_nameX(struct aa_ext *e, enum aa_code code, const char *name) ...@@ -203,7 +203,7 @@ static bool unpack_nameX(struct aa_ext *e, enum aa_code code, const char *name)
char *tag = NULL; char *tag = NULL;
size_t size = unpack_u16_chunk(e, &tag); size_t size = unpack_u16_chunk(e, &tag);
/* if a name is specified it must match. otherwise skip tag */ /* if a name is specified it must match. otherwise skip tag */
if (name && (!size || strcmp(name, tag))) if (name && (!size || tag[size-1] != '\0' || strcmp(name, tag)))
goto fail; goto fail;
} else if (name) { } else if (name) {
/* if a name is specified and there is no name tag fail */ /* if a name is specified and there is no name tag fail */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment