apparmor: fix ptrace label match when matching stacked labels
authorJohn Johansen <john.johansen@canonical.com>
Sat, 9 Dec 2017 01:43:18 +0000 (17:43 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Jan 2018 08:45:27 +0000 (09:45 +0100)
commit233363fd02c5fffdfd0be305b70adbbe661d22cf
treebecac4111f5e08ae6b1c766361bd096b1c6d7ad6
parenta4ae05b7bfcdd72f135099b848e1777e486efb19
apparmor: fix ptrace label match when matching stacked labels

commit 0dda0b3fb255048a221f736c8a2a24c674da8bf3 upstream.

Given a label with a profile stack of
  A//&B or A//&C ...

A ptrace rule should be able to specify a generic trace pattern with
a rule like

  ptrace trace A//&**,

however this is failing because while the correct label match routine
is called, it is being done post label decomposition so it is always
being done against a profile instead of the stacked label.

To fix this refactor the cross check to pass the full peer label in to
the label_match.

Fixes: 290f458a4f16 ("apparmor: allow ptrace checks to be finer grained than just capability")
Reported-by: Matthew Garrett <mjg59@google.com>
Tested-by: Matthew Garrett <mjg59@google.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/apparmor/include/perms.h
security/apparmor/ipc.c