AppArmor policy is compiled in user space for the feature set of the kernel, and the cache of compiled policy is keyed on that set. The set can only be read from /sys/kernel/security/apparmor/features once the kernel runs, so the first boot into a kernel with a new feature set compiles all of the policy.
Every entry of the feature set is a build-time constant. This series writes the set to a file when the kernel is built and installs it as /lib/modules/<release>/apparmor/features so that user space can compile the policy when the kernel is installed, and the first boot takes it from the cache. Patches 1 and 2 prepare the feature tables to be built into a host program, patch 3 writes the file with that program, and patch 4 installs it with the modules. The file is identical to the output of "aa-features-abi -x" on the booted kernel. Maxime Bélair (4): apparmor: move the feature tables to a header apparmor: make the feature tables build without kernel headers apparmor: write the feature set to a file at build time kbuild: install the AppArmor feature set with the modules Documentation/admin-guide/LSM/apparmor.rst | 15 ++ scripts/Makefile.modinst | 6 + security/apparmor/.gitignore | 3 + security/apparmor/Makefile | 25 ++- security/apparmor/apparmorfs.c | 127 +-------------- security/apparmor/capability.c | 6 - security/apparmor/gen_features.c | 100 ++++++++++++ security/apparmor/include/capability.h | 2 - security/apparmor/include/features.h | 173 +++++++++++++++++++++ security/apparmor/include/net.h | 3 - security/apparmor/include/resource.h | 2 - security/apparmor/include/task.h | 4 - security/apparmor/net.c | 15 -- security/apparmor/resource.c | 5 - 14 files changed, 328 insertions(+), 158 deletions(-) create mode 100644 security/apparmor/gen_features.c create mode 100644 security/apparmor/include/features.h -- 2.51.0
