diff options
author | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2009-10-22 17:30:13 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2009-10-25 00:22:48 -0400 |
commit | 6c21a7fb492bf7e2c4985937082ce58ddeca84bd (patch) | |
tree | 6cfe11ba4b8eee26ee8b02d2b4a5fcc6ea07e4bd /security/security.c | |
parent | 6e8e16c7bc298d7887584c3d027e05db3e86eed9 (diff) |
LSM: imbed ima calls in the security hooks
Based on discussions on LKML and LSM, where there are consecutive
security_ and ima_ calls in the vfs layer, move the ima_ calls to
the existing security_ hooks.
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/security.c')
-rw-r--r-- | security/security.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/security/security.c b/security/security.c index 279757314a05..684d5ee655da 100644 --- a/security/security.c +++ b/security/security.c | |||
@@ -16,6 +16,7 @@ | |||
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]; |
@@ -235,7 +236,12 @@ int security_bprm_set_creds(struct linux_binprm *bprm) | |||
235 | 236 | ||
236 | int security_bprm_check(struct linux_binprm *bprm) | 237 | int security_bprm_check(struct linux_binprm *bprm) |
237 | { | 238 | { |
238 | return security_ops->bprm_check_security(bprm); | 239 | int ret; |
240 | |||
241 | ret = security_ops->bprm_check_security(bprm); | ||
242 | if (ret) | ||
243 | return ret; | ||
244 | return ima_bprm_check(bprm); | ||
239 | } | 245 | } |
240 | 246 | ||
241 | void security_bprm_committing_creds(struct linux_binprm *bprm) | 247 | void security_bprm_committing_creds(struct linux_binprm *bprm) |
@@ -352,12 +358,21 @@ EXPORT_SYMBOL(security_sb_parse_opts_str); | |||
352 | 358 | ||
353 | int security_inode_alloc(struct inode *inode) | 359 | int security_inode_alloc(struct inode *inode) |
354 | { | 360 | { |
361 | int ret; | ||
362 | |||
355 | inode->i_security = NULL; | 363 | inode->i_security = NULL; |
356 | return security_ops->inode_alloc_security(inode); | 364 | ret = security_ops->inode_alloc_security(inode); |
365 | if (ret) | ||
366 | return ret; | ||
367 | ret = ima_inode_alloc(inode); | ||
368 | if (ret) | ||
369 | security_inode_free(inode); | ||
370 | return ret; | ||
357 | } | 371 | } |
358 | 372 | ||
359 | void security_inode_free(struct inode *inode) | 373 | void security_inode_free(struct inode *inode) |
360 | { | 374 | { |
375 | ima_inode_free(inode); | ||
361 | security_ops->inode_free_security(inode); | 376 | security_ops->inode_free_security(inode); |
362 | } | 377 | } |
363 | 378 | ||
@@ -648,6 +663,8 @@ int security_file_alloc(struct file *file) | |||
648 | void security_file_free(struct file *file) | 663 | void security_file_free(struct file *file) |
649 | { | 664 | { |
650 | security_ops->file_free_security(file); | 665 | security_ops->file_free_security(file); |
666 | if (file->f_dentry) | ||
667 | ima_file_free(file); | ||
651 | } | 668 | } |
652 | 669 | ||
653 | int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 670 | int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
@@ -659,7 +676,12 @@ int security_file_mmap(struct file *file, unsigned long reqprot, | |||
659 | unsigned long prot, unsigned long flags, | 676 | unsigned long prot, unsigned long flags, |
660 | unsigned long addr, unsigned long addr_only) | 677 | unsigned long addr, unsigned long addr_only) |
661 | { | 678 | { |
662 | return security_ops->file_mmap(file, reqprot, prot, flags, addr, addr_only); | 679 | int ret; |
680 | |||
681 | ret = security_ops->file_mmap(file, reqprot, prot, flags, addr, addr_only); | ||
682 | if (ret) | ||
683 | return ret; | ||
684 | return ima_file_mmap(file, prot); | ||
663 | } | 685 | } |
664 | 686 | ||
665 | int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, | 687 | int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, |