]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.15/slab-fix-a-crash-by-reading-proc-slab_allocators.patch
Linux 5.0.15
[thirdparty/kernel/stable-queue.git] / releases / 5.0.15 / slab-fix-a-crash-by-reading-proc-slab_allocators.patch
CommitLineData
64fefc3e
SL
1From 26dbb49dd6414012e56311cf7d5d0e9fa37d3d75 Mon Sep 17 00:00:00 2001
2From: Qian Cai <cai@lca.pw>
3Date: Sat, 6 Apr 2019 18:59:01 -0400
4Subject: slab: fix a crash by reading /proc/slab_allocators
5
6[ Upstream commit fcf88917dd435c6a4cb2830cb086ee58605a1d85 ]
7
8The commit 510ded33e075 ("slab: implement slab_root_caches list")
9changes the name of the list node within "struct kmem_cache" from "list"
10to "root_caches_node", but leaks_show() still use the "list" which
11causes a crash when reading /proc/slab_allocators.
12
13You need to have CONFIG_SLAB=y and CONFIG_MEMCG=y to see the problem,
14because without MEMCG all slab caches are root caches, and the "list"
15node happens to be the right one.
16
17Fixes: 510ded33e075 ("slab: implement slab_root_caches list")
18Signed-off-by: Qian Cai <cai@lca.pw>
19Reviewed-by: Tobin C. Harding <tobin@kernel.org>
20Cc: Tejun Heo <tj@kernel.org>
21Cc: Andrew Morton <akpm@linux-foundation.org>
22Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
23Signed-off-by: Sasha Levin <sashal@kernel.org>
24---
25 mm/slab.c | 3 ++-
26 1 file changed, 2 insertions(+), 1 deletion(-)
27
28diff --git a/mm/slab.c b/mm/slab.c
29index 2f2aa8eaf7d98..188c4b65255dc 100644
30--- a/mm/slab.c
31+++ b/mm/slab.c
32@@ -4297,7 +4297,8 @@ static void show_symbol(struct seq_file *m, unsigned long address)
33
34 static int leaks_show(struct seq_file *m, void *p)
35 {
36- struct kmem_cache *cachep = list_entry(p, struct kmem_cache, list);
37+ struct kmem_cache *cachep = list_entry(p, struct kmem_cache,
38+ root_caches_node);
39 struct page *page;
40 struct kmem_cache_node *n;
41 const char *name;
42--
432.20.1
44