Skip to content

Commit ccbb6e1

Browse files
committed
smack: Refactor to remove bprm_secureexec hook
The Smack bprm_secureexec hook can be merged with the bprm_set_creds hook since it's dealing with the same information, and all of the details are finalized during the first call to the bprm_set_creds hook via prepare_binprm() (subsequent calls due to binfmt_script, etc, are ignored via bprm->called_set_creds). Here, the test can just happen at the end of the bprm_set_creds hook, and the bprm_secureexec hook can be dropped. Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Serge Hallyn <serge@hallyn.com> Reviewed-by: James Morris <james.l.morris@oracle.com> Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
1 parent 62874c3 commit ccbb6e1

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

‎security/smack/smack_lsm.c‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,10 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
950950
bsp->smk_task = isp->smk_task;
951951
bprm->per_clear |= PER_CLEAR_ON_SETID;
952952

953+
/* Decide if this is a secure exec. */
954+
if (bsp->smk_task != bsp->smk_forked)
955+
bprm->secureexec = 1;
956+
953957
return 0;
954958
}
955959

@@ -967,22 +971,6 @@ static void smack_bprm_committing_creds(struct linux_binprm *bprm)
967971
current->pdeath_signal = 0;
968972
}
969973

970-
/**
971-
* smack_bprm_secureexec - Return the decision to use secureexec.
972-
* @bprm: binprm for exec
973-
*
974-
* Returns 0 on success.
975-
*/
976-
static int smack_bprm_secureexec(struct linux_binprm *bprm)
977-
{
978-
struct task_smack *tsp = current_security();
979-
980-
if (tsp->smk_task != tsp->smk_forked)
981-
return 1;
982-
983-
return 0;
984-
}
985-
986974
/*
987975
* Inode hooks
988976
*/
@@ -4646,7 +4634,6 @@ static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {
46464634

46474635
LSM_HOOK_INIT(bprm_set_creds, smack_bprm_set_creds),
46484636
LSM_HOOK_INIT(bprm_committing_creds, smack_bprm_committing_creds),
4649-
LSM_HOOK_INIT(bprm_secureexec, smack_bprm_secureexec),
46504637

46514638
LSM_HOOK_INIT(inode_alloc_security, smack_inode_alloc_security),
46524639
LSM_HOOK_INIT(inode_free_security, smack_inode_free_security),

0 commit comments

Comments
 (0)