OSDN Git Service

apparmor: enforce nullbyte at end of tag string
authorJann Horn <jannh@google.com>
Tue, 28 May 2019 15:32:26 +0000 (17:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Jul 2019 07:55:29 +0000 (09:55 +0200)
commit4a60589dc0ced39f2a511b226bee3a562591beda
tree9a1d0442664c41d49fed0bd073fa99e214ae9659
parent8b034f18a4a3e1324a9fa29e1d791d624f196fb4
apparmor: enforce nullbyte at end of tag string

commit 8404d7a674c49278607d19726e0acc0cae299357 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: 736ec752d95e ("AppArmor: policy routines for loading and unpacking policy")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/apparmor/policy_unpack.c