aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2017-03-28 10:08:45 -0400
committerPaul Moore <paul@paul-moore.com>2017-05-23 10:23:02 -0400
commita79be238600d1a0319a77b080b762d03c1d253ca (patch)
treeb5b7126bb73308ddd722f5c094cd6c2215315d2d /security/selinux/hooks.c
parentd68c51e0b377838dd31b37707813bb62089f399c (diff)
selinux: Use task_alloc hook rather than task_create hook
This patch is a preparation for getting rid of task_create hook because task_alloc hook which can do what task_create hook can do was revived. Creating a new thread is unlikely prohibited by security policy, for fork()/execve()/exit() is fundamental of how processes are managed in Unix. If a program is known to create a new thread, it is likely that permission to create a new thread is given to that program. Therefore, a situation where security_task_create() returns an error is likely that the program was exploited and lost control. Even if SELinux failed to check permission to create a thread at security_task_create(), SELinux can later check it at security_task_alloc(). Since the new thread is not yet visible from the rest of the system, nobody can do bad things using the new thread. What we waste will be limited to some initialization steps such as dup_task_struct(), copy_creds() and audit_alloc() in copy_process(). We can tolerate these overhead for unlikely situation. Therefore, this patch changes SELinux to use task_alloc hook rather than task_create hook so that we can remove task_create hook. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e67a526d1f30..735609b19e76 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3710,7 +3710,8 @@ static int selinux_file_open(struct file *file, const struct cred *cred)
3710 3710
3711/* task security operations */ 3711/* task security operations */
3712 3712
3713static int selinux_task_create(unsigned long clone_flags) 3713static int selinux_task_alloc(struct task_struct *task,
3714 unsigned long clone_flags)
3714{ 3715{
3715 u32 sid = current_sid(); 3716 u32 sid = current_sid();
3716 3717
@@ -6213,7 +6214,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
6213 6214
6214 LSM_HOOK_INIT(file_open, selinux_file_open), 6215 LSM_HOOK_INIT(file_open, selinux_file_open),
6215 6216
6216 LSM_HOOK_INIT(task_create, selinux_task_create), 6217 LSM_HOOK_INIT(task_alloc, selinux_task_alloc),
6217 LSM_HOOK_INIT(cred_alloc_blank, selinux_cred_alloc_blank), 6218 LSM_HOOK_INIT(cred_alloc_blank, selinux_cred_alloc_blank),
6218 LSM_HOOK_INIT(cred_free, selinux_cred_free), 6219 LSM_HOOK_INIT(cred_free, selinux_cred_free),
6219 LSM_HOOK_INIT(cred_prepare, selinux_cred_prepare), 6220 LSM_HOOK_INIT(cred_prepare, selinux_cred_prepare),