Linux Security Modules development
 help / color / mirror / Atom feed
From: "Maxime Bélair" <maxime.belair@canonical.com>
To: John Johansen <john.johansen@canonical.com>,
	Georgia Garcia <georgia.garcia@canonical.com>
Cc: apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
	"Maxime Bélair" <maxime.belair@canonical.com>
Subject: [PATCH 4/4] kbuild: install the AppArmor feature set with the modules
Date: Tue, 17 Nov 2026 14:50:10 +0100	[thread overview]
Message-ID: <20261117135042.78238-5-maxime.belair@canonical.com> (raw)
In-Reply-To: <20261117135042.78238-1-maxime.belair@canonical.com>

A package hook that compiles the policy for a kernel when it is
installed only knows the release of that kernel, so the feature set
has to be in a place that is derived from the release.

Install it as $(MODLIB)/apparmor/features with modules_install

aa-precompile, which is proposed for the apparmor user space tools,
reads the file from /lib/modules/<release>/apparmor/features if it
exists.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
---
 Documentation/admin-guide/LSM/apparmor.rst | 15 +++++++++++++++
 scripts/Makefile.modinst                   |  6 ++++++
 2 files changed, 21 insertions(+)

diff --git a/Documentation/admin-guide/LSM/apparmor.rst b/Documentation/admin-guide/LSM/apparmor.rst
index 47939ee89d74..90e216556198 100644
--- a/Documentation/admin-guide/LSM/apparmor.rst
+++ b/Documentation/admin-guide/LSM/apparmor.rst
@@ -37,6 +37,21 @@ For AppArmor to enforce any restrictions beyond standard Linux DAC permissions
 policy must be loaded into the kernel from user space (see the Documentation
 and tools links).
 
+Feature set
+===========
+
+The kernel lists what it supports in the securityfs directory
+``/sys/kernel/security/apparmor/features``. The user space tools read it when
+they compile policy, and keep the compiled policy of each feature set apart.
+
+The same feature set is written to ``security/apparmor/features`` when the
+kernel is built, in the form that the user space tools flatten the directory
+to, and ``make modules_install`` installs it as
+``/lib/modules/$(KERNELRELEASE)/apparmor/features``. With that file the policy
+can be compiled for a kernel that is not running, e.g. when it is installed::
+
+   apparmor_parser --kernel-features=<file> ...
+
 Documentation
 =============
 
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 9ba45e5b32b1..9df8e5ae014c 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -38,6 +38,12 @@ install-$(CONFIG_BUILTIN_MODULE_RANGES) += $(MODLIB)/modules.builtin.ranges
 $(addprefix $(MODLIB)/, modules.builtin modules.builtin.modinfo modules.builtin.ranges): $(MODLIB)/%: % FORCE
 	$(call cmd,install)
 
+# AppArmor feature set, to compile the policy for this kernel before it boots
+install-$(CONFIG_SECURITY_APPARMOR) += $(MODLIB)/apparmor/features
+
+$(MODLIB)/apparmor/features: security/apparmor/features FORCE
+	$(call cmd,install)
+
 endif
 
 modules := $(call read-file, modules.order)
-- 
2.51.0


  parent reply	other threads:[~2026-11-17 13:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 13:50 [PATCH 0/4] apparmor: provide the kernel feature set at build time Maxime Bélair
2026-11-17 13:50 ` [PATCH 1/4] apparmor: move the feature tables to a header Maxime Bélair
2026-11-17 13:55   ` sashiko-bot
2026-11-17 13:50 ` [PATCH 2/4] apparmor: make the feature tables build without kernel headers Maxime Bélair
2026-11-17 13:55   ` sashiko-bot
2026-11-17 13:50 ` [PATCH 3/4] apparmor: write the feature set to a file at build time Maxime Bélair
2026-11-17 14:00   ` sashiko-bot
2026-11-17 13:50 ` Maxime Bélair [this message]
2026-11-17 13:58   ` [PATCH 4/4] kbuild: install the AppArmor feature set with the modules sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117135042.78238-5-maxime.belair@canonical.com \
    --to=maxime.belair@canonical.com \
    --cc=apparmor@lists.ubuntu.com \
    --cc=georgia.garcia@canonical.com \
    --cc=john.johansen@canonical.com \
    --cc=linux-security-module@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox