aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMimi Zohar2009-10-22 16:30:13 -0500
committerJames Morris2009-10-24 23:22:48 -0500
commit6c21a7fb492bf7e2c4985937082ce58ddeca84bd (patch)
tree6cfe11ba4b8eee26ee8b02d2b4a5fcc6ea07e4bd /security/security.c
parent6e8e16c7bc298d7887584c3d027e05db3e86eed9 (diff)
downloadam43-linux-kernel-6c21a7fb492bf7e2c4985937082ce58ddeca84bd.tar.gz
am43-linux-kernel-6c21a7fb492bf7e2c4985937082ce58ddeca84bd.tar.xz
am43-linux-kernel-6c21a7fb492bf7e2c4985937082ce58ddeca84bd.zip
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.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/security/security.c b/security/security.c
index 279757314a0..684d5ee655d 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 */
21static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1]; 22static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1];
@@ -235,7 +236,12 @@ int security_bprm_set_creds(struct linux_binprm *bprm)
235 236
236int security_bprm_check(struct linux_binprm *bprm) 237int 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
241void security_bprm_committing_creds(struct linux_binprm *bprm) 247void security_bprm_committing_creds(struct linux_binprm *bprm)
@@ -352,12 +358,21 @@ EXPORT_SYMBOL(security_sb_parse_opts_str);
352 358
353int security_inode_alloc(struct inode *inode) 359int 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
359void security_inode_free(struct inode *inode) 373void 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)
648void security_file_free(struct file *file) 663void 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
653int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 670int 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
665int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, 687int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,