mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
840c91dc6a
commit
e4e55b47ed
6 changed files with 37 additions and 2 deletions
|
@ -533,8 +533,13 @@
|
|||
* manual page for definitions of the @clone_flags.
|
||||
* @clone_flags contains the flags indicating what should be shared.
|
||||
* Return 0 if permission is granted.
|
||||
* @task_alloc:
|
||||
* @task task being allocated.
|
||||
* @clone_flags contains the flags indicating what should be shared.
|
||||
* Handle allocation of task-related resources.
|
||||
* Returns a zero on success, negative values on failure.
|
||||
* @task_free:
|
||||
* @task task being freed
|
||||
* @task task about to be freed.
|
||||
* Handle release of task-related resources. (Note that this can be called
|
||||
* from interrupt context.)
|
||||
* @cred_alloc_blank:
|
||||
|
@ -1482,6 +1487,7 @@ union security_list_options {
|
|||
int (*file_open)(struct file *file, const struct cred *cred);
|
||||
|
||||
int (*task_create)(unsigned long clone_flags);
|
||||
int (*task_alloc)(struct task_struct *task, unsigned long clone_flags);
|
||||
void (*task_free)(struct task_struct *task);
|
||||
int (*cred_alloc_blank)(struct cred *cred, gfp_t gfp);
|
||||
void (*cred_free)(struct cred *cred);
|
||||
|
@ -1748,6 +1754,7 @@ struct security_hook_heads {
|
|||
struct list_head file_receive;
|
||||
struct list_head file_open;
|
||||
struct list_head task_create;
|
||||
struct list_head task_alloc;
|
||||
struct list_head task_free;
|
||||
struct list_head cred_alloc_blank;
|
||||
struct list_head cred_free;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue