[PATCH 2/4] apparmor: make the feature tables build without kernel headers
Maxime Bélair
maxime.belair at canonical.com
Tue Nov 17 13:50:08 UTC 2026
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 at 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
More information about the Linux-security-module-archive
mailing list