diff options
| author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2017-03-24 07:46:33 -0400 |
|---|---|---|
| committer | James Morris <james.l.morris@oracle.com> | 2017-03-27 20:05:14 -0400 |
| commit | e4e55b47ed9ae2c05ff062601ff6dacbe9dc4775 (patch) | |
| tree | 24a332cc81000bf9bbd1e4db4dc17d16f29e1da8 /kernel/fork.c | |
| parent | 840c91dc6a13b160f5b6e5c79c430dffac11c945 (diff) | |
LSM: Revive security_task_alloc() hook and per "struct task_struct" security blob.
We switched from "struct task_struct"->security to "struct cred"->security
in Linux 2.6.29. But not all LSM modules were happy with that change.
TOMOYO LSM module is an example which want to use per "struct task_struct"
security blob, for TOMOYO's security context is defined based on "struct
task_struct" rather than "struct cred". AppArmor LSM module is another
example which want to use it, for AppArmor is currently abusing the cred
a little bit to store the change_hat and setexeccon info. Although
security_task_free() hook was revived in Linux 3.4 because Yama LSM module
wanted to release per "struct task_struct" security blob,
security_task_alloc() hook and "struct task_struct"->security field were
not revived. Nowadays, we are getting proposals of lightweight LSM modules
which want to use per "struct task_struct" security blob.
We are already allowing multiple concurrent LSM modules (up to one fully
armored module which uses "struct cred"->security field or exclusive hooks
like security_xfrm_state_pol_flow_match(), plus unlimited number of
lightweight modules which do not use "struct cred"->security nor exclusive
hooks) as long as they are built into the kernel. But this patch does not
implement variable length "struct task_struct"->security field which will
become needed when multiple LSM modules want to use "struct task_struct"->
security field. Although it won't be difficult to implement variable length
"struct task_struct"->security field, let's think about it after we merged
this patch.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Tested-by: Djalal Harouni <tixxdz@gmail.com>
Acked-by: José Bollo <jobol@nonadev.net>
Cc: Paul Moore <paul@paul-moore.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Eric Paris <eparis@parisplace.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: James Morris <james.l.morris@oracle.com>
Cc: José Bollo <jobol@nonadev.net>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Diffstat (limited to 'kernel/fork.c')
| -rw-r--r-- | kernel/fork.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 6c463c80e93d..3d32513d6c73 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -1679,9 +1679,12 @@ static __latent_entropy struct task_struct *copy_process( | |||
| 1679 | goto bad_fork_cleanup_perf; | 1679 | goto bad_fork_cleanup_perf; |
| 1680 | /* copy all the process information */ | 1680 | /* copy all the process information */ |
| 1681 | shm_init_task(p); | 1681 | shm_init_task(p); |
| 1682 | retval = copy_semundo(clone_flags, p); | 1682 | retval = security_task_alloc(p, clone_flags); |
| 1683 | if (retval) | 1683 | if (retval) |
| 1684 | goto bad_fork_cleanup_audit; | 1684 | goto bad_fork_cleanup_audit; |
| 1685 | retval = copy_semundo(clone_flags, p); | ||
| 1686 | if (retval) | ||
| 1687 | goto bad_fork_cleanup_security; | ||
| 1685 | retval = copy_files(clone_flags, p); | 1688 | retval = copy_files(clone_flags, p); |
| 1686 | if (retval) | 1689 | if (retval) |
| 1687 | goto bad_fork_cleanup_semundo; | 1690 | goto bad_fork_cleanup_semundo; |
| @@ -1903,6 +1906,8 @@ bad_fork_cleanup_files: | |||
| 1903 | exit_files(p); /* blocking */ | 1906 | exit_files(p); /* blocking */ |
| 1904 | bad_fork_cleanup_semundo: | 1907 | bad_fork_cleanup_semundo: |
| 1905 | exit_sem(p); | 1908 | exit_sem(p); |
| 1909 | bad_fork_cleanup_security: | ||
| 1910 | security_task_free(p); | ||
| 1906 | bad_fork_cleanup_audit: | 1911 | bad_fork_cleanup_audit: |
| 1907 | audit_free(p); | 1912 | audit_free(p); |
| 1908 | bad_fork_cleanup_perf: | 1913 | bad_fork_cleanup_perf: |
