diff options
| author | Paul Moore <paul@paul-moore.com> | 2025-02-12 02:24:04 +0300 |
|---|---|---|
| committer | Paul Moore <paul@paul-moore.com> | 2025-10-23 02:24:22 +0300 |
| commit | 27be5600fe852c52d5b70f4ac9406879b39c864e (patch) | |
| tree | 6c00aa59301798a0550dffc9d676edb658b2a9f3 | |
| parent | 291271e691740003021cf5b48fa7cf7e3371eaa7 (diff) | |
| download | linux-27be5600fe852c52d5b70f4ac9406879b39c864e.tar.xz | |
lsm: cleanup initialize_lsm() and rename to lsm_init_single()
Rename initialize_lsm() to be more consistent with the rest of the LSM
initialization changes and rework the function itself to better fit
with the "exit on fail" coding pattern.
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: John Johansen <john.johansen@canonical.com>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
| -rw-r--r-- | security/lsm_init.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/security/lsm_init.c b/security/lsm_init.c index 6b1f8f18a43c..eb473f982ddb 100644 --- a/security/lsm_init.c +++ b/security/lsm_init.c @@ -169,6 +169,7 @@ out: lsm_is_enabled(lsm) ? "enabled" : "disabled"); } + /** * lsm_blob_size_update - Update the LSM blob size and offset information * @sz_req: the requested additional blob size @@ -225,16 +226,20 @@ static void __init lsm_prepare(struct lsm_info *lsm) lsm_blob_size_update(&blobs->lbs_bpf_token, &blob_sizes.lbs_bpf_token); } -/* Initialize a given LSM, if it is enabled. */ -static void __init initialize_lsm(struct lsm_info *lsm) +/** + * lsm_init_single - Initialize a given LSM + * @lsm: LSM definition + */ +static void __init lsm_init_single(struct lsm_info *lsm) { - if (lsm_is_enabled(lsm)) { - int ret; + int ret; - init_debug("initializing %s\n", lsm->id->name); - ret = lsm->init(); - WARN(ret, "%s failed to initialize: %d\n", lsm->id->name, ret); - } + if (!lsm_is_enabled(lsm)) + return; + + init_debug("initializing %s\n", lsm->id->name); + ret = lsm->init(); + WARN(ret, "%s failed to initialize: %d\n", lsm->id->name, ret); } /** @@ -379,7 +384,7 @@ static void __init lsm_init_ordered(void) panic("%s: early task alloc failed.\n", __func__); lsm_order_for_each(lsm) { - initialize_lsm(*lsm); + lsm_init_single(*lsm); } } @@ -429,7 +434,7 @@ int __init early_security_init(void) lsm_enabled_set(lsm, true); lsm_order_append(lsm, "early"); lsm_prepare(lsm); - initialize_lsm(lsm); + lsm_init_single(lsm); } return 0; |
