diff options
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index c3bb31ecc5aa..134a9c0d2004 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -3233,6 +3233,21 @@ static int selinux_task_create(unsigned long clone_flags) | |||
3233 | } | 3233 | } |
3234 | 3234 | ||
3235 | /* | 3235 | /* |
3236 | * allocate the SELinux part of blank credentials | ||
3237 | */ | ||
3238 | static int selinux_cred_alloc_blank(struct cred *cred, gfp_t gfp) | ||
3239 | { | ||
3240 | struct task_security_struct *tsec; | ||
3241 | |||
3242 | tsec = kzalloc(sizeof(struct task_security_struct), gfp); | ||
3243 | if (!tsec) | ||
3244 | return -ENOMEM; | ||
3245 | |||
3246 | cred->security = tsec; | ||
3247 | return 0; | ||
3248 | } | ||
3249 | |||
3250 | /* | ||
3236 | * detach and free the LSM part of a set of credentials | 3251 | * detach and free the LSM part of a set of credentials |
3237 | */ | 3252 | */ |
3238 | static void selinux_cred_free(struct cred *cred) | 3253 | static void selinux_cred_free(struct cred *cred) |
@@ -3264,6 +3279,17 @@ static int selinux_cred_prepare(struct cred *new, const struct cred *old, | |||
3264 | } | 3279 | } |
3265 | 3280 | ||
3266 | /* | 3281 | /* |
3282 | * transfer the SELinux data to a blank set of creds | ||
3283 | */ | ||
3284 | static void selinux_cred_transfer(struct cred *new, const struct cred *old) | ||
3285 | { | ||
3286 | const struct task_security_struct *old_tsec = old->security; | ||
3287 | struct task_security_struct *tsec = new->security; | ||
3288 | |||
3289 | *tsec = *old_tsec; | ||
3290 | } | ||
3291 | |||
3292 | /* | ||
3267 | * set the security data for a kernel service | 3293 | * set the security data for a kernel service |
3268 | * - all the creation contexts are set to unlabelled | 3294 | * - all the creation contexts are set to unlabelled |
3269 | */ | 3295 | */ |
@@ -5469,8 +5495,10 @@ static struct security_operations selinux_ops = { | |||
5469 | .dentry_open = selinux_dentry_open, | 5495 | .dentry_open = selinux_dentry_open, |
5470 | 5496 | ||
5471 | .task_create = selinux_task_create, | 5497 | .task_create = selinux_task_create, |
5498 | .cred_alloc_blank = selinux_cred_alloc_blank, | ||
5472 | .cred_free = selinux_cred_free, | 5499 | .cred_free = selinux_cred_free, |
5473 | .cred_prepare = selinux_cred_prepare, | 5500 | .cred_prepare = selinux_cred_prepare, |
5501 | .cred_transfer = selinux_cred_transfer, | ||
5474 | .kernel_act_as = selinux_kernel_act_as, | 5502 | .kernel_act_as = selinux_kernel_act_as, |
5475 | .kernel_create_files_as = selinux_kernel_create_files_as, | 5503 | .kernel_create_files_as = selinux_kernel_create_files_as, |
5476 | .kernel_module_request = selinux_kernel_module_request, | 5504 | .kernel_module_request = selinux_kernel_module_request, |