mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
Infrastructure management of the cred security blob
Move management of the cred security blob out of the security modules and into the security infrastructre. Instead of allocating and freeing space the security modules tell the infrastructure how much space they require. Signed-off-by: Casey Schaufler <[email protected]> Reviewed-by: Kees Cook <[email protected]> [kees: adjusted for ordered init series] Signed-off-by: Kees Cook <[email protected]>
This commit is contained in:
parent
43fc460907
commit
bbd3662a83
11 changed files with 162 additions and 102 deletions
|
|
@ -1087,6 +1087,7 @@ extern struct tomoyo_domain_info tomoyo_kernel_domain;
|
|||
extern struct tomoyo_policy_namespace tomoyo_kernel_namespace;
|
||||
extern unsigned int tomoyo_memory_quota[TOMOYO_MAX_MEMORY_STAT];
|
||||
extern unsigned int tomoyo_memory_used[TOMOYO_MAX_MEMORY_STAT];
|
||||
extern struct lsm_blob_sizes tomoyo_blob_sizes;
|
||||
|
||||
/********** Inlined functions. **********/
|
||||
|
||||
|
|
@ -1206,7 +1207,7 @@ static inline void tomoyo_put_group(struct tomoyo_group *group)
|
|||
*/
|
||||
static inline struct tomoyo_domain_info **tomoyo_cred(const struct cred *cred)
|
||||
{
|
||||
return (struct tomoyo_domain_info **)&cred->security;
|
||||
return cred->security + tomoyo_blob_sizes.lbs_cred;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -509,6 +509,10 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
|
|||
return tomoyo_socket_sendmsg_permission(sock, msg, size);
|
||||
}
|
||||
|
||||
struct lsm_blob_sizes tomoyo_blob_sizes __lsm_ro_after_init = {
|
||||
.lbs_cred = sizeof(struct tomoyo_domain_info *),
|
||||
};
|
||||
|
||||
/*
|
||||
* tomoyo_security_ops is a "struct security_operations" which is used for
|
||||
* registering TOMOYO.
|
||||
|
|
@ -562,6 +566,7 @@ static int __init tomoyo_init(void)
|
|||
/* register ourselves with the security framework */
|
||||
security_add_hooks(tomoyo_hooks, ARRAY_SIZE(tomoyo_hooks), "tomoyo");
|
||||
printk(KERN_INFO "TOMOYO Linux initialized\n");
|
||||
lsm_early_cred(cred);
|
||||
blob = tomoyo_cred(cred);
|
||||
*blob = &tomoyo_kernel_domain;
|
||||
tomoyo_mm_init();
|
||||
|
|
@ -573,5 +578,6 @@ DEFINE_LSM(tomoyo) = {
|
|||
.name = "tomoyo",
|
||||
.enabled = &tomoyo_enabled,
|
||||
.flags = LSM_FLAG_LEGACY_MAJOR | LSM_FLAG_EXCLUSIVE,
|
||||
.blobs = &tomoyo_blob_sizes,
|
||||
.init = tomoyo_init,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue