提交 54bb6552 编写于 作者: E Eric Paris 提交者: Al Viro

ima: initialize ima before inodes can be allocated

ima wants to create an inode information struct (iint) when inodes are
allocated.  This means that at least the part of ima which does this
allocation (the allocation is filled with information later) should
before any inodes are created.  To accomplish this we split the ima
initialization routine placing the kmem cache allocator inside a
security_initcall() function.  Since this makes use of radix trees we also
need to make sure that is initialized before security_initcall().
Signed-off-by: NEric Paris <eparis@redhat.com>
Acked-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 8eb988c7
...@@ -657,9 +657,9 @@ asmlinkage void __init start_kernel(void) ...@@ -657,9 +657,9 @@ asmlinkage void __init start_kernel(void)
proc_caches_init(); proc_caches_init();
buffer_init(); buffer_init();
key_init(); key_init();
radix_tree_init();
security_init(); security_init();
vfs_caches_init(totalram_pages); vfs_caches_init(totalram_pages);
radix_tree_init();
signals_init(); signals_init();
/* rootfs populating might need page-writeback */ /* rootfs populating might need page-writeback */
page_writeback_init(); page_writeback_init();
......
...@@ -65,7 +65,6 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode, ...@@ -65,7 +65,6 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
const char *cause, int result, int info); const char *cause, int result, int info);
/* Internal IMA function definitions */ /* Internal IMA function definitions */
void ima_iintcache_init(void);
int ima_init(void); int ima_init(void);
void ima_cleanup(void); void ima_cleanup(void);
int ima_fs_init(void); int ima_fs_init(void);
......
...@@ -52,9 +52,6 @@ int ima_inode_alloc(struct inode *inode) ...@@ -52,9 +52,6 @@ int ima_inode_alloc(struct inode *inode)
struct ima_iint_cache *iint = NULL; struct ima_iint_cache *iint = NULL;
int rc = 0; int rc = 0;
if (!ima_initialized)
return 0;
iint = kmem_cache_alloc(iint_cache, GFP_NOFS); iint = kmem_cache_alloc(iint_cache, GFP_NOFS);
if (!iint) if (!iint)
return -ENOMEM; return -ENOMEM;
...@@ -118,8 +115,6 @@ void ima_inode_free(struct inode *inode) ...@@ -118,8 +115,6 @@ void ima_inode_free(struct inode *inode)
{ {
struct ima_iint_cache *iint; struct ima_iint_cache *iint;
if (!ima_initialized)
return;
spin_lock(&ima_iint_lock); spin_lock(&ima_iint_lock);
iint = radix_tree_delete(&ima_iint_store, (unsigned long)inode); iint = radix_tree_delete(&ima_iint_store, (unsigned long)inode);
spin_unlock(&ima_iint_lock); spin_unlock(&ima_iint_lock);
...@@ -141,9 +136,11 @@ static void init_once(void *foo) ...@@ -141,9 +136,11 @@ static void init_once(void *foo)
kref_set(&iint->refcount, 1); kref_set(&iint->refcount, 1);
} }
void __init ima_iintcache_init(void) static int __init ima_iintcache_init(void)
{ {
iint_cache = iint_cache =
kmem_cache_create("iint_cache", sizeof(struct ima_iint_cache), 0, kmem_cache_create("iint_cache", sizeof(struct ima_iint_cache), 0,
SLAB_PANIC, init_once); SLAB_PANIC, init_once);
return 0;
} }
security_initcall(ima_iintcache_init);
...@@ -321,7 +321,6 @@ static int __init init_ima(void) ...@@ -321,7 +321,6 @@ static int __init init_ima(void)
{ {
int error; int error;
ima_iintcache_init();
error = ima_init(); error = ima_init();
ima_initialized = 1; ima_initialized = 1;
return error; return error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册