aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--security/selinux/hooks.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 799d15aa35f9..305399225010 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -126,6 +126,7 @@ int selinux_enabled = 1;
126#endif 126#endif
127 127
128static struct kmem_cache *sel_inode_cache; 128static struct kmem_cache *sel_inode_cache;
129static struct kmem_cache *file_security_cache;
129 130
130/** 131/**
131 * selinux_secmark_enabled - Check to see if SECMARK is currently enabled 132 * selinux_secmark_enabled - Check to see if SECMARK is currently enabled
@@ -287,7 +288,7 @@ static int file_alloc_security(struct file *file)
287 struct file_security_struct *fsec; 288 struct file_security_struct *fsec;
288 u32 sid = current_sid(); 289 u32 sid = current_sid();
289 290
290 fsec = kzalloc(sizeof(struct file_security_struct), GFP_KERNEL); 291 fsec = kmem_cache_zalloc(file_security_cache, GFP_KERNEL);
291 if (!fsec) 292 if (!fsec)
292 return -ENOMEM; 293 return -ENOMEM;
293 294
@@ -302,7 +303,7 @@ static void file_free_security(struct file *file)
302{ 303{
303 struct file_security_struct *fsec = file->f_security; 304 struct file_security_struct *fsec = file->f_security;
304 file->f_security = NULL; 305 file->f_security = NULL;
305 kfree(fsec); 306 kmem_cache_free(file_security_cache, fsec);
306} 307}
307 308
308static int superblock_alloc_security(struct super_block *sb) 309static int superblock_alloc_security(struct super_block *sb)
@@ -6086,6 +6087,9 @@ static __init int selinux_init(void)
6086 sel_inode_cache = kmem_cache_create("selinux_inode_security", 6087 sel_inode_cache = kmem_cache_create("selinux_inode_security",
6087 sizeof(struct inode_security_struct), 6088 sizeof(struct inode_security_struct),
6088 0, SLAB_PANIC, NULL); 6089 0, SLAB_PANIC, NULL);
6090 file_security_cache = kmem_cache_create("selinux_file_security",
6091 sizeof(struct file_security_struct),
6092 0, SLAB_PANIC, NULL);
6089 avc_init(); 6093 avc_init();
6090 6094
6091 security_add_hooks(selinux_hooks, ARRAY_SIZE(selinux_hooks)); 6095 security_add_hooks(selinux_hooks, ARRAY_SIZE(selinux_hooks));