summaryrefslogtreecommitdiffstats
path: root/fs/proc/inode.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2018-04-11 01:31:09 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-11 19:28:33 +0200
commit195b8cf0689554db764f459730c81f741887aa5f (patch)
treed7e0c603e5e87653a114c5be07ce8f21bb8bd0d9 /fs/proc/inode.c
parentproc: randomize "struct pde_opener" (diff)
downloadlinux-195b8cf0689554db764f459730c81f741887aa5f.tar.xz
linux-195b8cf0689554db764f459730c81f741887aa5f.zip
proc: move "struct pde_opener" to kmem cache
"struct pde_opener" is fixed size and we can have more granular approach to debugging. For those who don't know, per cache SLUB poisoning and red zoning don't work if there is at least one object allocated which is hopeless in case of kmalloc-64 but not in case of standalone cache. Although systemd opens 2 files from the get go, so it is hopeless after all. Link: http://lkml.kernel.org/r/20180214082306.GB17157@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Kees Cook <keescook@chromium.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/inode.c')
-rw-r--r--fs/proc/inode.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 0331ddbee4f6..5349eb07ac29 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -54,6 +54,7 @@ static void proc_evict_inode(struct inode *inode)
}
static struct kmem_cache *proc_inode_cachep __ro_after_init;
+static struct kmem_cache *pde_opener_cache __ro_after_init;
static struct inode *proc_alloc_inode(struct super_block *sb)
{
@@ -92,7 +93,7 @@ static void init_once(void *foo)
inode_init_once(&ei->vfs_inode);
}
-void __init proc_init_inodecache(void)
+void __init proc_init_kmemcache(void)
{
proc_inode_cachep = kmem_cache_create("proc_inode_cache",
sizeof(struct proc_inode),
@@ -100,6 +101,9 @@ void __init proc_init_inodecache(void)
SLAB_MEM_SPREAD|SLAB_ACCOUNT|
SLAB_PANIC),
init_once);
+ pde_opener_cache =
+ kmem_cache_create("pde_opener", sizeof(struct pde_opener), 0,
+ SLAB_PANIC, NULL);
}
static int proc_show_options(struct seq_file *seq, struct dentry *root)
@@ -172,7 +176,7 @@ static void close_pdeo(struct proc_dir_entry *pde, struct pde_opener *pdeo)
spin_unlock(&pde->pde_unload_lock);
if (unlikely(c))
complete(c);
- kfree(pdeo);
+ kmem_cache_free(pde_opener_cache, pdeo);
}
}
@@ -347,7 +351,7 @@ static int proc_reg_open(struct inode *inode, struct file *file)
release = pde->proc_fops->release;
if (release) {
- pdeo = kmalloc(sizeof(struct pde_opener), GFP_KERNEL);
+ pdeo = kmem_cache_alloc(pde_opener_cache, GFP_KERNEL);
if (!pdeo) {
rv = -ENOMEM;
goto out_unuse;
@@ -368,7 +372,7 @@ static int proc_reg_open(struct inode *inode, struct file *file)
list_add(&pdeo->lh, &pde->pde_openers);
spin_unlock(&pde->pde_unload_lock);
} else
- kfree(pdeo);
+ kmem_cache_free(pde_opener_cache, pdeo);
}
out_unuse: