This MR backports bugfixes from !985 (merged), bringing them from master to apparmor-3.1.
master
apparmor-3.1