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 2/4] apparmor: make the feature tables build without kernel headers
Date: Tue, 17 Nov 2026 14:50:08 +0100	[thread overview]
Message-ID: <20261117135042.78238-3-maxime.belair@canonical.com> (raw)
In-Reply-To: <20261117135042.78238-1-maxime.belair@canonical.com>

The feature tables are about to be built into a host program, and a
host program cannot include kernel headers, see commit 541b57e31368
("selinux: do not include <linux/*.h> headers from host programs").

Move AA_SFS_SIG_MASK next to the signal table, and give the tables
copies of MAX_OOB_SUPPORTED and VFS_CAP_FLAGS_MASK, which apparmorfs.c
checks against the originals with static_assert().

The content of the features directory does not change.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
---
 security/apparmor/apparmorfs.c       |  4 ++++
 security/apparmor/include/features.h | 11 +++++++++--
 security/apparmor/include/task.h     |  4 ----
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 9fbe72c4bee7..4ca449b108df 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -2582,6 +2582,10 @@ static const struct file_operations aa_sfs_profiles_fops = {
 #include "feature_masks.h"
 #include "include/features.h"
 
+/* features.h cannot include the headers that define these */
+static_assert(AA_SFS_MAX_OOB_SUPPORTED == MAX_OOB_SUPPORTED);
+static_assert(AA_SFS_VFS_CAP_FLAGS_MASK == VFS_CAP_FLAGS_MASK);
+
 static struct aa_sfs_entry aa_sfs_entry_apparmor[] = {
 	AA_SFS_FILE_FOPS(".access", 0666, &aa_sfs_access),
 	AA_SFS_FILE_FOPS(".stacked", 0444, &seq_ns_stacked_fops),
diff --git a/security/apparmor/include/features.h b/security/apparmor/include/features.h
index 97fb3c6acbd4..dc38f54abec6 100644
--- a/security/apparmor/include/features.h
+++ b/security/apparmor/include/features.h
@@ -13,6 +13,10 @@
 #ifndef __AA_FEATURES_H
 #define __AA_FEATURES_H
 
+/* Copies of kernel header values, apparmorfs.c checks that they match */
+#define AA_SFS_MAX_OOB_SUPPORTED	1
+#define AA_SFS_VFS_CAP_FLAGS_MASK	0x00ffffff
+
 static struct aa_sfs_entry aa_sfs_entry_file[] = {
 	AA_SFS_FILE_STRING("mask",
 			   "create read write exec append mmap_exec link lock"),
@@ -24,6 +28,9 @@ static struct aa_sfs_entry aa_sfs_entry_ptrace[] = {
 	{ }
 };
 
+#define AA_SFS_SIG_MASK "hup int quit ill trap abrt bus fpe kill usr1 " \
+	"segv usr2 pipe alrm term stkflt chld cont stop stp ttin ttou urg " \
+	"xcpu xfsz vtalrm prof winch io pwr sys emt lost"
 static struct aa_sfs_entry aa_sfs_entry_signal[] = {
 	AA_SFS_FILE_STRING("mask", AA_SFS_SIG_MASK),
 	{ }
@@ -71,7 +78,7 @@ static struct aa_sfs_entry aa_sfs_entry_policy[] = {
 	AA_SFS_FILE_BOOLEAN("set_load",		1),
 	AA_SFS_FILE_BOOLEAN("diff-encode",		1),
 	/* number of out of band transitions supported */
-	AA_SFS_FILE_U64("outofband",		MAX_OOB_SUPPORTED),
+	AA_SFS_FILE_U64("outofband",		AA_SFS_MAX_OOB_SUPPORTED),
 	AA_SFS_FILE_U64("permstable32_version",	3),
 	AA_SFS_FILE_STRING("permstable32", PERMS32STR),
 	AA_SFS_FILE_U64("state32",	1),
@@ -151,7 +158,7 @@ static struct aa_sfs_entry aa_sfs_entry_features[] = {
 	AA_SFS_DIR("network_v9",		aa_sfs_entry_networkv9),
 	AA_SFS_DIR("mount",			aa_sfs_entry_mount),
 	AA_SFS_DIR("namespaces",		aa_sfs_entry_ns),
-	AA_SFS_FILE_U64("capability",		VFS_CAP_FLAGS_MASK),
+	AA_SFS_FILE_U64("capability",		AA_SFS_VFS_CAP_FLAGS_MASK),
 	AA_SFS_DIR("rlimit",			aa_sfs_entry_rlimit),
 	AA_SFS_DIR("caps",			aa_sfs_entry_caps),
 	AA_SFS_DIR("ptrace",			aa_sfs_entry_ptrace),
diff --git a/security/apparmor/include/task.h b/security/apparmor/include/task.h
index a8030ed78ff2..0d984724383b 100644
--- a/security/apparmor/include/task.h
+++ b/security/apparmor/include/task.h
@@ -99,10 +99,6 @@ static inline void aa_clear_task_ctx_trans(struct aa_task_ctx *ctx)
 			     AA_MAY_BE_READ | AA_MAY_BE_TRACED)
 #define AA_SIGNAL_PERM_MASK (MAY_READ | MAY_WRITE)
 
-#define AA_SFS_SIG_MASK "hup int quit ill trap abrt bus fpe kill usr1 " \
-	"segv usr2 pipe alrm term stkflt chld cont stop stp ttin ttou urg " \
-	"xcpu xfsz vtalrm prof winch io pwr sys emt lost"
-
 int aa_may_ptrace(const struct cred *tracer_cred, struct aa_label *tracer,
 		  const struct cred *tracee_cred, struct aa_label *tracee,
 		  u32 request);
-- 
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 ` Maxime Bélair [this message]
2026-11-17 13:55   ` [PATCH 2/4] apparmor: make the feature tables build without kernel headers 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 ` [PATCH 4/4] kbuild: install the AppArmor feature set with the modules Maxime Bélair
2026-11-17 13:58   ` 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-3-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