]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lsm: integrate lsm_early_cred() and lsm_early_task() into caller
authorPaul Moore <paul@paul-moore.com>
Sat, 12 Jul 2025 20:27:39 +0000 (16:27 -0400)
committerPaul Moore <paul@paul-moore.com>
Wed, 22 Oct 2025 23:24:17 +0000 (19:24 -0400)
With only one caller of lsm_early_cred() and lsm_early_task(), insert
the functions' code directly into the caller and ger rid of the two
functions.

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>
security/lsm_init.c

index 09afa7ad719e62c866fd07522a698bfaaf7e6c81..8bb473aca113671eca259b78d0dad52b3aec5405 100644 (file)
@@ -291,34 +291,6 @@ static void __init ordered_lsm_parse(const char *order, const char *origin)
        kfree(sep);
 }
 
-/**
- * lsm_early_cred - during initialization allocate a composite cred blob
- * @cred: the cred that needs a blob
- *
- * Allocate the cred blob for all the modules
- */
-static void __init lsm_early_cred(struct cred *cred)
-{
-       int rc = lsm_cred_alloc(cred, GFP_KERNEL);
-
-       if (rc)
-               panic("%s: Early cred alloc failed.\n", __func__);
-}
-
-/**
- * lsm_early_task - during initialization allocate a composite task blob
- * @task: the task that needs a blob
- *
- * Allocate the task blob for all the modules
- */
-static void __init lsm_early_task(struct task_struct *task)
-{
-       int rc = lsm_task_alloc(task);
-
-       if (rc)
-               panic("%s: Early task alloc failed.\n", __func__);
-}
-
 static void __init ordered_lsm_init(void)
 {
        unsigned int first = 0;
@@ -382,8 +354,11 @@ static void __init ordered_lsm_init(void)
                                                    blob_sizes.lbs_inode, 0,
                                                    SLAB_PANIC, NULL);
 
-       lsm_early_cred((struct cred *) current->cred);
-       lsm_early_task(current);
+       if (lsm_cred_alloc((struct cred __rcu *)current->cred, GFP_KERNEL))
+               panic("%s: early cred alloc failed.\n", __func__);
+       if (lsm_task_alloc(current))
+               panic("%s: early task alloc failed.\n", __func__);
+
        lsm_order_for_each(lsm) {
                initialize_lsm(*lsm);
        }