exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds
[sfrench/cifs-2.6.git] / security / selinux / hooks.c
index 0b4e32161b7775df189e59624dd43923d8df1019..718345dd76bb26ffa6203f2b4bdef3c3ddf02a2b 100644 (file)
@@ -2286,7 +2286,7 @@ static int check_nnp_nosuid(const struct linux_binprm *bprm,
        return -EACCES;
 }
 
-static int selinux_bprm_set_creds(struct linux_binprm *bprm)
+static int selinux_bprm_creds_for_exec(struct linux_binprm *bprm)
 {
        const struct task_security_struct *old_tsec;
        struct task_security_struct *new_tsec;
@@ -2297,8 +2297,6 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
 
        /* SELinux context only depends on initial program or script and not
         * the script interpreter */
-       if (bprm->called_set_creds)
-               return 0;
 
        old_tsec = selinux_cred(current_cred());
        new_tsec = selinux_cred(bprm->cred);
@@ -6385,7 +6383,7 @@ static int selinux_setprocattr(const char *name, void *value, size_t size)
        /* Permission checking based on the specified context is
           performed during the actual operation (execve,
           open/mkdir/...), when we know the full context of the
-          operation.  See selinux_bprm_set_creds for the execve
+          operation.  See selinux_bprm_creds_for_exec for the execve
           checks and may_create for the file creation checks. The
           operation will then fail if the context is not permitted. */
        tsec = selinux_cred(new);
@@ -6914,7 +6912,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
 
        LSM_HOOK_INIT(netlink_send, selinux_netlink_send),
 
-       LSM_HOOK_INIT(bprm_set_creds, selinux_bprm_set_creds),
+       LSM_HOOK_INIT(bprm_creds_for_exec, selinux_bprm_creds_for_exec),
        LSM_HOOK_INIT(bprm_committing_creds, selinux_bprm_committing_creds),
        LSM_HOOK_INIT(bprm_committed_creds, selinux_bprm_committed_creds),