[PATCH v2 03/15] lsm: Move the lsm_for_each_hook() macro to security/lsm.h
From: Justin Suess
Date: Mon Aug 31 2026 - 13:54:16 EST
Move the lsm_for_each_hook() iterator from security/security.c to
security/lsm.h, verbatim: a following commit adds a user outside
security.c, the file implementing the LSM policy object kfuncs.
No functional change.
Cc: Paul Moore <paul@xxxxxxxxxxxxxx>
Cc: Casey Schaufler <casey@xxxxxxxxxxxxxxxx>
Signed-off-by: Justin Suess <utilityemal77@xxxxxxxxx>
---
security/lsm.h | 6 ++++++
security/security.c | 5 -----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/security/lsm.h b/security/lsm.h
index 32f808ad4335..264ae63290a8 100644
--- a/security/lsm.h
+++ b/security/lsm.h
@@ -24,6 +24,12 @@ extern bool lsm_debug;
extern unsigned int lsm_active_cnt;
extern const struct lsm_id *lsm_idlist[];
+/* Iterate over the active implementations of a given hook */
+#define lsm_for_each_hook(scall, NAME) \
+ for (scall = static_calls_table.NAME; \
+ scall - static_calls_table.NAME < MAX_LSM_COUNT; scall++) \
+ if (static_key_enabled(&scall->active->key))
+
/* LSM blob configuration */
extern struct lsm_blob_sizes blob_sizes;
diff --git a/security/security.c b/security/security.c
index 71aea8fdf014..0a6fa21cc31b 100644
--- a/security/security.c
+++ b/security/security.c
@@ -495,11 +495,6 @@ OUT: \
RC; \
})
-#define lsm_for_each_hook(scall, NAME) \
- for (scall = static_calls_table.NAME; \
- scall - static_calls_table.NAME < MAX_LSM_COUNT; scall++) \
- if (static_key_enabled(&scall->active->key))
-
/* Security operations */
/**
--
2.55.0