diff options
Diffstat (limited to 'security/security.c')
-rw-r--r-- | security/security.c | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/security/security.c b/security/security.c index c4c673240c1c..24e060be9fa5 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -16,9 +16,11 @@ | |||
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/security.h> | 18 | #include <linux/security.h> |
19 | #include <linux/ima.h> | ||
19 | 20 | ||
20 | /* Boot-time LSM user choice */ | 21 | /* Boot-time LSM user choice */ |
21 | static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1]; | 22 | static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] = |
23 | CONFIG_DEFAULT_SECURITY; | ||
22 | 24 | ||
23 | /* things that live in capability.c */ | 25 | /* things that live in capability.c */ |
24 | extern struct security_operations default_security_ops; | 26 | extern struct security_operations default_security_ops; |
@@ -79,8 +81,10 @@ __setup("security=", choose_lsm); | |||
79 | * | 81 | * |
80 | * Return true if: | 82 | * Return true if: |
81 | * -The passed LSM is the one chosen by user at boot time, | 83 | * -The passed LSM is the one chosen by user at boot time, |
82 | * -or user didn't specify a specific LSM and we're the first to ask | 84 | * -or the passed LSM is configured as the default and the user did not |
83 | * for registration permission, | 85 | * choose an alternate LSM at boot time, |
86 | * -or there is no default LSM set and the user didn't specify a | ||
87 | * specific LSM and we're the first to ask for registration permission, | ||
84 | * -or the passed LSM is currently loaded. | 88 | * -or the passed LSM is currently loaded. |
85 | * Otherwise, return false. | 89 | * Otherwise, return false. |
86 | */ | 90 | */ |
@@ -235,7 +239,12 @@ int security_bprm_set_creds(struct linux_binprm *bprm) | |||
235 | 239 | ||
236 | int security_bprm_check(struct linux_binprm *bprm) | 240 | int security_bprm_check(struct linux_binprm *bprm) |
237 | { | 241 | { |
238 | return security_ops->bprm_check_security(bprm); | 242 | int ret; |
243 | |||
244 | ret = security_ops->bprm_check_security(bprm); | ||
245 | if (ret) | ||
246 | return ret; | ||
247 | return ima_bprm_check(bprm); | ||
239 | } | 248 | } |
240 | 249 | ||
241 | void security_bprm_committing_creds(struct linux_binprm *bprm) | 250 | void security_bprm_committing_creds(struct linux_binprm *bprm) |
@@ -352,12 +361,21 @@ EXPORT_SYMBOL(security_sb_parse_opts_str); | |||
352 | 361 | ||
353 | int security_inode_alloc(struct inode *inode) | 362 | int security_inode_alloc(struct inode *inode) |
354 | { | 363 | { |
364 | int ret; | ||
365 | |||
355 | inode->i_security = NULL; | 366 | inode->i_security = NULL; |
356 | return security_ops->inode_alloc_security(inode); | 367 | ret = security_ops->inode_alloc_security(inode); |
368 | if (ret) | ||
369 | return ret; | ||
370 | ret = ima_inode_alloc(inode); | ||
371 | if (ret) | ||
372 | security_inode_free(inode); | ||
373 | return ret; | ||
357 | } | 374 | } |
358 | 375 | ||
359 | void security_inode_free(struct inode *inode) | 376 | void security_inode_free(struct inode *inode) |
360 | { | 377 | { |
378 | ima_inode_free(inode); | ||
361 | security_ops->inode_free_security(inode); | 379 | security_ops->inode_free_security(inode); |
362 | } | 380 | } |
363 | 381 | ||
@@ -434,6 +452,26 @@ int security_path_truncate(struct path *path, loff_t length, | |||
434 | return 0; | 452 | return 0; |
435 | return security_ops->path_truncate(path, length, time_attrs); | 453 | return security_ops->path_truncate(path, length, time_attrs); |
436 | } | 454 | } |
455 | |||
456 | int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt, | ||
457 | mode_t mode) | ||
458 | { | ||
459 | if (unlikely(IS_PRIVATE(dentry->d_inode))) | ||
460 | return 0; | ||
461 | return security_ops->path_chmod(dentry, mnt, mode); | ||
462 | } | ||
463 | |||
464 | int security_path_chown(struct path *path, uid_t uid, gid_t gid) | ||
465 | { | ||
466 | if (unlikely(IS_PRIVATE(path->dentry->d_inode))) | ||
467 | return 0; | ||
468 | return security_ops->path_chown(path, uid, gid); | ||
469 | } | ||
470 | |||
471 | int security_path_chroot(struct path *path) | ||
472 | { | ||
473 | return security_ops->path_chroot(path); | ||
474 | } | ||
437 | #endif | 475 | #endif |
438 | 476 | ||
439 | int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) | 477 | int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) |
@@ -628,6 +666,8 @@ int security_file_alloc(struct file *file) | |||
628 | void security_file_free(struct file *file) | 666 | void security_file_free(struct file *file) |
629 | { | 667 | { |
630 | security_ops->file_free_security(file); | 668 | security_ops->file_free_security(file); |
669 | if (file->f_dentry) | ||
670 | ima_file_free(file); | ||
631 | } | 671 | } |
632 | 672 | ||
633 | int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 673 | int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
@@ -639,7 +679,12 @@ int security_file_mmap(struct file *file, unsigned long reqprot, | |||
639 | unsigned long prot, unsigned long flags, | 679 | unsigned long prot, unsigned long flags, |
640 | unsigned long addr, unsigned long addr_only) | 680 | unsigned long addr, unsigned long addr_only) |
641 | { | 681 | { |
642 | return security_ops->file_mmap(file, reqprot, prot, flags, addr, addr_only); | 682 | int ret; |
683 | |||
684 | ret = security_ops->file_mmap(file, reqprot, prot, flags, addr, addr_only); | ||
685 | if (ret) | ||
686 | return ret; | ||
687 | return ima_file_mmap(file, prot); | ||
643 | } | 688 | } |
644 | 689 | ||
645 | int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, | 690 | int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, |
@@ -719,9 +764,9 @@ int security_kernel_create_files_as(struct cred *new, struct inode *inode) | |||
719 | return security_ops->kernel_create_files_as(new, inode); | 764 | return security_ops->kernel_create_files_as(new, inode); |
720 | } | 765 | } |
721 | 766 | ||
722 | int security_kernel_module_request(void) | 767 | int security_kernel_module_request(char *kmod_name) |
723 | { | 768 | { |
724 | return security_ops->kernel_module_request(); | 769 | return security_ops->kernel_module_request(kmod_name); |
725 | } | 770 | } |
726 | 771 | ||
727 | int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags) | 772 | int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags) |