Smack: use init_task_smack() in smack_cred_transfer()
authorCasey Schaufler <casey@schaufler-ca.com>
Wed, 14 Feb 2024 18:47:06 +0000 (10:47 -0800)
committerCasey Schaufler <casey@schaufler-ca.com>
Wed, 14 Feb 2024 18:47:06 +0000 (10:47 -0800)
smack_cred_transfer() open codes the same initialization
as init_task_smack(). Remove the open coding and replace it
with a call to init_task_smack().

Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
security/smack/smack_lsm.c

index d52d2a7a813d767a7d22fa5186bdcd42e6a4f673..b18b5023294797592023078018db027d7b300da2 100644 (file)
@@ -2101,12 +2101,7 @@ static void smack_cred_transfer(struct cred *new, const struct cred *old)
        struct task_smack *old_tsp = smack_cred(old);
        struct task_smack *new_tsp = smack_cred(new);
 
-       new_tsp->smk_task = old_tsp->smk_task;
-       new_tsp->smk_forked = old_tsp->smk_task;
-       mutex_init(&new_tsp->smk_rules_lock);
-       INIT_LIST_HEAD(&new_tsp->smk_rules);
-
-       /* cbs copy rule list */
+       init_task_smack(new_tsp, old_tsp->smk_task, old_tsp->smk_task);
 }
 
 /**