]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lsm: rework lsm_active_cnt and lsm_idlist[]
authorPaul Moore <paul@paul-moore.com>
Wed, 12 Feb 2025 20:36:51 +0000 (15:36 -0500)
committerPaul Moore <paul@paul-moore.com>
Wed, 22 Oct 2025 23:24:19 +0000 (19:24 -0400)
Move the LSM active count and lsm_id list declarations out of a header
that is visible across the kernel and into a header that is limited to
the LSM framework.  This not only helps keep the include/linux headers
smaller and cleaner, it helps prevent misuse of these variables.

Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: John Johansen <john.johhansen@canonical.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
include/linux/security.h
security/lsm.h
security/lsm_init.c
security/lsm_syscalls.c
security/security.c

index 92ac3f27b9733ac7094d43c43f40e8ab151c4b2c..556890ea2e838475266dbe3cd1d500d76291be30 100644 (file)
@@ -167,8 +167,6 @@ struct lsm_prop {
 };
 
 extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
-extern u32 lsm_active_cnt;
-extern const struct lsm_id *lsm_idlist[];
 
 /* These functions are in security/commoncap.c */
 extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
index 0e1731bad4a7aa15c6ae72b75021bfa2a24209c7..dbe755c45e57f87fefa168d5bc61f7e992c5003b 100644 (file)
@@ -7,6 +7,11 @@
 #define _LSM_H_
 
 #include <linux/lsm_hooks.h>
+#include <linux/lsm_count.h>
+
+/* List of configured LSMs */
+extern unsigned int lsm_active_cnt;
+extern const struct lsm_id *lsm_idlist[];
 
 /* LSM blob configuration */
 extern struct lsm_blob_sizes blob_sizes;
index a0785ca081c79c8bd24b28320b5f97bc0394c926..d40f31e79bd5b9986124d87a4cbde3dfaff31f37 100644 (file)
@@ -217,12 +217,6 @@ static void __init initialize_lsm(struct lsm_info *lsm)
        }
 }
 
-/*
- * Current index to use while initializing the lsm id list.
- */
-u32 lsm_active_cnt __ro_after_init;
-const struct lsm_id *lsm_idlist[MAX_LSM_COUNT];
-
 /* Populate ordered LSMs list from comma-separated LSM name list. */
 static void __init ordered_lsm_parse(const char *order, const char *origin)
 {
index 8440948a690c98e26b16249f25958f27fc23fc3d..5648b1f0ce9c1a12ad18ff6765d2dfca528536eb 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/lsm_hooks.h>
 #include <uapi/linux/lsm.h>
 
+#include "lsm.h"
+
 /**
  * lsm_name_to_attr - map an LSM attribute name to its ID
  * @name: name of the attribute
index dc9734f0d45c55292cc925549a93279a3ebb2ee4..b4eec4f007306bb02eeb2661d63401dc3e59ee13 100644 (file)
@@ -73,6 +73,9 @@ const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX + 1] = {
        [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality",
 };
 
+unsigned int lsm_active_cnt __ro_after_init;
+const struct lsm_id *lsm_idlist[MAX_LSM_COUNT];
+
 struct lsm_blob_sizes blob_sizes;
 
 struct kmem_cache *lsm_file_cache;